...
Let’s create a CQ that collects everything usable from default mgmt_api_request
data. We can find the tag and field names with commands like SELECT * FROM mgmt_api_request LIMIT 1
.
...
breakoutMode | full-width |
---|
...
CREATE
...
CONTINUOUS
...
QUERY
...
"mgmt_api_requests_5min_for_1month"
...
ON
...
"oneportal"
...
BEGIN
...
SELECT
...
count(auth_header_exists)
...
AS
...
"count_requests",
...
sum("request_duration")
...
AS
...
"sum_request_duration",
...
mean("request_duration")
...
AS
...
"mean_request_duration"
...
INTO
...
"one_month"."mgmt_api_requests"
...
FROM
...
"mgmt_api_request"
...
GROUP
...
BY
...
time(5m),
...
"path",
...
"method",
...
"api_client_id",
...
"oauth2_client_id"
...
END
We could have created a CQ that collects only the number of requests and groups them by path, but in anticipation of other needs, we collect more data and more tags.
...
The graph now shows the expected correct values. You should change the Min interval to 5m
to match the CQ, and to visualise that the data covers a 5 minute period.
...
More CQ examples
Number of Management API requests that ended if error code (>= 400):
CREATE CONTINUOUS QUERY mgmt_api_request_errors_5min_for_1month ON oneportal BEGIN SELECT count(auth_header_exists) AS count_requests INTO oneportal.one_month.mgmt_api_request_errors FROM oneportal.one_day.mgmt_api_request WHERE response_code >= 400 GROUP BY time(5m), api_client_id, oauth2_client_id, path END
Number of Management API requests that ended in successful code (200 to 399):
CREATE CONTINUOUS QUERY mgmt_api_request_successes_5min_for_1month ON oneportal BEGIN SELECT count(auth_header_exists) AS count_requests INTO oneportal.one_month.mgmt_api_request_successes FROM oneportal.one_day.mgmt_api_request WHERE response_code >= 200 AND response_code < 400 GROUP BY time(5m), api_client_id, oauth2_client_id, path END
Number of OpenID API requests, similar to number of Management API requests in the above example:
CREATE CONTINUOUS QUERY "openid_api_requests_5min_for_1month" ON "oneportal" BEGIN SELECT count(auth_header_exists) AS "count_requests" INTO "one_month"."openid_api_requests" FROM "openid_api_request" GROUP BY time(5m), "path", "method" END
Number of log entries:
CREATE CONTINUOUS QUERY "log_entries_5min_for_1month" ON "oneportal" BEGIN SELECT count("event_id") AS "count_entries" INTO "one_month"."log_entries" FROM "log_entry" GROUP BY time(5m), "source" END