Dynamic Dashboard Schema and Dynamic kibana charts

Hey Ashvita,

Sorry for the delayed response. I ended up writing a go program which connects to elasticsearch using the net/http client, creates new visualizations, fetches the existing dashboard, adds the new visualizations to the dashboard and uploads the new dashboard in elasticsearch.

For example, lets say you have a dashboard called Network-Bandwidth and need to add ingress and egress visualizations of your servers in it.

  • Fetch all visualizations present
    GET - http://localhost:9200/.kibana/visualization/_search

  • Check if the visualizations you need exists, if not, create new ones
    PUT - http://localhost:9200/.kibana/visualization/Egress%20Bandwidth%20-%20abc
    {
    "title": "Egress Bandwidth - abc",
    "visState": "{"title":"Egress Bandwidth - abc","type":"timelion","params":{"expression":".es(index=\"logstash-\", q=\"system.network.type.keyword:(Egress OR Both)\",metric=\"max:system.network.out.bytes\", split=\"system.network.name.keyword:20\", kibana=true).derivative().multiply(8).scale_interval(1s).if(operator=\"lt\", if=0, then=0).trim(start=2,end=1).label(regex=\"^. system.network.name.keyword:(.+) > .$\", label=\"$1\").lines(width=2).yaxis(units=bits/s, min=0)","interval":"auto"},"aggs":[],"listeners":{}}",
    "uiStateJSON": "{}",
    "description": "",
    "version": 1,
    "kibanaSavedObjectMeta": {
    "searchSourceJSON": "{"query":{"query_string":{"query":"
    "}},"filter":[]}"
    }
    }

  • Fetch the dashboard using the following URL
    GET - http://localhost:9200/.kibana/dashboard/Network-Bandwidth/_source

  • Re-create the panelsJSON of the dashboard including the new visualization(s)

  • Upload the new dashboard using the following
    PUT - http://localhost:9200/.kibana/dashboard/Network-Bandwidth
    {"title":"Network-Bandwidth","hits":0,"description":"Graph with network bandwidth for nodes","panelsJSON":"[{"col":1,"id":"Egress Bandwidth - abc","panelIndex":2,"row":1,"size_x":6,"size_y":4,"type":"visualization"},{"col":7,"id":"Ingress Bandwidth - abc","panelIndex":8,"row":1,"size_x":6,"size_y":4,"type":"visualization"},{"col":1,"id":"Egress Bandwidth - test123","panelIndex":7,"row":6,"size_x":6,"size_y":4,"type":"visualization"},{"col":7,"id":"Ingress Bandwidth - test123","panelIndex":13,"row":6,"size_x":6,"size_y":4,"type":"visualization"}]","optionsJSON":"{"darkTheme":false}","uiStateJSON":"{}","version":1,"timeRestore":true,"timeTo":"now","timeFrom":"now-30m","refreshInterval":{"display":"30 seconds","pause":false,"section":1,"value":30000},"kibanaSavedObjectMeta":{"searchSourceJSON":"{"filter":[{"query":{"query_string":{"query":"*"}}}],"highlightAll":true,"version":true}"}}

2 Likes