Splunk Search

How to search with the metadata command using the Python API?

lohitkidu
Path Finder

Hi ,

I am not sure how to use the metadata command using the Python API as it is required to be the first command like | metadata type=hosts, but when we use the Python API every search has to be appended by search like search index=abc.

In case of metadata, if I use search metadata type=hosts or search | metadata type=hosts, none of them are working.

Any ideas how to use it?

0 Karma
1 Solution

lohitkidu
Path Finder

It turns out that while using metadata command over API, we do not require search command as a prefix.

View solution in original post

0 Karma

lohitkidu
Path Finder

It turns out that while using metadata command over API, we do not require search command as a prefix.

0 Karma

somesoni2
Revered Legend

Try this as the search query

search index=_internal | head 1 | map maxsearches=1 "| metadata type=hosts"
0 Karma

lohitkidu
Path Finder

Never worked for me.

0 Karma
Get Updates on the Splunk Community!

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 ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...