Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ffd8772
feat: enable log forwarding through otel collector
florentianayuwono Apr 22, 2026
14514f2
chore(deps): update dependency packaging to v26.1 (#180)
renovate[bot] Apr 18, 2026
77f12cf
chore(deps): update dependency sphinx-ubuntu-images to v0.2.0 (#181)
renovate[bot] Apr 18, 2026
f41fd56
chore(deps): replace astral-sh/setup-uv action with astral-sh/setup-u…
renovate[bot] Apr 19, 2026
11631ad
fix(deps): update module github.com/jackc/pgx/v5 to v5.9.2 (#183)
renovate[bot] Apr 19, 2026
b2cff4d
fix(dashboard): remove dead override hiding job queue time series (#184)
cbartz Apr 22, 2026
564ff2c
chore: update Copilot collections to v0.11.0 (#172)
github-actions[bot] Apr 22, 2026
7b44fd0
chore(docs): update contributing guidelines (charmkeeper) (#170)
erinecon Apr 22, 2026
5961c47
Merge branch 'main' into feat/log-forwarding-isd-5146
florentianayuwono Apr 22, 2026
1bdb99d
fix: run shell as bash
florentianayuwono Apr 22, 2026
32eb82f
Update docs/how-to/enable-log-forwarding.md
florentianayuwono Apr 23, 2026
f7f4147
Apply suggestions from code review
florentianayuwono Apr 23, 2026
0539529
fix docs
florentianayuwono Apr 23, 2026
16a1ff7
add index
florentianayuwono Apr 23, 2026
9934f4e
Update actions/enable-log-forwarding/enable-log-forwarding.py
florentianayuwono Apr 23, 2026
8337420
Update actions/enable-log-forwarding/enable-log-forwarding.py
florentianayuwono Apr 23, 2026
9590fd5
Merge branch 'main' into feat/log-forwarding-isd-5146
florentianayuwono Apr 23, 2026
3f3fd59
address code reviews
florentianayuwono Apr 23, 2026
f15564a
add license
florentianayuwono Apr 23, 2026
bc2a1e4
fix docs
florentianayuwono Apr 24, 2026
5016dcb
refactor code
florentianayuwono Apr 24, 2026
a920d9a
Apply suggestions from code review
florentianayuwono Apr 27, 2026
356f39f
Merge branch 'main' into feat/log-forwarding-isd-5146
florentianayuwono Apr 29, 2026
dc8fd5a
address code reviews
florentianayuwono Apr 29, 2026
9a3491d
remove pyyaml
florentianayuwono Apr 29, 2026
39ae8fb
parameterized test
florentianayuwono Apr 29, 2026
a0888ab
fix: use otlp exporter type instead of otlp_grpc
florentianayuwono Apr 30, 2026
28090db
chore: merge origin/main and resolve conflicts
florentianayuwono Apr 30, 2026
da087c6
fix: add tls insecure to generated otlp exporter config
florentianayuwono Apr 30, 2026
1318773
Fix logging action
weiiwang01 Apr 30, 2026
89a43b5
style: fix black formatting and missing final newline
florentianayuwono Apr 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/enable_log_forwarding_action_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,22 @@ jobs:
runs-on: [self-hosted-linux-amd64-noble-edge]
env:
TEST_CONFIG_FILE: 91-enable-log-forwarding-smoke-${{ github.run_id }}-${{ github.run_attempt }}.yaml
TEST_LOG_FILE: /var/log/enable-log-forwarding-smoke-${{ github.run_id }}.log
steps:
- uses: actions/checkout@v6

- name: Run enable log forwarding action
uses: ./actions/enable-log-forwarding
with:
files: |
/var/log/syslog
files: ${{ env.TEST_LOG_FILE }}
config-file-name: ${{ env.TEST_CONFIG_FILE }}
otlp-endpoint: 127.0.0.1:4317

- name: Populate log file to forward
run: |
for i in {1..5}; do
echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) INFO enable-log-forwarding smoke test: entry $i run_id=${{ github.run_id }}" | sudo tee -a ${TEST_LOG_FILE}
sleep 2
done

- name: Verify generated config file exists
run: |
Expand Down
45 changes: 42 additions & 3 deletions actions/enable-log-forwarding/enable_log_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@
from typing import Sequence

CONFIG_DIR = "/etc/otelcol/config.d"
EXPORTER_NAME = "otlp_grpc"
EXPORTER_NAME = "otlp/github_runner_optin"
BATCH_PROCESSOR_NAME = "batch/github_runner_optin"
SERVICE_NAME = "self-hosted-runner"
LOKI_RESOURCE_LABELS = (
"service.name",
"github.repository",
"github.runner",
"github.workflow",
"github.job",
"github.run.id",
"github.run.attempt",
)
LOKI_ATTRIBUTE_LABELS = (
"log.file.name",
"log.file.path",
)
SNAP_CMD = Path("/usr/bin/snap")
SUDO_CMD = Path("/usr/bin/sudo")
MKDIR_CMD = Path("/usr/bin/mkdir")
Expand Down Expand Up @@ -174,16 +189,29 @@ def exporter_exists_in_config_dir(
def build_resource_attributes() -> list[dict[str, str]]:
"""Build static GitHub resource attributes attached to forwarded logs."""
attrs = [
("service.name", SERVICE_NAME),
("github.repository", os.getenv("GITHUB_REPOSITORY", "unknown")),
("github.runner", os.getenv("RUNNER_NAME", "unknown")),
("github.workflow", os.getenv("GITHUB_WORKFLOW", "unknown")),
("github.job", os.getenv("GITHUB_JOB", "unknown")),
("github.run.id", os.getenv("GITHUB_RUN_ID", "unknown")),
("github.run.attempt", os.getenv("GITHUB_RUN_ATTEMPT", "unknown")),
("loki.resource.labels", ", ".join(LOKI_RESOURCE_LABELS)),
]
return [{"key": key, "value": value, "action": "upsert"} for key, value in attrs]


def build_log_attribute_actions() -> list[dict[str, str]]:
"""Build log-attribute actions for Loki label promotion hints."""
return [
{
"key": "loki.attribute.labels",
"value": ", ".join(LOKI_ATTRIBUTE_LABELS),
"action": "upsert",
}
]


def build_config(
files: Sequence[str],
resolved_endpoint: str,
Expand All @@ -196,18 +224,28 @@ def build_config(
"filelog/github_runner_optin": {
"include": list(files),
"start_at": "end",
"include_file_name": True,
"include_file_path": True,
}
},
"processors": {
"resource/github_runner_optin": {
"attributes": build_resource_attributes(),
}
},
"attributes/github_runner_optin": {
"actions": build_log_attribute_actions(),
},
BATCH_PROCESSOR_NAME: {},
},
"service": {
"pipelines": {
"logs/github_runner_optin": {
"receivers": ["filelog/github_runner_optin"],
"processors": ["resource/github_runner_optin", "batch"],
"processors": [
"resource/github_runner_optin",
"attributes/github_runner_optin",
BATCH_PROCESSOR_NAME,
],
"exporters": [exporter_name],
}
}
Expand All @@ -217,6 +255,7 @@ def build_config(
config["exporters"] = {
exporter_name: {
"endpoint": resolved_endpoint,
"tls": {"insecure": True},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def test_build_config_exporter_block_is_conditionally_defined(
assert ("exporters" in config) is has_exporters_block
if has_exporters_block:
assert config["exporters"][module.EXPORTER_NAME]["endpoint"] == "otel:4318"
assert config["exporters"][module.EXPORTER_NAME]["tls"] == {"insecure": True}


@pytest.mark.parametrize(
Expand Down
Loading