influxdata / kapacitor

Open source framework for processing, monitoring, and alerting on time series data
MIT License
2.31k stars 493 forks source link

import/export alerts #1348

Open petercelentano opened 7 years ago

petercelentano commented 7 years ago

Quick question,

I'm using kapacitor version 1.2 on centos 7 (installed via the official repo). Is there a CLI option to export existing alerts into tick scripts? There doesn't seem to be a clear command to accomplish this.

Thank you!

nathanielc commented 7 years ago

@petercelentano There is not an easy way to do this with the CLI, but using the HTTP API would be a short script. See https://docs.influxdata.com/kapacitor/v1.2/api/api/#tasks

petercelentano commented 7 years ago

No worries, created and tested a script that can handle import/export functions, by either exporting all available alerts (if none are selected), exporting specified alerts, and importing specified alerts. I'll research the http api soon, but I would think that having import/export functionality in the cli would be considered a core feature, especially for backup and migration purposes.

nathanielc commented 7 years ago

@petercelentano The CLI does support a backup command which backs up all tasks, templates, replays, recordings etc.

kapacitor backup path/to/backup/kapacitor-$(date +%s).db

To restore simply provide the backup file to the Kapacitor process on startup. Live restores are not supported, which means it is still not quite an import/export tool but similar.

petercelentano commented 7 years ago

That's good to know that a backup functionality is there, but what I really needed was the ability to export or import specific alerts without taking downtime.

Starting in which version is the backup command supported? I'm running v.1.1.1, and I do not see that option listed in the help file. Also, is the kapacitor.db file an encrypted sqlite database? If so, where can I find the password to decrypt the database?

nathanielc commented 7 years ago

It was added in v1.3.0. The file is not encrypted and is actually a boltdb file.

petercelentano commented 7 years ago

Thank you, I'll look into upgrading. Thanks for the info on the DB file.

ajayanaj commented 5 years ago

@nathanielc Hi, we are taking kapacitor backups using the API and we are able to view the kapacitor tasks using boltdbbrowser, I think the tasks are showing as binary in boltdbbrowser. But we would like to see these tasks as tick script format. Is there any option to import kapacitor tasks in boltdb as tick script format?

whoAbhishekSah commented 4 years ago

@petercelentano The CLI does support a backup command which backs up all tasks, templates, replays, recordings etc.

kapacitor backup path/to/backup/kapacitor-$(date +%s).db

To restore simply provide the backup file to the Kapacitor process on startup. Live restores are not supported, which means it is still not quite an import/export tool but similar.

@nathanielc how to import from the .db file ?