RobustPerception / azure_metrics_exporter

Azure metrics exporter for Prometheus
Apache License 2.0
133 stars 70 forks source link

Exporter exiting when no data is returned from a metric definition available #35

Closed mariobede closed 5 years ago

mariobede commented 5 years ago

Exporter exiting when no data exists for one metric.

panic: runtime error: index out of range

goroutine 16 [running]:
panic(0x3d3640, 0xc42000a0f0)
    /usr/local/Cellar/go/1.7.5/libexec/src/runtime/panic.go:500 +0x1a1
main.(*Collector).Collect(0x678d90, 0xc420327500)
    /usr/local/Cellar/go/1.7.5/bin/src/github.com/RobustPerception/azure_metrics_exporter/main.go:71 +0xd97
github.com/RobustPerception/azure_metrics_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func2(0xc420396ad0, 0xc420327500, 0x63b720, 0x678d90)
    /usr/local/Cellar/go/1.7.5/bin/src/github.com/RobustPerception/azure_metrics_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:383 +0x63
created by github.com/RobustPerception/azure_metrics_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather
    /usr/local/Cellar/go/1.7.5/bin/src/github.com/RobustPerception/azure_metrics_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:384 +0x326

Config:

  - resource: "/resourceGroups/xXXXX-rg/providers/Microsoft.ServiceBus/namespaces/XXXX"
    metrics:
      - name: "SuccessfulRequests"
      - name: "ServerErrors"
      - name: "UserErrors"
      - name: "IncomingRequests"
      - name: "IncomingMessages"
      - name: "OutgoingMessages"
      - name: "ActiveConnections"
      - name: "Size"
      - name: "Messages"
      - name: "ActiveMessages"
      - name: "DeadletteredMessages"
      - name: "ScheduledMessages"
      - name: "ThrottledRequests"

ThrottledRequests -> This is the guilty guy. If configured only on its own or removed from the list. there is no failure.


2018/11/12 12:55:14 Resource: XXXXX

Available Metrics:
2018/11/12 12:55:14 - SuccessfulRequests
2018/11/12 12:55:14 - ServerErrors
2018/11/12 12:55:14 - UserErrors
2018/11/12 12:55:14 - ThrottledRequests
2018/11/12 12:55:14 - IncomingRequests
2018/11/12 12:55:14 - IncomingMessages
2018/11/12 12:55:14 - OutgoingMessages
2018/11/12 12:55:14 - ActiveConnections
2018/11/12 12:55:14 - Size
2018/11/12 12:55:14 - Messages
2018/11/12 12:55:14 - ActiveMessages
2018/11/12 12:55:14 - DeadletteredMessages
2018/11/12 12:55:14 - ScheduledMessages```
brian-brazil commented 5 years ago

Looks like we should do a check before here: https://github.com/RobustPerception/azure_metrics_exporter/blob/72c78b4aeb8f803026a924d1a112da765b3c09c5/main.go#L71

mariobede commented 5 years ago

i'm tempted to give it a "go" but my lack of knowledge might difficult t.

brian-brazil commented 5 years ago

len(value.Timeseries) > 0 is the main bit you need.

mariobede commented 5 years ago

👍 will take a peak.