Skip to content

feat(database_observability.mysql): Embed prometheus exporter within db-o11y component#5711

Merged
matthewnolf merged 5 commits into
mainfrom
mn/db-o11y-embed-mysql-exporter
Mar 11, 2026
Merged

feat(database_observability.mysql): Embed prometheus exporter within db-o11y component#5711
matthewnolf merged 5 commits into
mainfrom
mn/db-o11y-embed-mysql-exporter

Conversation

@matthewnolf
Copy link
Copy Markdown
Contributor

Brief description of Pull Request

Pull Request Details

This change enables the prometheus.exporter.mysql component to be embedded inside the database_observability.mysql component so that it encapsulates the functionality. This enables end users to create a single component, instead of multiple and wiring them up.

This also will aid our support for clustering mode in a future change.

If the mysql_exporter config block is provided, we create the exporter and attach it to the prometheus registry already used for database_observbaility_* metrics.

Example config:

database_observability.mysql "database" {
   data_source_name = "..."
   forward_to       = [loki.relabel.database.receiver]
   targets = []
   mysql_exporter {
    enable_collectors = ["perf_schema.eventsstatements", "perf_schema.eventswaits"]
   }
}

Issue(s) fixed by this Pull Request

Notes to the Reviewer

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

Comment thread internal/component/database_observability/mysql/component.go Outdated
Comment thread internal/component/database_observability/mysql/component.go Outdated
matthewnolf and others added 2 commits March 10, 2026 13:17
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cristiangreco cristiangreco changed the title feat: Database_observability - embed mysql exporter within db o11y component feat(database_observability.mysql): Embed prometheus exporter within db-o11y component Mar 10, 2026
… struct

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
*a = PrometheusExporterArguments(exporter_mysql.DefaultArguments)
}

func (a *PrometheusExporterArguments) Validate() error { return nil }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we call Validate() on the args here? Or maybe we could call it in the Validate() if this component itself? (line 206)

SlowLogFilter: exporterCfg.LogSlowFilter,
})
if err := c.registry.Register(exporter); err != nil {
return fmt.Errorf("failed to register mysqld_exporter collector: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("failed to register mysqld_exporter collector: %w", err)
return fmt.Errorf("failed to register prometheus_exporter collector: %w", err)

…d exporter

Delegate PrometheusExporterArguments.Validate() to the underlying
exporter_mysql.Arguments.Validate() instead of returning nil.

Rename error message to reference prometheus_exporter consistently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@matthewnolf matthewnolf merged commit 88bffb0 into main Mar 11, 2026
46 of 47 checks passed
@matthewnolf matthewnolf deleted the mn/db-o11y-embed-mysql-exporter branch March 11, 2026 14:55
cursor Bot pushed a commit that referenced this pull request Mar 16, 2026
…dded block

Add documentation for the new prometheus_exporter optional block introduced
in PR #5711, which allows embedding mysqld_exporter metrics collection directly
within the database_observability.mysql component.

- Add prometheus_exporter block and all its sub-blocks to the Blocks table
- Add prometheus_exporter section describing usage, attributes, and mutual
  exclusivity with the targets argument
- Add sub-sections for each nested block (heartbeat, info_schema.processlist,
  info_schema.tables, mysql.user, perf_schema.eventsstatements,
  perf_schema.file_instances, perf_schema.memory_events)
- Add a second example showing the embedded exporter pattern

Co-authored-by: Cristian Greco <cristian@regolo.cc>
cursor Bot pushed a commit that referenced this pull request Mar 16, 2026
…dded block

Add documentation for the new prometheus_exporter block introduced in
v1.15.0 (PR #5711), which allows embedding a MySQL Prometheus exporter
directly within database_observability.mysql without requiring a separate
prometheus.exporter.mysql component.

- Add prometheus_exporter block and its sub-blocks to the Blocks table
- Add prometheus_exporter section with argument and sub-block details
- Update the example to use the embedded prometheus_exporter pattern
- Note that prometheus_exporter and targets are mutually exclusive

Co-authored-by: Cristian Greco <cristian@regolo.cc>
matthewnolf added a commit that referenced this pull request Mar 25, 2026
…in db-o11y component (#5714)

<!--
  CONTRIBUTORS GUIDE:

https://github.com/grafana/alloy/blob/main/docs/developer/contributing.md

If this is your first PR or you have not contributed in a while, we
recommend
  taking the time to review the guide.

  **NOTE**
Your PR title must adhere to Conventional Commit style. For details on
this,
  check out the Contributors Guide linked above.
-->

### Brief description of Pull Request

<!--
Add a human-readable description of the PR that may be used as the
commit body
  (i.e. "Extended description") when it gets merged.
-->

### Pull Request Details
This change enables the `prometheus.exporter.postgres` component to be
embedded inside the `database_observability.postgres` component so that
it encapsulates the functionality. This enables end users to create a
single component, instead of multiple and wiring them up.

This also will aid our support for clustering mode in a future change.

If the `postgres_exporter` config block is provided, we create the
exporter and attach it to the prometheus registry already used for
`database_observbaility_*` metrics.

Example config:
```
database_observability.mysql "database" {
   data_source_name = "..."
   forward_to       = [loki.relabel.database.receiver]
   targets = []
   postgres_exporter {
    autodiscovery {
        database_denylist = ["rdsadmin"]
        enabled = true
      }
      enabled_collectors = ["database", "locks", "replication", "replication_slot", "stat_bgwriter", "stat_database", "stat_user_tables", "statio_user_tables", "wal", "long_running_transactions", "stat_statements"]
   }
}
```

Matches the functionality implemented for MySQL in
#5711
<!-- Add a more detailed descripion of the Pull Request here, if needed.
-->

### Issue(s) fixed by this Pull Request

<!--
Uncomment the following line and fill in an issue number if you want a
GitHub
  issue to be closed automatically when this PR gets merged.
-->

<!-- Fixes #issue_id -->

### Notes to the Reviewer

<!-- Add any relevant notes for the reviewers and testers of this PR.
-->

### PR Checklist

<!-- Remove items that do not apply. For completed items, change [ ] to
[x]. -->

- [ ] Documentation added
- [ ] Tests updated
- [ ] Config converters updated

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants