diff --git a/docs/changelog.md b/docs/changelog.md index 3e5eac7124..2bc6cf0ac3 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,11 @@ This changelog documents user-relevant changes to the GitHub runner charm. +## 2026-05-20 + +- Enhanced OpenTelemetry Collector configuration in the pre-job script to expose local OTLP (gRPC/HTTP) and Loki endpoints for workflow to push observability data. +- Enable system.cpu.logical.count and system.cpu.physical.count metrics. + ## 2026-04-24 - Exposed the configured GitHub path (org or repository) as a Terraform module output, allowing consumers to make decisions based on which path a runner is registered to. diff --git a/github-runner-manager/src/github_runner_manager/templates/pre-job.j2 b/github-runner-manager/src/github_runner_manager/templates/pre-job.j2 index c7d5f9b9be..38632743fd 100644 --- a/github-runner-manager/src/github_runner_manager/templates/pre-job.j2 +++ b/github-runner-manager/src/github_runner_manager/templates/pre-job.j2 @@ -144,29 +144,107 @@ receivers: collection_interval: 10s scrapers: cpu: + metrics: + system.cpu.logical.count: + enabled: true + system.cpu.physical.count: + enabled: true memory: disk: filesystem: network: load: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:44317 + http: + endpoint: 0.0.0.0:44318 + loki: + protocols: + http: + endpoint: 0.0.0.0:43100 + use_incoming_timestamp: true + filelog/aproxy: + include: + - /var/log/syslog + operators: + - type: filter + expr: 'body not matches "aproxy.aproxy"' processors: - attributes/github_labels: + attributes/self_hosted_runner_github_labels: actions: - - key: github_runner + - key: service.name action: upsert - value: "$RUNNER_NAME" - - key: github_workflow + value: "self-hosted-runner" + - key: github.repository action: upsert - value: "$GITHUB_WORKFLOW" - - key: github_job + value: "$GITHUB_REPOSITORY" + - key: github.runner action: upsert - value: "$GITHUB_JOB" - - key: github_repository + value: "$RUNNER_NAME" + - key: github.workflow action: upsert - value: "$GITHUB_REPOSITORY" + value: "$GITHUB_WORKFLOW" + - key: github.job + action: upsert + value: "$GITHUB_JOB" + - key: github.run.id + action: upsert + value: "$GITHUB_RUN_ID" + - key: github.run.attempt + action: upsert + value: "$GITHUB_RUN_ATTEMPT" + - key: host.arch + action: upsert + value: "$(uname -m)" + resource/self_hosted_runner_github_labels: + attributes: + - key: service.name + action: upsert + value: "self-hosted-runner" + - key: github.repository + action: upsert + value: "$GITHUB_REPOSITORY" + - key: github.runner + action: upsert + value: "$RUNNER_NAME" + - key: github.workflow + action: upsert + value: "$GITHUB_WORKFLOW" + - key: github.job + action: upsert + value: "$GITHUB_JOB" + - key: github.run.id + action: upsert + value: "$GITHUB_RUN_ID" + - key: github.run.attempt + action: upsert + value: "$GITHUB_RUN_ATTEMPT" + - key: host.arch + action: upsert + value: "$(uname -m)" + resource/self_hosted_runner_github_aproxy_labels: + attributes: + - key: service.name + action: upsert + value: "aproxy" + transform/self_hosted_runner_loki_labels: + log_statements: + - context: resource + statements: + - > + set(resource.attributes["loki.resource.labels"], + Concat([resource.attributes["loki.resource.labels"], + ", service.name, github.repository, github.runner, github.workflow, github.job, github.run.id, github.run.attempt, host.arch"], "")) + where resource.attributes["loki.resource.labels"] != nil + - > + set(resource.attributes["loki.resource.labels"], + "service.name, github.repository, github.runner, github.workflow, github.job, github.run.id, github.run.attempt, host.arch") + where resource.attributes["loki.resource.labels"] == nil batch: exporters: - otlp/mimir: + otlp/self_hosted_runner: endpoint: {{ otel_collector_endpoint }} tls: insecure: true @@ -174,8 +252,38 @@ service: pipelines: metrics: receivers: [hostmetrics] - processors: [attributes/github_labels, batch] - exporters: [otlp/mimir] + processors: [attributes/self_hosted_runner_github_labels, batch] + exporters: [otlp/self_hosted_runner] + metrics/otlp: + receivers: [otlp] + processors: [attributes/self_hosted_runner_github_labels, batch] + exporters: [otlp/self_hosted_runner] + logs/otlp: + receivers: [otlp] + processors: + - resource/self_hosted_runner_github_labels + - transform/self_hosted_runner_loki_labels + - batch + exporters: [otlp/self_hosted_runner] + logs/loki: + receivers: [loki] + processors: + - resource/self_hosted_runner_github_labels + - transform/self_hosted_runner_loki_labels + - batch + exporters: [otlp/self_hosted_runner] + logs/aproxy: + receivers: [filelog/aproxy] + processors: + - resource/self_hosted_runner_github_labels + - resource/self_hosted_runner_github_aproxy_labels + - transform/self_hosted_runner_loki_labels + - batch + exporters: [otlp/self_hosted_runner] + traces: + receivers: [otlp] + processors: [resource/self_hosted_runner_github_labels, batch] + exporters: [otlp/self_hosted_runner] EOF /usr/bin/sudo /usr/bin/snap enable opentelemetry-collector diff --git a/github-runner-manager/tests/unit/openstack_cloud/test_openstack_runner_manager.py b/github-runner-manager/tests/unit/openstack_cloud/test_openstack_runner_manager.py index 9f341b35b3..556903b328 100644 --- a/github-runner-manager/tests/unit/openstack_cloud/test_openstack_runner_manager.py +++ b/github-runner-manager/tests/unit/openstack_cloud/test_openstack_runner_manager.py @@ -197,7 +197,9 @@ def test_create_runner_without_aproxy( runner_manager.create_runner(identity, runner_context) openstack_cloud.launch_instance.assert_called_once() - assert "aproxy" not in openstack_cloud.launch_instance.call_args.kwargs["cloud_init"] + assert ( + "snap install aproxy" not in openstack_cloud.launch_instance.call_args.kwargs["cloud_init"] + ) def test_delete_vms(runner_manager: OpenStackRunnerManager): diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index e56fd149d3..0d0714de67 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -564,7 +564,7 @@ def image_builder_fixture( name=password_secret_name, content={"password": openstack_config.password}, ) - config = { + deploy_config = { **image_builder_config, "openstack-password-secret": str(password_secret_id), } @@ -572,7 +572,7 @@ def image_builder_fixture( "github-runner-image-builder", app=image_builder_app_name, channel="latest/edge", - config=config, + config=deploy_config, constraints={ "root-disk": "20480M", "mem": "2048M",