Skip to content

Instantly share code, notes, and snippets.

@pmuellr
Created October 6, 2022 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmuellr/d89e1c2fee4bddca23880b23ec4c7905 to your computer and use it in GitHub Desktop.
Save pmuellr/d89e1c2fee4bddca23880b23ec4c7905 to your computer and use it in GitHub Desktop.
Kibana 8.4.1 saved objects for Task Manager tasks viz
{"attributes":{"fieldAttrs":"{}","fields":"[]","name":"Task Manager","runtimeFieldMap":"{}","sourceFilters":"[]","timeFieldName":"task.runAt","title":".kibana_task_manager","typeMeta":"{}"},"coreMigrationVersion":"8.4.1","id":"c0766836-7fb8-4710-a7a5-f67c70145405","migrationVersion":{"index-pattern":"8.0.0"},"references":[],"type":"index-pattern","updated_at":"2022-10-05T22:27:48.679Z","version":"WzM3OTgwLDFd"}
{"attributes":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"fad2ab1a-f33d-47c8-bece-16d3b2ce0452":{"columnOrder":["aa331f51-914a-4329-a429-7cc0e771b6ab","aec91a26-7c5e-469a-ac39-544214281856","a35f50da-207e-4219-bcae-14f927450ec4"],"columns":{"a35f50da-207e-4219-bcae-14f927450ec4":{"dataType":"number","isBucketed":false,"label":"Count of records","operationType":"count","params":{"emptyAsNull":true},"scale":"ratio","sourceField":"___records___"},"aa331f51-914a-4329-a429-7cc0e771b6ab":{"dataType":"string","isBucketed":true,"label":"Top 3 values of task.taskType","operationType":"terms","params":{"missingBucket":false,"orderBy":{"columnId":"a35f50da-207e-4219-bcae-14f927450ec4","type":"column"},"orderDirection":"desc","otherBucket":true,"parentFormat":{"id":"terms"},"size":3},"scale":"ordinal","sourceField":"task.taskType"},"aec91a26-7c5e-469a-ac39-544214281856":{"dataType":"date","isBucketed":true,"label":"task.runAt","operationType":"date_histogram","params":{"dropPartials":false,"includeEmptyRows":true,"interval":"auto"},"scale":"interval","sourceField":"task.runAt"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"axisTitlesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"fittingFunction":"None","gridlinesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"labelsOrientation":{"x":0,"yLeft":0,"yRight":0},"layers":[{"accessors":["a35f50da-207e-4219-bcae-14f927450ec4"],"layerId":"fad2ab1a-f33d-47c8-bece-16d3b2ce0452","layerType":"data","position":"top","seriesType":"bar_stacked","showGridlines":false,"splitAccessor":"aa331f51-914a-4329-a429-7cc0e771b6ab","xAccessor":"aec91a26-7c5e-469a-ac39-544214281856"}],"legend":{"isVisible":true,"position":"bottom","shouldTruncate":false},"preferredSeriesType":"bar_stacked","tickLabelsVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"valueLabels":"hide","valuesInLegend":false,"yLeftExtent":{"lowerBound":0,"mode":"custom","upperBound":50}}},"title":"Task Manager tasks","visualizationType":"lnsXY"},"coreMigrationVersion":"8.4.1","id":"503ea1d0-44fd-11ed-b752-0d3f4f8fdcea","migrationVersion":{"lens":"8.3.0"},"references":[{"id":"c0766836-7fb8-4710-a7a5-f67c70145405","name":"indexpattern-datasource-layer-fad2ab1a-f33d-47c8-bece-16d3b2ce0452","type":"index-pattern"}],"type":"lens","updated_at":"2022-10-05T22:45:54.237Z","version":"WzQ0OTIyLDFd"}
{"attributes":{"description":"","hits":0,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"},"optionsJSON":"{\"useMargins\":true,\"syncColors\":false,\"syncTooltips\":false,\"hidePanelTitles\":false}","panelsJSON":"[{\"version\":\"8.4.1\",\"type\":\"lens\",\"gridData\":{\"x\":0,\"y\":0,\"w\":45,\"h\":22,\"i\":\"687800e6-cbf7-46a5-97ce-e7f432202e4e\"},\"panelIndex\":\"687800e6-cbf7-46a5-97ce-e7f432202e4e\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_687800e6-cbf7-46a5-97ce-e7f432202e4e\"}]","timeRestore":false,"title":"Task Manager tasks","version":1},"coreMigrationVersion":"8.4.1","id":"c7d89620-456f-11ed-b752-0d3f4f8fdcea","migrationVersion":{"dashboard":"8.4.0"},"references":[{"id":"503ea1d0-44fd-11ed-b752-0d3f4f8fdcea","name":"687800e6-cbf7-46a5-97ce-e7f432202e4e:panel_687800e6-cbf7-46a5-97ce-e7f432202e4e","type":"lens"}],"type":"dashboard","updated_at":"2022-10-06T12:09:51.496Z","version":"WzIzNDU1NiwxXQ=="}
{"excludedObjects":[],"excludedObjectsCount":0,"exportedCount":3,"missingRefCount":0,"missingReferences":[]}
@pmuellr
Copy link
Author

pmuellr commented Oct 6, 2022

Built on an Elastic Stack 8.4.1 cloud deployment, and should run on any version greater than that.

Visualization to show Task Managers tasks, by type, queued up to run. In this example, we start with 10 rules which are creating 4 server log actions every run, with the rule interval at 1s (but task manager only polls every 3s). The rules are blue, the actions are green, (but change color later) the other colors are rando tasks popping up to run. Each column is the number of tasks queued to run at that time, with "now" being pretty close to the right edge of the viz - so columns to the left are the next to run, and the closer to the left edge they are, the longer they have been waiting to run.

The visualization / dash is using relative time units - try 1 minute ago -> 5 minutes from now. Then turn on auto-refresh for every second. On each refresh, you'll see tasks on the left "disappear" as they are being executed, and "new" tasks that are ready to run or will be ready soon appear on the right.

After a few seconds, the rules stop detecting alerts, so stop queuing up actions, and the backlog is cleaned up.

Task Manager tasks

To install into your Kibana from the command line, you can download the .ndjson file and then import into Kibana via Stack Management / Saved Objects / Import. Or use the following command:

curl -L https://ela.st/pmuellr-task-manager-tasks-ndjson | curl $KBN_URL/api/saved_objects/_import "-Ffile=@-;filename=task-manager-tasks.ndjson" -H "kbn-xsrf: foo"

You may need a -k option on the second curl invocation, if you are running Kibana in dev mode or otherwise using a self-signed or non-public TLS certificate on Kibana.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment