Skip to content

Commit

Permalink
Fixes #18781: Replace stats API by a prometheus endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset committed Dec 30, 2020
1 parent 634f1fb commit 652c78b
Show file tree
Hide file tree
Showing 22 changed files with 521 additions and 430 deletions.
1 change: 1 addition & 0 deletions relay/sources/api-doc/code_samples/curl/metrics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl http://localhost:3030/metrics
6 changes: 5 additions & 1 deletion relay/sources/api-doc/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ Download OpenAPI specification: [openapi.yml](openapi.yml)

Rudder relay exposes an internal API, enabling the agents and other services to interact with the relay.

A part of the API (everything but the `System` category) is exposed publicly on the relay
at `https://relay.example.com/rudder/relay-api/` (which is a reverse proxy of
`http://localhost:3030/rudder/relay-api/1/`).

## Authentication

The relay API is authentified on a case-by-case basis:
The relay API is authenticated on a case-by-case basis:

* *Remote run* is only accessible to requests from the IP of the relay's own policy server

Expand Down
24 changes: 12 additions & 12 deletions relay/sources/api-doc/openapi.src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ info:
name: "CC-BY-SA 2.0"
url: "https://spdx.org/licenses/CC-BY-SA-2.0.html"
servers:
- url: "http://localhost:3030/rudder/relay-api/1/"
- url: "http://localhost:3030"
description: "Local API"
- url: "https://rudder.example.local/rudder/relay-api/"
description: "Public API (does not include the `System` API)"
externalDocs:
description: Learn more about Rudder.
url: "https://docs.rudder.io"
Expand All @@ -34,21 +32,23 @@ tags:
- name: Remote run
description: Trigger agents runs
paths:
"/system/status":
"/rudder/relay-api/1/system/status":
$ref: paths/system/status.yml
"/system/info":
"/rudder/relay-api/1/system/info":
$ref: paths/system/info.yml
"/system/reload":
"/rudder/relay-api/1/system/reload":
$ref: paths/system/reload.yml
"/shared-folder/{path}":
"/rudder/relay-api/1/shared-folder/{path}":
$ref: paths/shared-folder.yml
"/shared-files/{targetNodeId}/{sourceNodeId}/{fileId}":
"/rudder/relay-api/1/shared-files/{targetNodeId}/{sourceNodeId}/{fileId}":
$ref: paths/shared-files.yml
"/policies/{nodeId}/rules/dsc/rudder.zip":
"/rudder/relay-api/1/policies/{nodeId}/rules/dsc/rudder.zip":
$ref: paths/policies.yml
"/remote-run/nodes/{nodeId}":
"/rudder/relay-api/1/remote-run/nodes/{nodeId}":
$ref: paths/remote-run/node.yml
"/remote-run/nodes":
"/rudder/relay-api/1/remote-run/nodes":
$ref: paths/remote-run/nodes.yml
"/remote-run/all":
"/rudder/relay-api/1/remote-run/all":
$ref: paths/remote-run/all.yml
"/metrics":
$ref: paths/metrics.yml
72 changes: 72 additions & 0 deletions relay/sources/api-doc/paths/metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# SPDX-License-Identifier: CC-BY-SA-2.0
# SPDX-FileCopyrightText: 2013-2020 Normation SAS
get:
summary: Get metrics
description: Get metrics in prometheus format. You need to configure prometheus to scrape `http://localhost:3030/metrics` on the relay.
operationId: getMetrics
responses:
"200":
description: Prometheus metrics
content:
text/plain:
schema:
type: string
format: Prometheus metrics
example: |
# HELP rudder_relayd_inventories_total Agent inventories
# TYPE rudder_relayd_inventories_total counter
rudder_relayd_inventories_total{status="forward_error"} 0
rudder_relayd_inventories_total{status="forward_ok"} 0
# HELP rudder_relayd_managed_nodes_total Managed Nodes
# TYPE rudder_relayd_managed_nodes_total gauge
rudder_relayd_managed_nodes_total 0
# HELP rudder_relayd_reports_processing_duration_seconds Reports processing
# TYPE rudder_relayd_reports_processing_duration_seconds histogram
rudder_relayd_reports_processing_duration_seconds_bucket{le="0.005"} 1
rudder_relayd_reports_processing_duration_seconds_bucket{le="0.01"} 1
rudder_relayd_reports_processing_duration_seconds_bucket{le="0.025"} 2
rudder_relayd_reports_processing_duration_seconds_bucket{le="0.05"} 3
rudder_relayd_reports_processing_duration_seconds_bucket{le="0.1"} 3
rudder_relayd_reports_processing_duration_seconds_bucket{le="0.25"} 3
rudder_relayd_reports_processing_duration_seconds_bucket{le="0.5"} 3
rudder_relayd_reports_processing_duration_seconds_bucket{le="1"} 3
rudder_relayd_reports_processing_duration_seconds_bucket{le="2.5"} 3
rudder_relayd_reports_processing_duration_seconds_bucket{le="5"} 3
rudder_relayd_reports_processing_duration_seconds_bucket{le="10"} 3
rudder_relayd_reports_processing_duration_seconds_bucket{le="+Inf"} 3
rudder_relayd_reports_processing_duration_seconds_sum 0.043532457999999996
rudder_relayd_reports_processing_duration_seconds_count 3
# HELP rudder_relayd_reports_total Agent run reports
# TYPE rudder_relayd_reports_total counter
rudder_relayd_reports_total{status="error"} 1
rudder_relayd_reports_total{status="forward_error"} 0
rudder_relayd_reports_total{status="forward_ok"} 0
rudder_relayd_reports_total{status="invalid"} 1
rudder_relayd_reports_total{status="ok"} 2
# HELP rudder_relayd_sub_nodes_total Nodes behind this policy server
# TYPE rudder_relayd_sub_nodes_total gauge
rudder_relayd_sub_nodes_total 0
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.12
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1024
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 27
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 29184000
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1609155927.83
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 1491361792
tags:
- System
x-code-samples:
- lang: curl
source:
$ref: ../code_samples/curl/metrics.sh

0 comments on commit 652c78b

Please sign in to comment.