Deployment Architecture

How to monitor cpu utlization from linux and unix ?

karthi2809
Builder

In my scenario I have to consolidated cpu utlization of all application in one query.But i cannot get proper output because my cpu for linux used vmstat for unix mpstat used so my output is mismatch .i will attach below.How to frame a query to get all server cpu .
Used Query:
index=XXX* OR index=FFF* OR index=EEE* OR index="GGG*" OR index="HH*"source=cpu | rex field=_raw "CPUPctUsed=(?\d*)" | eval CPUPctUsed2=100-pctIdle | fillnull value="NA" CPUPctUsed1 CPUPctUsed2 | eval CPUPctUsed=if(CPUPctUsed1="NA",CPUPctUsed2,CPUPctUsed1) | stats avg(CPUPctUsed) as "Avg" max(CPUPctUsed) as "Max" by host index | eval Avg=round(Avg,2) | where Max > 95 | table index host Avg Max

Thanks in advance

Tags (3)
0 Karma

renjith_nair
Legend

@karthi2809 ,
Your search does not show how the raw events are stored. However, you could try extracting the output from vmstat and mpstat on two different variables and pick up the non empty value , something like

index=XXX* OR index=FFF* OR index=EEE* OR index="GGG*" OR index="HH*"source=cpu|eval mpstat="extraction logic for mpstat" |eval vmstat="extraction logic for vmstat" |eval CPUPctUsed=coalesce(mpstat,vmstat)|stats avg(CPUPctUsed) as "Avg" max(CPUPctUsed) as "Max" by host index | eval Avg=round(Avg,2) | where Max > 95 | table index host Avg Max 
Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...