summaryrefslogtreecommitdiffstats
path: root/web/api
diff options
context:
space:
mode:
authorChris Akritidis <43294513+cakrit@users.noreply.github.com>2019-01-15 12:49:28 +0100
committerGitHub <noreply@github.com>2019-01-15 12:49:28 +0100
commit08649bec373555144878b4314e87c9a8eb38c82e (patch)
tree23c9246e606f948944af8bc33f976085fa455848 /web/api
parent67834f184ff3d67f6c8b6005ac68b568d7573118 (diff)
Port ACLs, Management API and Health commands (#4969)
##### Summary fixes #2673 fixes #2149 fixes #5017 fixes #3830 fixes #3187 fixes #5154 Implements a command API for health which will accept commands via a socket to selectively suppress health checks. Allows different ports to accept different request types (streaming, dashboard, api, registry, netdata.conf, badges, management) Removes support for multi-threaded and single-threaded web servers. ##### Component Name health, daemon
Diffstat (limited to 'web/api')
-rw-r--r--web/api/Makefile.am1
-rw-r--r--web/api/health/Makefile.am8
-rw-r--r--web/api/health/README.md129
-rw-r--r--web/api/health/health_cmdapi.c166
-rw-r--r--web/api/health/health_cmdapi.h31
-rw-r--r--web/api/netdata-swagger.json395
-rw-r--r--web/api/netdata-swagger.yaml271
-rw-r--r--web/api/web_api_v1.c66
-rw-r--r--web/api/web_api_v1.h4
9 files changed, 1063 insertions, 8 deletions
diff --git a/web/api/Makefile.am b/web/api/Makefile.am
index 5755612c8b..0f54817590 100644
--- a/web/api/Makefile.am
+++ b/web/api/Makefile.am
@@ -8,6 +8,7 @@ SUBDIRS = \
queries \
exporters \
formatters \
+ health \
$(NULL)
dist_noinst_DATA = \
diff --git a/web/api/health/Makefile.am b/web/api/health/Makefile.am
new file mode 100644
index 0000000000..19554bed8e
--- /dev/null
+++ b/web/api/health/Makefile.am
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+AUTOMAKE_OPTIONS = subdir-objects
+MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
+
+dist_noinst_DATA = \
+ README.md \
+ $(NULL)
diff --git a/web/api/health/README.md b/web/api/health/README.md
index cbe06c7f16..cbc8aaac4b 100644
--- a/web/api/health/README.md
+++ b/web/api/health/README.md
@@ -1,6 +1,8 @@
# Health API Calls
-## Enabled Alarms
+## Health Read API
+
+### Enabled Alarms
NetData enables alarms on demand, i.e. when the chart they should be linked to starts collecting data. So, although many more alarms are configured, only the useful ones are enabled.
@@ -8,13 +10,13 @@ To get the list of all enabled alarms:
`http://your.netdata.ip:19999/api/v1/alarms?all`
-## Raised Alarms
+### Raised Alarms
This API call will return the alarms currently in WARNING or CRITICAL state.
`http://your.netdata.ip:19999/api/v1/alarms`
-## Event Log
+### Event Log
The size of the alarm log is configured in `netdata.conf`. There are 2 settings: the rotation of the alarm log file and the in memory size of the alarm log.
@@ -28,17 +30,134 @@ The API call retrieves all entries of the alarm log:
`http://your.netdata.ip:19999/api/v1/alarm_log`
-## Alarm Log Incremental Updates
+### Alarm Log Incremental Updates
`http://your.netdata.ip:19999/api/v1/alarm_log?after=UNIQUEID`
The above returns all the events in the alarm log that occurred after UNIQUEID (you poll it once without `after=`, remember the last UNIQUEID of the returned set, which you give back to get incrementally the next events).
-## Alarm badges
+### Alarm badges
The following will return an SVG badge of the alarm named `NAME`, attached to the chart named `CHART`.
`http://your.netdata.ip:19999/api/v1/badge.svg?alarm=NAME&chart=CHART`
+## Health Management API
+
+Netdata v1.12 and beyond provides a command API to control health checks and notifications at runtime. The feature is especially useful for maintenance periods, during which you receive meaningless alarms.
+
+Specifically, the API allows you to:
+ - Disable health checks completely. Alarm conditions will not be evaluated at all and no entries will be added to the alarm log.
+ - Silence alarm notifications. Alarm conditions will be evaluated, the alarms will appear in the log and the netdata UI will show the alarms as active, but no notifications will be sent.
+ - Disable or Silence specific alarms that match selectors on alarm/template name, chart, context, host and family.
+
+The API is available by default, but it is protected by an `api authorization token` that is stored in the file you will see in the following entry of `http://localhost:19999/netdata.conf`:
+
+```bash
+[registry]
+ # netdata management api key file = /var/lib/netdata/netdata.api.key
+```
+
+You can access the API via GET requests, by adding the bearer token to an `Authorization` http header, like this:
+
+```
+curl "http://myserver/api/v1/manage/health?cmd=RESET" -H "Authorization: Bearer Mytoken"
+```
+
+The command `RESET` just returns netdata to the default operation, with all health checks and notifications enabled.
+If you've configured and entered your token correclty, you should see the plain text response `All health checks and notifications are enabled`.
+
+### Disable or silence all alarms
+
+If all you need is temporarily disable all health checks, then you issue the following before your maintenance period starts:
+```
+curl "http://myserver/api/v1/manage/health?cmd=DISABLE ALL" -H "Authorization: Bearer Mytoken"
+```
+The effect of disabling health checks is that the alarm criteria are not evaluated at all and nothing is written in the alarm log.
+If you want the health checks to be running but to not receive any notifications during your maintenance period, you can instead use this:
+
+```
+curl "http://myserver/api/v1/manage/health?cmd=SILENCE ALL" -H "Authorization: Bearer Mytoken"
+```
+
+Alarms may then still be raised and logged in netdata, so you'll be able to see them via the UI.
+
+Regardless of the option you choose, at the end of your maintenance period you revert to the normal state via the RESET command.
+
+```
+ curl "http://myserver/api/v1/manage/health?cmd=RESET" -H "Authorization: Bearer Mytoken"
+```
+
+### Disable or silence specific alarms
+
+If you do not wish to disable/silence all alarms, then the `DISABLE ALL` and `SILENCE ALL` commands can't be used.
+Instead, the following commands expect that one or more alarm selectors will be added, so that only alarms that match the selectors are disabled or silenced.
+- `DISABLE` : Set the mode to disable health checks.
+- `SILENCE` : Set the mode to silence notifications.
+
+You will normally put one of these commands in the same request with your first alarm selector, but it's possible to issue them separately as well.
+You will get a warning in the response, if a selector was added without a SILENCE/DISABLE command, or vice versa.
+
+Each request can specify a single alarm `selector`, with one or more `selection criteria`.
+A single alarm will match a `selector` if all selection criteria match the alarm.
+You can add as many selectors as you like.
+In essence, the rule is: IF (alarm matches all the criteria in selector1 OR all the criteria in selector2 OR ...) THEN apply the DISABLE or SILENCE command.
+
+To clear all selectors and reset the mode to default, use the `RESET` command.
+
+The following example silences notifications for all the alarms with context=load:
+
+```
+curl "http://myserver/api/v1/manage/health?cmd=SILENCE&context=load" -H "Authorization: Bearer Mytoken"
+```
+
+#### Selection criteria
+
+The `selection criteria` are key/value pairs, in the format `key : value`, where value is a netdata [simple pattern](../../../libnetdata/simple_pattern/). This means that you can create very powerful selectors (you will rarely need more than one or two).
+
+The accepted keys for the `selection criteria` are the following:
+- `alarm` : The expression provided will match both `alarm` and `template` names.
+- `chart` : Chart ids/names, as shown on the dashboard. These will match the `on` entry of a configured `alarm`.
+- `context` : Chart context, as shown on the dashboard. These will match the `on` entry of a configured `template`.
+- `hosts` : The hostnames that will need to match.
+- `families` : The alarm families.
+
+You can add any of the selection criteria you need on the request, to ensure that only the alarms you are interested in are matched and disabled/silenced. e.g. there is no reason to add `hosts: *`, if you want the criteria to be applied to alarms for all hosts.
+
+Example 1: Disable all health checks for context = `random`
+
+```
+http://localhost/api/v1/manage/health?cmd=DISABLE&context=random
+```
+
+Example 2: Silence all alarms and templates with name starting with `out_of` on host `myhost`
+
+```
+http://localhost/api/v1/manage/health?cmd=SILENCE&alarm=out_of*&hosts=myhost
+```
+
+Example 2.2: Add one more selector, to also silence alarms for cpu1 and cpu2
+
+```
+http://localhost/api/v1/manage/health?families=cpu1 cpu2
+```
+
+### Responses
+
+- "Auth Error" : Token authentication failed
+- "All alarm notifications are silenced" : Successful response to cmd=SILENCE ALL
+- "All health checks are disabled" : Successful response to cmd=DISABLE ALL
+- "All health checks and notifications are enabled" : Successful response to cmd=RESET
+- "Health checks disabled for alarms matching the selectors" : Added to the response for a cmd=DISABLE
+- "Alarm notifications silenced for alarms matching the selectors" : Added to the response for a cmd=SILENCE
+- "Alarm selector added" : Added to the response when a new selector is added
+- "Invalid key. Ignoring it." : Wrong name of a parameter. Added to the response and ignored.
+- "WARNING: Added alarm selector to silence/disable alarms without a SILENCE or DISABLE command." : Added to the response if a selector is added without a selector-specific command.
+- "WARNING: SILENCE or DISABLE command is ineffective without defining any alarm selectors." : Added to the response if a selector-specific command is issued without a selector.
+
+### Further reading
+
+The test script under [tests/health_mgmtapi](../../../tests/health_mgmtapi) contains a series of tests that you can either run or read through to understand the various calls and responses better.
+
[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fweb%2Fapi%2Fhealth%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
diff --git a/web/api/health/health_cmdapi.c b/web/api/health/health_cmdapi.c
new file mode 100644
index 0000000000..ec177751b9
--- /dev/null
+++ b/web/api/health/health_cmdapi.c
@@ -0,0 +1,166 @@
+//
+// Created by christopher on 11/12/18.
+//
+
+#include "health_cmdapi.h"
+
+
+static SILENCER *create_silencer(void) {
+ SILENCER *t = callocz(1, sizeof(SILENCER));
+ debug(D_HEALTH, "HEALTH command API: Created empty silencer");
+
+ return t;
+}
+
+void free_silencers(SILENCER *t) {
+ if (!t) return;
+ if (t->next) free_silencers(t->next);
+ debug(D_HEALTH, "HEALTH command API: Freeing silencer %s:%s:%s:%s:%s", t->alarms,
+ t->charts, t->contexts, t->hosts, t->families);
+ simple_pattern_free(t->alarms_pattern);
+ simple_pattern_free(t->charts_pattern);
+ simple_pattern_free(t->contexts_pattern);
+ simple_pattern_free(t->hosts_pattern);
+ simple_pattern_free(t->families_pattern);
+ freez(t->alarms);
+ freez(t->charts);
+ freez(t->contexts);
+ freez(t->hosts);
+ freez(t->families);
+ freez(t);
+ return;
+}
+
+
+
+int web_client_api_request_v1_mgmt_health(RRDHOST *host, struct web_client *w, char *url) {
+ int ret = 400;
+ (void) host;
+
+
+
+ BUFFER *wb = w->response.data;
+ buffer_flush(wb);
+ wb->contenttype = CT_TEXT_PLAIN;
+
+ buffer_flush(w->response.data);
+
+ static uint32_t
+ hash_alarm = 0,
+ hash_template = 0,
+ hash_chart = 0,
+ hash_context = 0,
+ hash_host = 0,
+ hash_families = 0;
+
+ if (unlikely(!hash_alarm)) {
+ hash_alarm = simple_uhash(HEALTH_ALARM_KEY);
+ hash_template = simple_uhash(HEALTH_TEMPLATE_KEY);
+ hash_chart = simple_uhash(HEALTH_CHART_KEY);
+ hash_context = simple_uhash(HEALTH_CONTEXT_KEY);
+ hash_host = simple_uhash(HEALTH_HOST_KEY);
+ hash_families = simple_uhash(HEALTH_FAMILIES_KEY);
+ }
+
+ SILENCER *silencer = NULL;
+
+ if (!w->auth_bearer_token) {
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_AUTHERROR);
+ ret = 403;
+ } else {
+ debug(D_HEALTH, "HEALTH command API: Comparing secret '%s' to '%s'", w->auth_bearer_token, api_secret);
+ if (strcmp(w->auth_bearer_token, api_secret)) {
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_AUTHERROR);
+ ret = 403;
+ } else {
+ while (url) {
+ char *value = mystrsep(&url, "&");
+ if (!value || !*value) continue;
+
+ char *key = mystrsep(&value, "=");
+ if (!key || !*key) continue;
+ if (!value || !*value) continue;
+
+ debug(D_WEB_CLIENT, "%llu: API v1 health query param '%s' with value '%s'", w->id, key, value);
+
+ // name and value are now the parameters
+ if (!strcmp(key, "cmd")) {
+ if (!strcmp(value, HEALTH_CMDAPI_CMD_SILENCEALL)) {
+ silencers->all_alarms = 1;
+ silencers->stype = STYPE_SILENCE_NOTIFICATIONS;
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_SILENCEALL);
+ } else if (!strcmp(value, HEALTH_CMDAPI_CMD_DISABLEALL)) {
+ silencers->all_alarms = 1;
+ silencers->stype = STYPE_DISABLE_ALARMS;
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_DISABLEALL);
+ } else if (!strcmp(value, HEALTH_CMDAPI_CMD_SILENCE)) {
+ silencers->stype = STYPE_SILENCE_NOTIFICATIONS;
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_SILENCE);
+ } else if (!strcmp(value, HEALTH_CMDAPI_CMD_DISABLE)) {
+ silencers->stype = STYPE_DISABLE_ALARMS;
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_DISABLE);
+ } else if (!strcmp(value, HEALTH_CMDAPI_CMD_RESET)) {
+ silencers->all_alarms = 0;
+ silencers->stype = STYPE_NONE;
+ free_silencers(silencers->silencers);
+ silencers->silencers = NULL;
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_RESET);
+ }
+ } else {
+ uint32_t hash = simple_uhash(key);
+ if (unlikely(silencer == NULL)) {
+ if (
+ (hash == hash_alarm && !strcasecmp(key, HEALTH_ALARM_KEY)) ||
+ (hash == hash_template && !strcasecmp(key, HEALTH_TEMPLATE_KEY)) ||
+ (hash == hash_chart && !strcasecmp(key, HEALTH_CHART_KEY)) ||
+ (hash == hash_context && !strcasecmp(key, HEALTH_CONTEXT_KEY)) ||
+ (hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) ||
+ (hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY))
+ ) {
+ silencer = create_silencer();
+ }
+ }
+
+ if (hash == hash_alarm && !strcasecmp(key, HEALTH_ALARM_KEY)) {
+ silencer->alarms = strdupz(value);
+ silencer->alarms_pattern = simple_pattern_create(silencer->alarms, NULL, SIMPLE_PATTERN_EXACT);
+ } else if (hash == hash_chart && !strcasecmp(key, HEALTH_CHART_KEY)) {
+ silencer->charts = strdupz(value);
+ silencer->charts_pattern = simple_pattern_create(silencer->charts, NULL, SIMPLE_PATTERN_EXACT);
+ } else if (hash == hash_context && !strcasecmp(key, HEALTH_CONTEXT_KEY)) {
+ silencer->contexts = strdupz(value);
+ silencer->contexts_pattern = simple_pattern_create(silencer->contexts, NULL, SIMPLE_PATTERN_EXACT);
+ } else if (hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) {
+ silencer->hosts = strdupz(value);
+ silencer->hosts_pattern = simple_pattern_create(silencer->hosts, NULL, SIMPLE_PATTERN_EXACT);
+ } else if (hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY)) {
+ silencer->families = strdupz(value);
+ silencer->families_pattern = simple_pattern_create(silencer->families, NULL, SIMPLE_PATTERN_EXACT);
+ } else {
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_INVALID_KEY);
+ }
+ }
+
+ }
+ if (likely(silencer)) {
+ // Add the created instance to the linked list in silencers
+ silencer->next = silencers->silencers;
+ silencers->silencers = silencer;
+ debug(D_HEALTH, "HEALTH command API: Added silencer %s:%s:%s:%s:%s", silencer->alarms,
+ silencer->charts, silencer->contexts, silencer->hosts, silencer->families
+ );
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_ADDED);
+ if (silencers->stype == STYPE_NONE) {
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_STYPEWARNING);
+ }
+ }
+ if (unlikely(silencers->stype != STYPE_NONE && !silencers->all_alarms && !silencers->silencers)) {
+ buffer_strcat(wb, HEALTH_CMDAPI_MSG_NOSELECTORWARNING);
+ }
+ ret = 200;
+ }
+ }
+ w->response.data = wb;
+ buffer_no_cacheable(w->response.data);
+ return ret;
+}
diff --git a/web/api/health/health_cmdapi.h b/web/api/health/health_cmdapi.h
new file mode 100644
index 0000000000..d0f30401c9
--- /dev/null
+++ b/web/api/health/health_cmdapi.h
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef NETDATA_WEB_HEALTH_SVG_H
+#define NETDATA_WEB_HEALTH_SVG_H 1
+
+#include "libnetdata/libnetdata.h"
+#include "web/server/web_client.h"
+#include "health/health.h"
+
+#define HEALTH_CMDAPI_CMD_SILENCEALL "SILENCE ALL"
+#define HEALTH_CMDAPI_CMD_DISABLEALL "DISABLE ALL"
+#define HEALTH_CMDAPI_CMD_SILENCE "SILENCE"
+#define HEALTH_CMDAPI_CMD_DISABLE "DISABLE"
+#define HEALTH_CMDAPI_CMD_RESET "RESET"
+
+#define HEALTH_CMDAPI_MSG_AUTHERROR "Auth Error\n"
+#define HEALTH_CMDAPI_MSG_SILENCEALL "All alarm notifications are silenced\n"
+#define HEALTH_CMDAPI_MSG_DISABLEALL "All health checks are disabled\n"
+#define HEALTH_CMDAPI_MSG_RESET "All health checks and notifications are enabled\n"
+#define HEALTH_CMDAPI_MSG_DISABLE "Health checks disabled for alarms matching the selectors\n"
+#define HEALTH_CMDAPI_MSG_SILENCE "Alarm notifications silenced for alarms matching the selectors\n"
+#define HEALTH_CMDAPI_MSG_ADDED "Alarm selector added\n"
+#define HEALTH_CMDAPI_MSG_INVALID_KEY "Invalid key. Ignoring it.\n"
+#define HEALTH_CMDAPI_MSG_STYPEWARNING "WARNING: Added alarm selector to silence/disable alarms without a SILENCE or DISABLE command.\n"
+#define HEALTH_CMDAPI_MSG_NOSELECTORWARNING "WARNING: SILENCE or DISABLE command is ineffective without defining any alarm selectors.\n"
+
+extern int web_client_api_request_v1_mgmt_health(RRDHOST *host, struct web_client *w, char *url);
+
+#include "web/api/web_api_v1.h"
+
+#endif /* NETDATA_WEB_HEALTH_SVG_H */
diff --git a/web/api/netdata-swagger.json b/web/api/netdata-swagger.json
index d709912c6f..ac84b754d6 100644
--- a/web/api/netdata-swagger.json
+++ b/web/api/netdata-swagger.json
@@ -545,6 +545,116 @@
}
}
}
+ },
+ "/alarms": {
+ "get": {
+ "summary": "Get a list of active or raised alarms on the server",
+ "description": "The alarms endpoint returns the list of all raised or enabled alarms on the netdata server. Called without any parameters, the raised alarms in state WARNING or CRITICAL are returned. By passing \"?all\", all the enabled alarms are returned.",
+ "parameters": [
+ {
+ "name": "all",
+ "in": "query",
+ "description": "If passed, all enabled alarms are returned",
+ "required": false,
+ "type": "boolean",
+ "allowEmptyValue": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "An object containing general info and a linked list of alarms",
+ "schema": {
+ "$ref": "#/definitions/alarms"
+ }
+ }
+ }
+ }
+ },
+ "/alarm_log": {
+ "get": {
+ "summary": "Retrieves the entries of the alarm log",
+ "description": "Returns an array of alarm_log entries, with historical information on raised and cleared alarms.",
+ "parameters": [
+ {
+ "name": "after",
+ "in": "query",
+ "description": "Passing the parameter after=UNIQUEID returns all the events in the alarm log that occurred after UNIQUEID. An automated series of calls would call the interface once without after=, store the last UNIQUEID of the returned set, and give it back to get incrementally the next events",
+ "required": false,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "An array of alarm log entries",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/alarm_log_entry"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/manage/health": {
+ "get": {
+ "summary": "Accesses the health management API to control health checks and notifications at runtime.",
+ "description": "Available from Netdata v1.12 and above, protected via bearer authorization. Especially useful for maintenance periods, the API allows you to disable health checks completely, silence alarm notifications, or Disable/Silence specific alarms that match selectors on alarm/template name, chart, context, host and family. For the simple disable/silence all scenaria, only the cmd parameter is required. The other parameters are used to define alarm selectors. For more information and examples, refer to the netdata documentation.",
+ "parameters": [
+ {
+ "name": "cmd",
+ "in": "query",
+ "description": "DISABLE ALL: No alarm criteria are evaluated, nothing is written in the alarm log. SILENCE ALL: No notifications are sent. RESET: Return to the default state. DISABLE/SILENCE: Set the mode to be used for the alarms matching the criteria of the alarm selectors.",
+ "required": false,
+ "type": "string",
+ "enum": [
+ "DISABLE ALL",
+ "SILENCE ALL",
+ "DISABLE",
+ "SILENCE",
+ "RESET"
+ ]
+ },
+ {
+ "name": "alarm",
+ "in": "query",
+ "description": "The expression provided will match both `alarm` and `template` names.",
+ "type": "string"
+ },
+ {
+ "name": "chart",
+ "in": "query",
+ "description": "Chart ids/names, as shown on the dashboard. These will match the `on` entry of a configured `alarm`",
+ "type": "string"
+ },
+ {
+ "name": "context",
+ "in": "query",
+ "description": "Chart context, as shown on the dashboard. These will match the `on` entry of a configured `template`.",
+ "type": "string"
+ },
+ {
+ "name": "hosts",
+ "in": "query",
+ "description": "The hostnames that will need to match.",
+ "type": "string"
+ },
+ {
+ "name": "families",
+ "in": "query",
+ "description": "The alarm families.",
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "A plain text response based on the result of the command"
+ },
+ "403": {
+ "description": "Bearer authentication error."
+ }
+ }
+ }
}
},
"definitions": {
@@ -830,6 +940,291 @@
"description": "The result requested, in the format requested."
}
}
+ },
+ "alarms": {
+ "type": "object",
+ "properties": {
+ "hostname": {
+ "type": "string"
+ },
+ "latest_alarm_log_unique_id": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "status": {
+ "type": "boolean"
+ },
+ "now": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "alarms": {
+ "type": "object",
+ "properties": {
+ "chart-name.alarm-name": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "name": {
+ "type": "string",
+ "description": "Full alarm name"
+ },
+ "chart": {
+ "type": "string"
+ },
+ "family": {
+ "type": "string"
+ },
+ "active": {
+ "type": "boolean",
+ "description": "Will be false only if the alarm is disabled in the configuration"
+ },
+ "disabled": {
+ "type": "boolean",
+ "description": "Whether the health check for this alarm has been disabled via a health command API DISABLE command."
+ },
+ "silenced": {
+ "type": "boolean",
+ "description": "Whether notifications for this alarm have been silenced via a health command API SILENCE command."
+ },
+ "exec": {
+ "type": "string"
+ },
+ "recipient": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ },
+ "units": {
+ "type": "string"
+ },
+ "info": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ },
+ "last_status_change": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "last_updated": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "next_update": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "update_every": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "delay_up_duration": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "delay_down_duration": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "delay_max_duration": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "delay_multiplier": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "delay": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "delay_up_to_timestamp": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "value_string": {
+ "type": "string"
+ },
+ "no_clear_notification": {
+ "type": "boolean"
+ },
+ "lookup_dimensions": {
+ "type": "string"
+ },
+ "db_after": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "db_before": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "lookup_method": {
+ "type": "string"
+ },
+ "lookup_after": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "lookup_before": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "lookup_options": {
+ "type": "string"
+ },
+ "calc": {
+ "type": "string"
+ },
+ "calc_parsed": {
+ "type": "string"
+ },
+ "warn": {
+ "type": "string"
+ },
+ "warn_parsed": {
+ "type": "string"
+ },
+ "crit": {
+ "type": "string"
+ },
+ "crit_parsed": {
+ "type": "string"
+ },
+ "green": {
+ "type": "string",
+ "format": "nullable"
+ },
+ "red": {
+ "type": "string",
+ "format": "nullable"
+ },
+ "value": {
+ "type": "number"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "alarm_log_entry": {
+ "type": "object",
+ "properties": {
+ "hostname": {
+ "type": "string"
+ },
+ "unique_id": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "alarm_id": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "alarm_event_id": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "name": {
+ "type": "string"
+ },
+ "chart": {
+ "type": "string"
+ },
+ "family": {
+ "type": "string"
+ },
+ "processed": {
+ "type": "boolean"
+ },
+ "updated": {
+ "type": "boolean"
+ },
+ "exec_run": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "exec_failed": {
+ "type": "boolean"
+ },
+ "exec": {
+ "type": "string"
+ },
+ "recipient": {
+ "type": "string"
+ },
+ "exec_code": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "source": {
+ "type": "string"
+ },
+ "units": {
+ "type": "string"
+ },
+ "when": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "duration": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "non_clear_duration": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "status": {
+ "type": "string"
+ },
+ "old_status": {
+ "type": "string"
+ },
+ "delay": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "delay_up_to_timestamp": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "updated_by_id": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "updates_id": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "value_string": {
+ "type": "string"
+ },
+ "old_value_string": {
+ "type": "string"
+ },
+ "silenced": {
+ "type": "string"
+ },
+ "info": {
+ "type": "string"
+ },
+ "value": {
+ "type": "string",
+ "format": "nullable"
+ },
+ "old_value": {
+ "type": "string",
+ "format": "nullable"
+ }
+ }
}
}
} \ No newline at end of file
diff --git a/web/api/netdata-swagger.yaml b/web/api/netdata-swagger.yaml
index fd84933b29..bf62fb95af 100644
--- a/web/api/netdata-swagger.yaml
+++ b/web/api/netdata-swagger.yaml
@@ -357,6 +357,75 @@ paths:
description: 'All the metrics returned in the format requested'
'400':
description: 'The format requested is not supported'
+ /alarms:
+ get:
+ summary: 'Get a list of active or raised alarms on the server'
+ description: 'The alarms endpoint returns the list of all raised or enabled alarms on the netdata server. Called without any parameters, the raised alarms in state WARNING or CRITICAL are returned. By passing "?all", all the enabled alarms are returned.'
+ parameters:
+ - name: all
+ in: query
+ description: 'If passed, all enabled alarms are returned'
+ required: false
+ type: boolean
+ allowEmptyValue: true
+ responses:
+ '200':
+ description: 'An object containing general info and a linked list of alarms'
+ schema:
+ $ref: '#/definitions/alarms'
+ /alarm_log:
+ get:
+ summary: 'Retrieves the entries of the alarm log'
+ description: 'Returns an array of alarm_log entries, with historical information on raised and cleared alarms.'