-
Notifications
You must be signed in to change notification settings - Fork 1
feat: enable log forwarding through otel collector #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ffd8772
feat: enable log forwarding through otel collector
florentianayuwono 14514f2
chore(deps): update dependency packaging to v26.1 (#180)
renovate[bot] 77f12cf
chore(deps): update dependency sphinx-ubuntu-images to v0.2.0 (#181)
renovate[bot] f41fd56
chore(deps): replace astral-sh/setup-uv action with astral-sh/setup-u…
renovate[bot] 11631ad
fix(deps): update module github.com/jackc/pgx/v5 to v5.9.2 (#183)
renovate[bot] b2cff4d
fix(dashboard): remove dead override hiding job queue time series (#184)
cbartz 564ff2c
chore: update Copilot collections to v0.11.0 (#172)
github-actions[bot] 7b44fd0
chore(docs): update contributing guidelines (charmkeeper) (#170)
erinecon 5961c47
Merge branch 'main' into feat/log-forwarding-isd-5146
florentianayuwono 1bdb99d
fix: run shell as bash
florentianayuwono 32eb82f
Update docs/how-to/enable-log-forwarding.md
florentianayuwono f7f4147
Apply suggestions from code review
florentianayuwono 0539529
fix docs
florentianayuwono 16a1ff7
add index
florentianayuwono 9934f4e
Update actions/enable-log-forwarding/enable-log-forwarding.py
florentianayuwono 8337420
Update actions/enable-log-forwarding/enable-log-forwarding.py
florentianayuwono 9590fd5
Merge branch 'main' into feat/log-forwarding-isd-5146
florentianayuwono 3f3fd59
address code reviews
florentianayuwono f15564a
add license
florentianayuwono bc2a1e4
fix docs
florentianayuwono 5016dcb
refactor code
florentianayuwono a920d9a
Apply suggestions from code review
florentianayuwono 356f39f
Merge branch 'main' into feat/log-forwarding-isd-5146
florentianayuwono dc8fd5a
address code reviews
florentianayuwono 9a3491d
remove pyyaml
florentianayuwono 39ae8fb
parameterized test
florentianayuwono File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| name: Enable Log Forwarding Action Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_call: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| detect-changes: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| action: ${{ steps.filter.outputs.action }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: dorny/paths-filter@v4 | ||
| id: filter | ||
| with: | ||
| filters: | | ||
| action: | ||
| - 'actions/enable-log-forwarding/**' | ||
| - '.github/workflows/enable_log_forwarding_action_tests.yaml' | ||
|
|
||
| test-action: | ||
| needs: detect-changes | ||
| if: ${{ needs.detect-changes.outputs.action == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v8.1.0 | ||
|
|
||
| - name: Install tox | ||
| run: uv tool install tox --with tox-uv | ||
|
|
||
| - name: Run lint, static checks, and unit tests | ||
| run: tox -e actions-lint,actions-static,actions-unit | ||
|
|
||
| smoke-test-self-hosted: | ||
| needs: detect-changes | ||
| if: ${{ needs.detect-changes.outputs.action == 'true' }} | ||
| runs-on: [self-hosted-linux-amd64-noble-edge] | ||
| env: | ||
| TEST_CONFIG_FILE: 91-enable-log-forwarding-smoke-${{ github.run_id }}-${{ github.run_attempt }}.yaml | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Run enable log forwarding action | ||
| uses: ./actions/enable-log-forwarding | ||
| with: | ||
| files: | | ||
| /var/log/syslog | ||
| config-file-name: ${{ env.TEST_CONFIG_FILE }} | ||
| otlp-endpoint: 127.0.0.1:4317 | ||
|
|
||
| - name: Verify generated config file exists | ||
| run: | | ||
| sudo test -f /etc/otelcol/config.d/${TEST_CONFIG_FILE} | ||
|
|
||
| - name: Verify generated config contains expected receiver | ||
| run: | | ||
| sudo grep -q '"filelog/github_runner_optin"' /etc/otelcol/config.d/${TEST_CONFIG_FILE} | ||
|
|
||
| smoke-test-github-hosted: | ||
| needs: detect-changes | ||
| if: ${{ needs.detect-changes.outputs.action == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Run enable log forwarding action on github-hosted runner | ||
| uses: ./actions/enable-log-forwarding | ||
| with: | ||
| files: | | ||
| /var/log/syslog | ||
|
|
||
| - name: Verify workflow continues after github-hosted no-op | ||
| run: | | ||
| echo "enable-log-forwarding exited successfully on github-hosted runner" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Copyright 2026 Canonical Ltd. | ||
| # See LICENSE file for licensing details. | ||
| name: Enable log forwarding | ||
| description: Opt in to forward selected log files from a self-hosted GitHub runner to Loki. | ||
|
|
||
| inputs: | ||
| files: | ||
| description: | | ||
| Newline or comma-separated list of file paths and glob patterns to forward. | ||
| Examples: | ||
| newline-separated: /var/log/syslog\n/var/log/kern.log | ||
| comma-separated: /var/log/syslog,/var/log/kern.log | ||
| glob: /var/log/chrony/*.log | ||
| required: true | ||
| otlp-endpoint: | ||
| description: | | ||
| Optional OTLP/gRPC endpoint for upstream OpenTelemetry Collector logs export. | ||
| When not set, the action falls back to ACTION_OTEL_EXPORTER_OTLP_ENDPOINT, | ||
| which is injected by Canonical self-hosted runners. | ||
| Example: otel-gateway.internal:4317 | ||
| required: false | ||
| default: "" | ||
| config-file-name: | ||
| description: | | ||
| File name for the generated collector fragment under /etc/otelcol/config.d. | ||
| Use this to control merge/load priority relative to other fragments. | ||
| required: false | ||
| default: 90-github-runner-log-forwarding.yaml | ||
|
yanksyoon marked this conversation as resolved.
|
||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Configure collector for opt-in file log forwarding | ||
| shell: bash | ||
| env: | ||
| INPUT_FILES: ${{ inputs.files }} | ||
| INPUT_OTLP_ENDPOINT: ${{ inputs.otlp-endpoint }} | ||
| INPUT_CONFIG_FILE_NAME: ${{ inputs.config-file-name }} | ||
| run: python3 "${{ github.action_path }}/enable_log_forwarding.py" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.