Skip to content

Split OTel Collector config into separate Mattermost and PostgreSQL files#8866

Merged
esethna merged 5 commits intomattermost:masterfrom
sadohert:stu-split-otel-collector-config
Apr 17, 2026
Merged

Split OTel Collector config into separate Mattermost and PostgreSQL files#8866
esethna merged 5 commits intomattermost:masterfrom
sadohert:stu-split-otel-collector-config

Conversation

@sadohert
Copy link
Copy Markdown
Contributor

@sadohert sadohert commented Apr 8, 2026

Summary

  • Splits the combined otel-collector-config.yaml into two separate files: otel-collector-config-mattermost.yaml and otel-collector-config-postgres.yaml
  • Step 3 (Install OTel Collector) now references the Mattermost-specific config as the primary download
  • The Optional PostgreSQL section now has a distinct callout with its own download link for the PostgreSQL config
  • Removes the PostgreSQL group permission command from Step 3 (now belongs in the optional section)

Motivation: The combined config caused confusion during customer engagements — users setting up Mattermost log collection were confused by Postgres configuration they didn't need, and vice versa.

Test plan

  • Verify both YAML download links resolve correctly on the rendered docs page
  • Confirm Step 3 flow reads cleanly for a Mattermost-only deployment
  • Confirm the Optional PostgreSQL callout is clearly separated and self-contained

🤖 Generated with Claude Code

…iles

The combined otel-collector-config.yaml mixed Mattermost and PostgreSQL
log collection, which caused confusion during customer engagements. Split
into otel-collector-config-mattermost.yaml (primary, referenced in Step 3)
and otel-collector-config-postgres.yaml (referenced in a distinct callout
in the Optional PostgreSQL section).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mattermost-build
Copy link
Copy Markdown
Contributor

Hello @sadohert,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3002ce19-7a9a-492c-947c-309a1f5017f1

📥 Commits

Reviewing files that changed from the base of the PR and between 9544dc2 and 0471f82.

📒 Files selected for processing (1)
  • source/samples/loki/otel-collector-config-mattermost.yaml
✅ Files skipped from review due to trivial changes (1)
  • source/samples/loki/otel-collector-config-mattermost.yaml

📝 Walkthrough

Walkthrough

Updated logging docs to reference Mattermost- and PostgreSQL-specific OpenTelemetry Collector configs and added two new collector configuration files for Mattermost and PostgreSQL log collection, mapping severities and exporting logs to Loki via OTLP/HTTP.

Changes

Cohort / File(s) Summary
Documentation
source/administration-guide/scale/deploy-grafana-loki-for-centralized-logging.rst
Directed users to download otel-collector-config-mattermost.yaml (instead of generic config); removed instruction to add collector to postgres group; replaced inline PostgreSQL guidance with reference to a dedicated PostgreSQL config and updated LogQL example formatting.
Collector configs
source/samples/loki/otel-collector-config-mattermost.yaml, source/samples/loki/otel-collector-config-postgres.yaml
Added two OTEL Collector configs: Mattermost filelog receiver reading /opt/mattermost/logs/mattermost.log with JSON parsing and severity mapping; PostgreSQL filelog receiver reading /var/log/postgresql/*.json with error_severity→severity number mapping; both include resource, transform, batch processors and otlp_http exporter to Loki.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant FS as File system (logs)
  participant Collector as OpenTelemetry Collector
  participant Loki as Loki (OTLP/HTTP)
  rect rgba(210,230,255,0.5)
    FS->>Collector: Tail JSON logs (mattermost.log or /var/log/postgresql/*.json)
    Collector->>Collector: Parse JSON, upsert resource attrs
    Collector->>Collector: Map severity -> log.severity_number
    Collector->>Collector: Batch logs
    Collector->>Loki: Export via OTLP/HTTP to /otlp
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: splitting a combined OTel Collector configuration file into two separate Mattermost and PostgreSQL configuration files.
Description check ✅ Passed The description clearly relates to the changeset by explaining the motivation for splitting configs, documenting the new files created, and outlining the structural changes to the deployment guide.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@source/administration-guide/scale/deploy-grafana-loki-for-centralized-logging.rst`:
- Around line 355-360: Clarify that when reusing Step 3 for installing the
OpenTelemetry Collector for PostgreSQL, readers should follow the generic
installation steps only and skip Mattermost-specific access/permission commands
found in Step 3; update the paragraph referencing
otel-collector-config-postgres.yaml to explicitly state “follow Step 3 except do
NOT run Mattermost-specific user/group or chown/chmod commands (those are Lines
under ‘Step 3’ for Mattermost access)” and instead run the standard collector
install and service setup as appropriate for a PostgreSQL host, and remind
readers to still replace the <LOKI_HOST>, <HOSTNAME>, and <SERVICE_NAME>
placeholders.

In `@source/samples/loki/otel-collector-config-mattermost.yaml`:
- Around line 4-6: The filelog/mattermost receiver is not parsing JSON so
log.attributes["level"] is nil and the transform/severity processor's conditions
fail; add a json_parser operator to the pipeline for the filelog/mattermost
receiver (before the transform/severity processor) that parses the incoming log
payload (e.g., body/message) into attributes and extracts the "level" field into
attributes["level"] so the transform/severity rules can map severity correctly;
locate the filelog/mattermost receiver block and insert a json_parser operator
configured to parse the JSON message into attributes and set attributes.level
(or attributes["level"]) as the target attribute.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7436a707-611e-4696-bbe6-487de9648c6d

📥 Commits

Reviewing files that changed from the base of the PR and between dbe1e0d and 9544dc2.

📒 Files selected for processing (3)
  • source/administration-guide/scale/deploy-grafana-loki-for-centralized-logging.rst
  • source/samples/loki/otel-collector-config-mattermost.yaml
  • source/samples/loki/otel-collector-config-postgres.yaml

Comment thread source/samples/loki/otel-collector-config-mattermost.yaml
Without json_parser, Mattermost's JSON log fields (including "level") are
never extracted into log.attributes, causing the transform/severity processor
to silently fail — all logs arrive in Loki without severity information.

This bug was present in the original combined config and carried over into
the split Mattermost-specific file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sadohert
Copy link
Copy Markdown
Contributor Author

sadohert commented Apr 8, 2026

@kwiersgalla can you help with adding reviewers to this PR? This was feedback that came out of a customer PS engagement.

Copy link
Copy Markdown
Contributor

@esethna esethna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sadohert this looks file from an editor perspective. Do we need dev review here or have these config files been validated?

@sadohert
Copy link
Copy Markdown
Contributor Author

I've validated in my own lab setups. I think someone else might need a bit of setup time to validate this. I would say risks if there are errors is low so I'd merge.

@esethna esethna merged commit affe7fd into mattermost:master Apr 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants