Roberto Jiménez Sánchez 6638c09e30 Provisioning: Add job operation metrics (#120147)
* Provisioning: Add job metrics for warnings, file ops, and resource ops

Introduce three new Prometheus metrics to the provisioning jobs package:
- `grafana_provisioning_jobs_warnings` (histogram): distribution of warning
  counts per sync by action and reason
- `grafana_provisioning_jobs_file_operations_total` (counter): file operations
  by action, operation, and reason
- `grafana_provisioning_jobs_resource_operations_total` (counter): resource
  operations by action, operation, reason, group, and kind

Wire the warnings histogram into the pull job via the progress recorder's
new WarningCounts() method, which counts warnings per reason as they are
recorded. The sync worker emits the histogram after each sync using the
actual job action, keeping the metrics generic across job types.

Also add the FolderMetadataConflict error type and warning reason as
plumbing for future conflict detection.

Made-with: Cursor

* Provisioning: Move metrics to driver, add errors histogram, add tests

- Pass *JobMetrics through driver constructors instead of
  SetWarningRecorder on the interface, so every job gets warning/error
  recording automatically without workers opting in.
- Add grafana_provisioning_jobs_errors histogram to track resource error
  count distribution per job run.
- Update metric descriptions to be generic for all job types.
- Add unit tests for FolderMetadataConflict, NewFolderManifest, and
  MissingFolderMetadata error formatting.

Made-with: Cursor

* Provisioning: Switch resource warnings/errors to counters, add resource prefix

- Rename metrics to grafana_provisioning_jobs_resource_warnings_total
  and grafana_provisioning_jobs_resource_errors_total.
- Change from histograms to counters since distribution per job run
  is not needed right now.
- Rename fields and methods to include Resource prefix for clarity.

Made-with: Cursor

* Provisioning: Restore worker_test.go to main (no changes needed)

Made-with: Cursor

* Provisioning: Fix gofmt formatting

Made-with: Cursor

* Provisioning: Emit resource metrics per-Record, remove file_operations metric

Move metric emission from Complete() snapshots to per-Record() Inc() calls,
simplifying the recording API and removing the need for snapshot/nil-guard
logic. Also remove the unused file_operations_total metric and WarningCounts
method.

Made-with: Cursor

* Provisioning: Consolidate resource metrics into single counter

Replace four separate metrics (resource_success_total, resource_warnings_total,
resource_errors_total, resource_operations_total) with a single unified
grafana_provisioning_jobs_resource_operations_total counter using an outcome
label to distinguish success/warning/error.

Made-with: Cursor

* Provisioning: Add typed constants for resource operation and outcome

Move ResourceOutcome and ResourceOperation types from metrics.go to
job_resource_result.go alongside other result types. Add OperationReplaced
constant and fileActionToOperation helper for mapping FileAction values.

Made-with: Cursor

* Provisioning: Use typed JobAction in RecordResourceOperation signature

Accept provisioning.JobAction instead of string for the action parameter.
Add OperationReplaced constant. Use existing provisioning constants in tests.

Made-with: Cursor

* Provisioning: Revert warningCounts back to resultReasons set

With per-Record metric emission we no longer need counts per reason.
Restore the original resultReasons map[string]struct{} from main.

Made-with: Cursor

* Provisioning: Remove trailing newline in progress_test.go

Made-with: Cursor

* Provisioning: Simplify RecordResourceOperation to accept JobResourceResult

Move outcome/operation/reason derivation into RecordResourceOperation so
callers just pass the action and result. Remove emitMetrics helper and
inline the call. Add OperationRenamed constant.

Made-with: Cursor

* Provisioning: Rename OperationNoop to OperationIgnored

Made-with: Cursor
2026-03-12 12:56:36 +00:00
2026-03-06 10:27:09 +01:00
2026-03-06 10:27:09 +01:00
2025-10-29 17:17:07 +01:00
2025-03-04 11:00:35 +00:00
2025-08-20 10:08:03 +00:00

Grafana Logo (Light) Grafana Logo (Dark)

The open-source platform for monitoring and observability

License Go Report Card

Grafana allows you to query, visualize, alert on and understand your metrics no matter where they are stored. Create, explore, and share dashboards with your team and foster a data-driven culture:

  • Visualizations: Fast and flexible client side graphs with a multitude of options. Panel plugins offer many different ways to visualize metrics and logs.
  • Dynamic Dashboards: Create dynamic & reusable dashboards with template variables that appear as dropdowns at the top of the dashboard.
  • Explore Metrics: Explore your data through ad-hoc queries and dynamic drilldown. Split view and compare different time ranges, queries and data sources side by side.
  • Explore Logs: Experience the magic of switching from metrics to logs with preserved label filters. Quickly search through all your logs or streaming them live.
  • Alerting: Visually define alert rules for your most important metrics. Grafana will continuously evaluate and send notifications to systems like Slack, PagerDuty, VictorOps, OpsGenie.
  • Mixed Data Sources: Mix different data sources in the same graph! You can specify a data source on a per-query basis. This works for even custom datasources.

Get started

Unsure if Grafana is for you? Watch Grafana in action on play.grafana.org!

Documentation

The Grafana documentation is available at grafana.com/docs.

Contributing

If you're interested in contributing to the Grafana project:

Share your contributor experience in our feedback survey to help us improve.

Get involved

This project is tested with BrowserStack.

License

Grafana is distributed under AGPL-3.0-only. For Apache-2.0 exceptions, see LICENSING.md.

Description
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
Readme AGPL-3.0 2.8 GiB
Languages
TypeScript 52.5%
Go 44.9%
CUE 0.7%
Rich Text Format 0.4%
JavaScript 0.4%
Other 0.9%