https://github.com/influxdata/influxdb-stack-manager
CLI tool to make managing stacks easier
https://github.com/influxdata/influxdb-stack-manager
Last synced: 2 months ago
JSON representation
CLI tool to make managing stacks easier
- Host: GitHub
- URL: https://github.com/influxdata/influxdb-stack-manager
- Owner: influxdata
- License: mit
- Created: 2021-04-08T14:33:35.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-13T11:47:57.000Z (over 3 years ago)
- Last Synced: 2025-04-11T01:41:30.104Z (9 months ago)
- Language: Go
- Size: 309 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# InfluxDB Stack Manager
The [influx cli tool](https://github.com/influxdata/influx-cli) 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:

## Installation
This tool can be built using [go](https://golang.org/) 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](https://github.com/influxdata/influxdb).
## Basic Usage
To first create a stack to manage, you will need to use the influx cli
tool itself. To create a stack, run:
```bash
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:
```bash
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
```
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
```
Help can be found on by supplying an `-h` or `--help` argument to any command.
## Templating
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:
### 1. Add fields to your templates/flux queries
The templates and flux queries can be amended to use injected fields using the
[golang templating syntax](https://pkg.go.dev/text/template). For example, if
I wanted to inject a set of thresholds which I would alert on, I could inject
the field `{{ .Thresholds.CPU }}`.
### 2. Create a data file with the values to inject
The data to be injected can be specified either in json or yaml format, for example:
```json
{
"Thresholds": {
"CPU": 75.0,
"Memory": 60.0
}
}
```
```yaml
Thresholds:
CPU: 75.0
Memory: 60.0
```
### 3. Specify the data file when pushing
When pushing, add the `--data-file` flag:
```
influxdb-stack-manager push --data-file "data/cluster-1.yml"
```
## TODO
- [ ] Provide release binaries
- [ ] Provide docker images
- [ ] Allow running queries with injected data