Getting Data In

How to use Time modifiers in mstats command?

ssn
Explorer

I want to  use relative time modifiers (earliest/latest) in mstats command. Not sure how to use the time format.

 

 

| mstats earliest=-1h avg(xxx) WHERE index=xxx

 

 

This is failing since it is in relative time format. Documentation mentions about 'timeformat' attribute but I am not sure how to use it for relative time.

Labels (1)
Tags (1)

ddvali
Explorer

Did you ever find a solution for this ? I also have same requirement.

VatsalJagani
SplunkTrust
SplunkTrust

You need to put earliest and latest as part of where condition.

| mstats latest(_value) AS val WHERE index="myindex" earliest=-1h@h latest=now BY host span=15m

Reference - https://docs.splunk.com/Documentation/Splunk/8.2.5/SearchReference/Mstats

govardha
Path Finder

The usage for this is as follows.  Hope this helps.

|mstats latest(_value) AS foo WHERE index="some_metrics_index" earliest=-300s latest=now() metric_name=some.metric BY host span=1m



nbenson27
Engager

Hello! 

Did you ever find a solution for this? 

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...