All Apps and Add-ons

Splunk for k8s - incorrect search syntax will produce incorrect results

guilmxm
Influencer

Hi,

The embedded search:

[Pod CPU/Memeory Usage Trend]
search = | mstats avg(_value) as cpu  WHERE `k8s-metrics-index` AND metric_name="kube.pod.cpu.usage" span=10s  BY "pod" | join type=left _time [ | mstats avg(_value) as memory WHERE `k8s-metrics-index` AND metric_name="kube.pod.memory.usage" BY span=10s "pod"] | stats sparkline(avg(cpu)) as "CPU Usage", sparkline(avg(memory)) as "Memory Usage" BY "pod"

Produces incorrect results to the (ugly) usage of "| joint type=left _time", as the following can demonstrate:

alt text

replaced with an append / appendcols:

alt text

To avoid ugly subsearches, I would kindly suggest something in replacement like:

| mstats avg(_value) as value WHERE index = kubernetes-metrics AND (metric_name="kube.pod.cpu.usage" OR metric_name="kube.pod.memory.usage") span=10s BY metric_name "pod"
| rex field=metric_name "[^\.]*\.[^\.]*\.(?<metric>[^\.]*)\."
| eval {metric}=value
| stats sparkline(avg(cpu)) as "CPU Usage", sparkline(avg(memory)) as "Memory Usage" BY "pod"

Which would avoid running subsearches that can result in bad performances and truncation.

Kind regards,

Guilhem

0 Karma
1 Solution

mattymo
Splunk Employee
Splunk Employee

Hey guilmxm!

Will pass along the feedback and work with the team. Will let you know once cleaned up!

Matt

- MattyMo

View solution in original post

0 Karma

mattymo
Splunk Employee
Splunk Employee

Hey guilmxm!

Will pass along the feedback and work with the team. Will let you know once cleaned up!

Matt

- MattyMo
0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...