Skip to content

Instantly share code, notes, and snippets.

@yosiat
Last active February 10, 2023 21:08
Show Gist options
  • Save yosiat/a850abd319ac7cf7c3c0 to your computer and use it in GitHub Desktop.
Save yosiat/a850abd319ac7cf7c3c0 to your computer and use it in GitHub Desktop.
kapacitor api doc

HTTP API

Base url is "http://localhost:9092"

Replay

POST http://localhost:9092/api/v1/replay?name=cpu_alert&id={record id}&clock=fast&rec-time=false

rec-time - mock the times

Record

POST http://localhost:9092/api/v1/record?type=stream&name=cpu_alert&duration=10s

{
    "RecordingID": "75df77ac-05fb-450e-89cf-e050ba8fba85"
}

Define

POST "http://localhost:9092/task?name=yosi&type=(stream|batch)&dbrps=[{"db":"kapacitor_example","rp":"default"}]

Contents: tick script (of course "application/octetstream")

Response:

{ "Error": "Some error" }

disable

POST http://localhost:9092/api/v1/disable?name=cpu_alert

enable

POST http://localhost:9092/api/v1/enable?name=cpu_alert

Show

GET http://localhost:9092/task?name=cpu_alert

{
    "Name": "cpu_alert",
    "Type": 0,
    "DBRPs": [
        {
            "db": "kapacitor_example",
            "rp": "default"
        }
    ],
    "TICKscript": "stream\n    // Select just the cpu_usage_idle measurement from our example database.\n\t\t.from().measurement('cpu_usage_idle')\n    .alert()\n        .crit(lambda: \"value\" \u003c  20)\n\t\t\t\t.log('/tmp/alerts.log')\n\n",
    "Dot": "digraph cpu_alert {\nstream0 -\u003e stream1;\nstream1 -\u003e alert2;\n}",
    "Enabled": true,
    "Error": ""
}

List

http://localhost:9092/api/v1/tasks

{
    "Tasks": [
        {
            "Name": "cpu_alert",
            "Type": 0,
            "DBRPs": [
                {
                    "db": "kapacitor_example",
                    "rp": "default"
                }
            ],
            "Enabled": true
        }
    ]
}

http://localhost:9092/api/v1/recordings

{
    "Recordings": [
        {
            "ID": "52925c3f-105e-4cbe-b958-de063dbe7dc6",
            "Type": 0,
            "Size": 1580,
            "Created": "2016-01-28T21:03:29Z"
        },
        {
            "ID": "8944ac7c-76ad-4329-ad9e-6cf00d1fd629",
            "Type": 0,
            "Size": 4520,
            "Created": "2016-01-30T13:21:22Z"
        },
        {
            "ID": "bb03d8f8-0946-4fb0-b0b5-bb2576aa4dca",
            "Type": 0,
            "Size": 2900,
            "Created": "2016-01-26T17:22:11Z"
        }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment