[
https://issues.apache.org/jira/browse/AIRFLOW-3177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16644015#comment-16644015
]
ASF GitHub Bot commented on AIRFLOW-3177:
-----------------------------------------
schnie opened a new pull request #4027: [AIRFLOW-3177] Change
scheduler_heartbeat from gauge to counter
URL: https://github.com/apache/incubator-airflow/pull/4027
Make sure you have checked _all_ steps below.
### Jira
- [x] My PR addresses the following [Airflow
Jira](https://issues.apache.org/jira/browse/AIRFLOW-3177) issues and references
them in the PR title.
### Description
- [x] Here are some details about my PR, including screenshots of any UI
changes:
Currently, the `scheduler_heartbeat` metric exposed with the statsd
integration is a gauge. I'm proposing to change the gauge to a counter for a
better integration with Prometheus via the
[statsd_exporter](https://github.com/prometheus/statsd_exporter.)
Rather than pointing Airflow at an actual statsd server, you can point it at
this exporter, which will accumulate the metrics and expose them to be scraped
by Prometheus at /metrics. The problem is that once this value is set when the
scheduler runs its first loop, it will always be exposed to Prometheus as 1.
The scheduler can crash, or be turned off and the statsd exporter will report a
1 until it is restarted and rebuilds its internal state.
By turning this metric into a counter, we can detect an issue with the
scheduler by graphing and alerting using a rate. If the rate of change of the
counter drops below what it should be at (determined by the
scheduler_heartbeat_secs setting), we can fire an alert.
This should be helpful for adoption in Kubernetes environments where
Prometheus is pretty much the standard.
### Tests
- [x] My PR adds the following unit tests __OR__ does not need testing for
this extremely good reason: No existing tests around statsd
### Commits
- [x] My commits all reference Jira issues in their subject lines, and I
have squashed multiple commits if they address the same issue. In addition, my
commits follow the guidelines from "[How to write a good git commit
message](http://chris.beams.io/posts/git-commit/)":
1. Subject is separated from body by a blank line
1. Subject is limited to 50 characters (not including Jira issue reference)
1. Subject does not end with a period
1. Subject uses the imperative mood ("add", not "adding")
1. Body wraps at 72 characters
1. Body explains "what" and "why", not "how"
### Documentation
- [x] In case of new functionality, my PR adds documentation that describes
how to use it.
- When adding new operators/hooks/sensors, the autoclass documentation
generation needs to be added.
### Code Quality
- [x] Passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Change scheduler_heartbeat metric from gauge to counter
> -------------------------------------------------------
>
> Key: AIRFLOW-3177
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3177
> Project: Apache Airflow
> Issue Type: Improvement
> Components: scheduler
> Reporter: Greg Neiheisel
> Assignee: Greg Neiheisel
> Priority: Minor
>
> Currently, the scheduler_heartbeat metric exposed with the statsd integration
> is a gauge. I'm proposing to change the gauge to a counter for a better
> integration with Prometheus via the
> [statsd_exporter|[https://github.com/prometheus/statsd_exporter].]
> Rather than pointing Airflow at an actual statsd server, you can point it at
> this exporter, which will accumulate the metrics and expose them to be
> scraped by Prometheus at /metrics. The problem is that once this value is set
> when the scheduler runs its first loop, it will always be exposed to
> Prometheus as 1. The scheduler can crash, or be turned off and the statsd
> exporter will report a 1 until it is restarted and rebuilds its internal
> state.
> By turning this metric into a counter, we can detect an issue with the
> scheduler by graphing and alerting using a rate. If the rate of change of the
> counter drops below what it should be at (determined by the
> scheduler_heartbeat_secs setting), we can fire an alert.
> This should be helpful for adoption in Kubernetes environments where
> Prometheus is pretty much the standard.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)