Skip to content

Commit

Permalink
chore: expose application and system metrics on the same port (#2039)
Browse files Browse the repository at this point in the history
* Expose application and system metrics on the same port

Signed-off-by: Jessica He <jhe@redhat.com>

* fix dead links in docs

Signed-off-by: Jessica He <jhe@redhat.com>

---------

Signed-off-by: Jessica He <jhe@redhat.com>
  • Loading branch information
JessicaJHee authored Dec 10, 2024
1 parent e00adfa commit e0c03b9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/dynamic-plugins/installing-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To install a dynamic plugin, you need to add the plugin definition to the `dynamic-plugin-config.yaml` file.

The placement of `dynamic-plugin-config.yaml` depends on the deployment method.
For more information, see [Installing Dynamic Plugins with the Red Hat Developer Hub Operator](https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.3/html/installing_and_viewing_dynamic_plugins/proc-config-dynamic-plugins-rhdh-operator_title-plugins-rhdh-about) or [Installing Dynamic Plugins Using the Helm Chart](https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.3/html/installing_and_viewing_dynamic_plugins/con-install-dynamic-plugin-helm_title-plugins-rhdh-about).
For more information, see [Installing Dynamic Plugins with the Red Hat Developer Hub Operator](https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.3/html/installing_and_viewing_dynamic_plugins/index#proc-config-dynamic-plugins-rhdh-operator_title-plugins-rhdh-about) or [Installing Dynamic Plugins Using the Helm Chart](https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.3/html/installing_and_viewing_dynamic_plugins/index#con-install-dynamic-plugin-helm_title-plugins-rhdh-about).

Plugins are defined in the `plugins` array in the `dynamic-plugin-config.yaml` file. Each plugin is defined as an object with the following properties:

Expand Down
4 changes: 1 addition & 3 deletions docs/monitoring-and-logging.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Setting up Metrics Monitoring and Logging for Backstage Showcase

The Backstage Showcase provides a `/metrics` endpoint on port `9464` (for application metrics) and `9463` (for host metrics) that provides OpenTelemetry metrics about your backstage application. This endpoint can be used to monitor your backstage instance using OpenTelemetry and Grafana.

**Note**: Due to a limitation, the host and application metrics are exposed on separate ports. This is to be improved by making all metrics accessible on the same port (9464) in a future release. This guide will ONLY work with the application metrics from NodeJs and Backstage.
The Backstage Showcase provides a `/metrics` endpoint on port `9464` that provides OpenTelemetry metrics about your backstage application. This endpoint can be used to monitor your backstage instance using OpenTelemetry and Grafana.

When deploying Backstage Showcase onto a kubernetes cluster with the [RHDH Helm chart](https://github.com/redhat-developer/rhdh-chart) or the [RHDH Operator](https://github.com/janus-idp/operator), monitoring and logging for your RHDH instance can be configured using the following steps.

Expand Down
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@internal/plugin-licensed-users-info-backend": "*",
"@internal/plugin-scalprum-backend": "*",
"@janus-idp/backstage-plugin-audit-log-node": "1.7.0",
"@opentelemetry/api": "1.9.0",
"@opentelemetry/auto-instrumentations-node": "0.50.2",
"@opentelemetry/exporter-prometheus": "0.53.0",
"@opentelemetry/host-metrics": "0.35.4",
Expand Down
15 changes: 6 additions & 9 deletions packages/backend/src/instrumentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const {
} = require('@opentelemetry/instrumentation-runtime-node');
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
const { HostMetrics } = require('@opentelemetry/host-metrics');
const { MeterProvider } = require('@opentelemetry/sdk-metrics');
const { metrics } = require('@opentelemetry/api');

// Application metrics will be exported to localhost:9464/metrics
const prometheusApplication = new PrometheusExporter();
// Metrics will be exported to localhost:9464/metrics
const prometheus = new PrometheusExporter();
const sdk = new NodeSDK({
metricReader: prometheusApplication,
metricReader: prometheus,
instrumentations: [
getNodeAutoInstrumentations(),
new RuntimeNodeInstrumentation(),
Expand All @@ -21,10 +21,7 @@ const sdk = new NodeSDK({

sdk.start();

// Host/process metrics will be exported to localhost:9463/metrics
const prometheusHost = new PrometheusExporter({ port: 9463 });
const meterProvider = new MeterProvider({
readers: [prometheusHost],
const hostMetrics = new HostMetrics({
meterProvider: metrics.getMeterProvider(),
});
const hostMetrics = new HostMetrics({ meterProvider });
hostMetrics.start();
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13940,7 +13940,7 @@ __metadata:
languageName: node
linkType: hard

"@opentelemetry/api@npm:^1.0.0, @opentelemetry/api@npm:^1.0.1, @opentelemetry/api@npm:^1.3.0, @opentelemetry/api@npm:^1.4.0":
"@opentelemetry/api@npm:1.9.0, @opentelemetry/api@npm:^1.0.0, @opentelemetry/api@npm:^1.0.1, @opentelemetry/api@npm:^1.3.0, @opentelemetry/api@npm:^1.4.0":
version: 1.9.0
resolution: "@opentelemetry/api@npm:1.9.0"
checksum: 9e88e59d53ced668f3daaecfd721071c5b85a67dd386f1c6f051d1be54375d850016c881f656ffbe9a03bedae85f7e89c2f2b635313f9c9b195ad033cdc31020
Expand Down Expand Up @@ -22391,6 +22391,7 @@ __metadata:
"@internal/plugin-licensed-users-info-backend": "*"
"@internal/plugin-scalprum-backend": "*"
"@janus-idp/backstage-plugin-audit-log-node": 1.7.0
"@opentelemetry/api": 1.9.0
"@opentelemetry/auto-instrumentations-node": 0.50.2
"@opentelemetry/exporter-prometheus": 0.53.0
"@opentelemetry/host-metrics": 0.35.4
Expand Down

0 comments on commit e0c03b9

Please sign in to comment.