Splunk 查询示例

rangmap使用

index= aliyun sourcetype=ali_formatted_cdn (message.reqPath="/merch/products/v2*" OR message.reqPath="/merch/skus/v2*" OR message.reqPath="/merch/value_added_services/v1*" OR message.reqPath="/merch/contents/v1*" OR message.reqPath="/merch/prices/v2*" ) NOT message.reqPath="*batch*"

| replace /merch/products/v2* with merchproductsv2 in message.reqPath

| replace /merch/skus/v2* with merchskusv2 in message.reqPath

| replace /merch/value_added_services/v1* with vasv1 in message.reqPath

| replace /merch/contents/v1* with productcontentservice in message.reqPath

| replace /merch/prices/v2* with merchpricesv2 in message.reqPath

| stats count BY netPerf.downloadTime 

| rangemap field=netPerf.downloadTime  0-2s=0-2000 2-5s=2001-5000 5-10s=5001-10000 10-30s=10001-30000 30-60s=30001-60000 default=60s+

| stats sum(count) by range

 

嵌套查询:

index=app app=xx [search index=app app=xx traceId=xx | top limit=10| table traceId] 

 

正则表达:

index=app app=servicemonitor host="catalog-prod-catalog_servicemonitorv1-.ip-100-64-134-134-cn-northwest-1a" app:MERCH-VALUE_ADDED_SERVICES-V1 instanceId:i-0ebd2cd66d8584cb4

| rex field=_raw ", asg:(?<asgn>[\\w-]*),"

| rex field=_raw ", instanceId:(?<in>[\\w-]*)"

| table in asgn

| stats count by in asgn

 

 

index=app app=servicemonitor (error OR failed OR failure)

| rex field=_raw " method:(?<mname>[a-zA-Z0-9]*), "

| rex field=_raw " app:(?<appname>[a-zA-Z0-9_-]*), "

| stats count by mname appname

 

 

替换操作:

index= aliyun sourcetype=ali_formatted_cdn (message.reqPath="/merch/*" NOT message.reqPath="*batch*")

| replace /merch/products/v* with merchproducts in message.reqPath

| replace /merch/skus/v* with merchskusv2 in message.reqPath

| replace /merch/value_added_services/v* with vasv1 in message.reqPath

| replace /merch/contents/v* with productcontentservice in message.reqPath

| replace /merch/prices/v* with merchpricesv2 in message.reqPath

| stats avg(netPerf.downloadTime) as avgDownloadTime,p95(netPerf.downloadTime) as p95DownloadTime,max(netPerf.downloadTime) as maxDownloadTime by message.reqPath

| eval avgDownloadTime=avgDownloadTime/1000, p95DownloadTime=p95DownloadTime/1000, maxDownloadTime=maxDownloadTime/1000

 

index=akamai message.reqHost=api.xx.com geo.country=CN

| fields message.reqPath

| rex mode=sed field=message.reqPath "s/%2f/\//g"

| rex mode=sed field=message.reqPath "s/[a-fA-F0-9]{8}-([a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}/{uuid}/g"

| search message.reqPath="/product_feed/*"

| stats count by message.reqPath

 

统计YN比率

index= aliyun sourcetype=ali_formatted_cdn message.reqPath ="/xxx/contents*"

| eval gt1s=if('netPerf.downloadTime'>1000, "Y", "N")

| stats count by gt1s

 

index= aliyun sourcetype=ali_formatted_cdn ( message.reqPath="/xx/contents*") 

| eval hit=if(like('netPerf.cacheStatus', "HIT%"), "Y", "N")

| stats count by hit

 

统计区间event数量最大值:

index=web source="/var/log/xx/productcontent/access.log"  | bin span=1s _time  | top 1 _time

 

index=aliyun sourcetype=ali_formatted_cdn  message.reqPath="/merch/contents*" | bin span=1s _time  | top 1 _time

 

posted @   原子切割员  阅读(295)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
点击右上角即可分享
微信分享提示