Snapshot with index pattern

Hello

I'm trying to create a python script to automaticly create snapshots. This is not a big deal.
But will use kibanas "Index Pattern".
You find that under kibana - Management /Kibana. there you may create a new Index Pattern. Is there any way to read out those Index Patterns? Hopefully somehow with any API/Python.
i.e. I have some Patterns: "auditbeat-", metricbeat-"
Those Index Pattern gat at the end a date.
I know how to do a snapshot of "auditbeats" but as I would like to automate as much as possible, I would like to read out the Patterns. But I have to know first, that there is a "autidbeats"...
Of course I may list all Indices, sort it, cut it, parse it... I'm happy, if there is an easier way...

thanks
rog

You can use the Saved Objects API. For example:

https://your-kibana-instance.com/api/saved_objects?fields=title

Will give you all your index patterns.

Thank you
Pretty nice idea. But how do I call/see the Index Patterns?
As I said, I'm able to call functions/requests and so on via Python. What I need to know is the command to see the "Index Patterns"-List.

thanks
rog

You should use your favourite Python HTTP library - here is a version in python 2.7 using requests:

import json
import requests

response = requests.get("https://your-kibana-instance.com/api/saved_objects?fields=title&per_page=500")
json_data = json.loads(response.text)
print [pattern.get('attributes').get('title') for pattern in json_data.get('saved_objects') if pattern.get('type') == 'index-pattern']

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.