The influx cli tool provides the ability to manage dashboards, tasks etc. in a collection called a "stack". It provides the ability to export a template for all of these objects, and apply a modified version to update our stack.
This tool builds on top of the influx cli to make working with that template file a better, and easier experience. It transforms the single large yaml file, with inlined flux code like this:
Into a well-organised set of individual templates, with the flux code extracted so we can work with it easily, like this:
This tool can be built using go by running:
go install github.com/influxdata/influxdb-stack-manager
.
The influx cli tool will also need to be installed, and can be found here.
To first create a stack to manage, you will need to use the influx cli tool itself. To create a stack, run:
influx stacks init -n MyStackName -d MyStackDescription
To add resources to the stack, you will need to know their IDs which can be found either from the influxdb UI, or by listing them, and then updating the stack with the new resources:
influx dashboards
influx task list
influx stacks update --stack-id $STACK_ID \
--addResource=Dashboard=$DASHBOARD_ID
--addResource=Task=$TASK_ID
With the stack created, you can use the influxdb-stack-manager to actually fetch your templates and push up any changes.
influxdb-stack-manager pull <stack-id>
Please be aware though, that this will destructively update the template
directory (which can be specified using the --directory
or -d
argument).
To apply any changes you've made to a stack, run:
influxdb-stack-manager push <stack-id>
Help can be found on by supplying an -h
or --help
argument to any command.
If you would like to use the same templates for multiple stacks (in the same or different influxdb clusters), you may want to inject data into the templates or flux code. To do this:
The templates and flux queries can be amended to use injected fields using the
golang templating syntax. For example, if
I wanted to inject a set of thresholds which I would alert on, I could inject
the field {{ .Thresholds.CPU }}
.
The data to be injected can be specified either in json or yaml format, for example:
{
"Thresholds": {
"CPU": 75.0,
"Memory": 60.0
}
}
Thresholds:
CPU: 75.0
Memory: 60.0
When pushing, add the --data-file
flag:
influxdb-stack-manager push <stack-id> --data-file "data/cluster-1.yml"
- Provide release binaries
- Provide docker images
- Allow running queries with injected data