Skip to content

Commit

Permalink
Metrics-ingest-delay bugfix
Browse files Browse the repository at this point in the history
Signed-off-by: eitah <eli@spantree.net>
  • Loading branch information
eitah committed Apr 7, 2022
1 parent 96baa4c commit 9cfdfb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ If you are still using the legacy [Access scopes][access-scopes], the `https://w
| `monitoring.filters` | No | | Formatted string to allow filtering on certain metrics type |
| `web.listen-address` | No | `:9255` | Address to listen on for web interface and telemetry |
| `web.telemetry-path` | No | `/metrics` | Path under which to expose Prometheus metrics |
| `monitoring.metrics-ingest-delay` | No | | Offsets metric collection by a delay appropriate for each metric type, e.g. because bigquery metrics are slow to appear |

### Metrics

Expand Down
14 changes: 12 additions & 2 deletions collectors/monitoring_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ func (c *MonitoringCollector) reportMonitoringMetrics(ch chan<- prometheus.Metri
metricDescriptor.Type)
}

if metricDescriptor.DisplayName == "Stored bytes" {
fmt.Printf("\n start pre \n %+v \n\n\n\n", startTime.Format(time.RFC3339Nano))
fmt.Printf("\n\n end pre \n %+v \n\n\n\n", endTime.Format(time.RFC3339Nano))
}

if c.metricsIngestDelay &&
metricDescriptor.Metadata != nil &&
metricDescriptor.Metadata.IngestDelay != "" {
Expand All @@ -277,10 +282,14 @@ func (c *MonitoringCollector) reportMonitoringMetrics(ch chan<- prometheus.Metri
return
}
level.Debug(c.logger).Log("msg", "adding ingest delay", "descriptor", metricDescriptor.Type, "delay", ingestDelay)
endTime.Add(ingestDelayDuration)
startTime.Add(ingestDelayDuration)
endTime = endTime.Add(ingestDelayDuration * -1)
startTime = startTime.Add(ingestDelayDuration * -1)
}

if metricDescriptor.DisplayName == "Stored bytes" {
fmt.Printf("\n start post \n %+v \n\n\n\n", startTime.Format(time.RFC3339Nano))
fmt.Printf("\n\n end post \n %+v \n\n\n\n", endTime.Format(time.RFC3339Nano))
}
for _, ef := range c.metricsFilters {
if strings.Contains(metricDescriptor.Type, ef.Prefix) {
filter = fmt.Sprintf("%s AND (%s)", filter, ef.Modifier)
Expand Down Expand Up @@ -356,6 +365,7 @@ func (c *MonitoringCollector) reportMonitoringMetrics(ch chan<- prometheus.Metri
}

func (c *MonitoringCollector) reportTimeSeriesMetrics(

page *monitoring.ListTimeSeriesResponse,
metricDescriptor *monitoring.MetricDescriptor,
ch chan<- prometheus.Metric,
Expand Down

0 comments on commit 9cfdfb7

Please sign in to comment.