Skip to content
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

Avoid flapping metrics. #70

Merged
merged 17 commits into from
Oct 24, 2023
Merged

Avoid flapping metrics. #70

merged 17 commits into from
Oct 24, 2023

Conversation

woblerr
Copy link
Owner

@woblerr woblerr commented Oct 4, 2023

Some metrics might not have a value.

This can happen in the case of older pgBackRest versions or in the absence of some parameters when calling the pgBackRest command during backup. Previously, such metrics were missing. This leads to the disappearance of metrics on the dashboards.

It is much more reasonable to pass the default value than to handle the event of the absence metrics. It's necessary to avoid flapping time series.

This PR allows to create metrics with default values in the absence of the necessary information.

If value is absent, the following metrics will be set to 0:

  • pgbackrest_backup_annotations
  • pgbackrest_backup_databases
  • pgbackrest_backup_error_status
  • pgbackrest_backup_repo_size_bytes
  • pgbackrest_backup_repo_size_map_bytes
  • pgbackrest_backup_repo_delta_map_bytes
  • pgbackrest_backup_last_annotations
  • pgbackrest_backup_last_databases
  • pgbackrest_backup_last_error_status
  • pgbackrest_backup_last_repo_size_bytes
  • pgbackrest_backup_last_repo_size_map_bytes
  • pgbackrest_backup_last_repo_delta_map_bytes

The label block_incr was added to all *_backup_* and *_backup_last_* metrics with default value "n".

If information about LSN in backup is absent, the label values "-" are used for labels lsn_start and lsn_stop for pgbackrest_backup_info metric.

If information about repo is absent, the pgbackrest_repo_status metric will be set to 0 with labels repo_key="0" and cipher="none"

For metrics:
* pgbackrest_backup_repo_size_bytes
* pgbackrest_backup_repo_size_map_bytes
* pgbackrest_backup_repo_delta_map_bytes
* pgbackrest_backup_last_repo_size_bytes
* pgbackrest_backup_last_repo_size_map_bytes
* pgbackrest_backup_last_repo_delta_map_bytes

If value is absent, metric will be set to 0.
It's necessary to avoid flapping time series.

It is much more reasonable to pass the value 0 than to handle the event of the absence metrics. It's necessary to avoid flapping time series. This is especially important for *_last_* metrics.
For metrics:
* pgbackrest_backup_error_status
* pgbackrest_backup_annotations
* pgbackrest_backup_databases
* pgbackrest_backup_last_error_status
* pgbackrest_backup_last_annotations
* pgbackrest_backup_last_databases

If value is absent, metric will be set to 0.
It's necessary to avoid flapping time series.

Add label "block_incr" to all *_backup_* and *_backup_last_* metrics.
…cific backup.

This situation may occur on old pgBackRest versions or on some errors with pgBackRest.
Before pgBackRest v2.38 information about LSN in backup is absent. To avoid empty values for labels "lsn_start" and "lsn_stop" in "pgbackrest_backup_info" metric the label values "-" are used.
Update tests taking into account the default values for metrics.
Deleted unused mocks.

Add a custom function to compare the LastBackups structure.
reflect.deepEqual() is not suitable because the structure may contain nil values. Previously, some tests could work incorrectly.
@woblerr woblerr changed the title Add default value for _repo_*_bytes metrics when them are absent. Draft: Add default value for _repo_*_bytes metrics when them are absent. Oct 22, 2023
@woblerr woblerr changed the title Draft: Add default value for _repo_*_bytes metrics when them are absent. Add default value for _repo_*_bytes metrics when them are absent. Oct 22, 2023
@woblerr woblerr marked this pull request as draft October 22, 2023 13:33
For pgBackRest < v2.32 repo info is not available.
To avoid flapping this metric, set up the metric with value 0 (ok status) and the labels repo_key="0" and cipher="none".
@woblerr woblerr changed the title Add default value for _repo_*_bytes metrics when them are absent. Avoid flapping metrics. Oct 24, 2023
@woblerr woblerr marked this pull request as ready for review October 24, 2023 12:36
@woblerr woblerr merged commit f4c78dc into master Oct 24, 2023
@woblerr woblerr deleted the avoid_metric_flapping branch October 24, 2023 16:45
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.

1 participant