prometheus: Azure SD with Public IP Address: panic: runtime error: invalid memory address or nil pointer dereference
Version
Docker image prom/prometheus
, tags latest
and main
, both have the same problem.
Problem
We’re receiving a panic from Azure SD plugin whenever it tries to enumerate our VMs. The problem is caused by an incorrect nil check as seen below:
Fix
The current code is checking ip.PublicIPAddress.PublicIPAddressPropertiesFormat
but is dereferencing ip.PublicIPAddress.IPAddress
. We should nil check ip.PublicIPAddress.IPAddress
instead.
Stacktrace
Feb 08 17:14:17 prometheus docker[8302]: panic: runtime error: invalid memory address or nil pointer dereference
Feb 08 17:14:17 prometheus docker[8302]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xeb0ac1]
Feb 08 17:14:17 prometheus docker[8302]: goroutine 776 [running]:
Feb 08 17:14:17 prometheus docker[8302]: github.com/prometheus/prometheus/discovery/azure.(*Discovery).refresh.func1(0xd9bebd0f7c815613, {{0xc00194db80, 0x92}, {0xc001950228, 0x11}, {0xc001950240, 0x11}, {0xc0019726f0, 0x21}, {0xc001a62590, ...}, ...})
Feb 08 17:14:17 prometheus docker[8302]: /app/discovery/azure/azure.go:375 +0x7a1
Feb 08 17:14:17 prometheus docker[8302]: created by github.com/prometheus/prometheus/discovery/azure.(*Discovery).refresh
Feb 08 17:14:17 prometheus docker[8302]: /app/discovery/azure/azure.go:321 +0xd52
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (13 by maintainers)
Can you please try #10289?
Pre-built binaries from our CI: https://app.circleci.com/pipelines/github/prometheus/prometheus/15928/workflows/bb6f9612-032a-407e-a204-66282a431552/jobs/75697/artifacts
I guess azure changed something in their API’s.