|
11 | 11 | from collectors.starkware import starkware_collector |
12 | 12 | from settings import logger, cfg |
13 | 13 | from metrics_processor import results |
14 | | -from settings import logger |
| 14 | +from settings import logger, cfg |
15 | 15 |
|
16 | 16 |
|
17 | 17 | class prom_registry(object): |
@@ -84,6 +84,9 @@ def _instantiate_starkware(self): |
84 | 84 | self.collectors.append(starkware_collector(item)) |
85 | 85 | self.labels = self.collectors[0].labels |
86 | 86 |
|
| 87 | + def _report_exporter_health(self, health_metric): |
| 88 | + health_metric.add_metric([cfg.blockchain], True) |
| 89 | + |
87 | 90 | def collect(self): |
88 | 91 | metrics = { |
89 | 92 | "brpc_health": |
@@ -143,6 +146,14 @@ def collect_metrics(prom_collector): |
143 | 146 | # Only yield metric if samples were provided by the probe |
144 | 147 | if len(metric.samples) > 0: |
145 | 148 | yield metric |
| 149 | + # The last step is to report exporter health |
| 150 | + # This metric will be used to monitor if exporter is alive and forwarding metrics to prometheus endpoints. |
| 151 | + exporter_health_metric = GaugeMetricFamily( |
| 152 | + 'brpc_exporter_health', |
| 153 | + 'Returns 1 if exporter was able to finalise scraping loop without exceptions.', |
| 154 | + labels=['blockchain']) |
| 155 | + self._report_exporter_health(exporter_health_metric) |
| 156 | + yield exporter_health_metric |
146 | 157 |
|
147 | 158 |
|
148 | 159 | def dummy_report(environ, start_fn): |
|
0 commit comments