cloudwatch_exporter icon indicating copy to clipboard operation
cloudwatch_exporter copied to clipboard

0.10.0 - setting `role_arn` also requires setting `region` or exporter fails, complaining on missing region.

Open mindw opened this issue 3 years ago • 3 comments

updated description - setting region in the config file works.

0.9.0 works as expected. Error:

Exception in thread "main" java.lang.NullPointerException: region must not be null.
	at software.amazon.awssdk.utils.Validate.paramNotBlank(Validate.java:156)
	at software.amazon.awssdk.regions.Region.of(Region.java:134)
	at software.amazon.awssdk.regions.Region.of(Region.java:130)
	at io.prometheus.cloudwatch.CloudWatchCollector.getRoleCredentialProvider(CloudWatchCollector.java:284)
	at io.prometheus.cloudwatch.CloudWatchCollector.loadConfig(CloudWatchCollector.java:168)
	at io.prometheus.cloudwatch.CloudWatchCollector.loadConfig(CloudWatchCollector.java:136)
	at io.prometheus.cloudwatch.CloudWatchCollector.<init>(CloudWatchCollector.java:101)
	at io.prometheus.cloudwatch.WebServer.main(WebServer.java:27)

Config:

apiVersion: v1
data:
  config.yml: |-
    delay_seconds: 300
    # period_seconds: 60
    range_seconds: 120
    role_arn: arn:aws:iam::<reducted>
    metrics:
      - aws_namespace: AWS/CloudHSM
        aws_metric_name: HsmUnhealthy
        aws_dimensions: [ClusterId, HsmId]
        aws_dimension_select:
          ClusterId: ['<reducted>']
        aws_statistics: [Maximum, Average]
<reducted>
kind: ConfigMap
metadata:
  labels:
    app: cloudwatch-exporter-hsm
    monitoring: prometheus
  name: cloudwatch-exporter-hsm
  namespace: kube-system

Expected: AWS region is picked up automatically as described in here,

mindw avatar May 19 '21 11:05 mindw

This might be fallout from the AWS SDK v2 update.

As a workaround, it does it work to supply a configuration file and make the exporter use it via environment variables?

matthiasr avatar May 21 '21 16:05 matthiasr

@matthiasr thank you for looking into this. I have double checked the finding and found an error, setting region in the config works as expected. I've update the title and description to match. While still a regression - it is much less severe IMHO.

mindw avatar May 25 '21 09:05 mindw

Hi, the AWS region is picked up automatically if your application runs in AWS infrastructure. If the app runs elsewhere, the was SDK tries to pick up the default region following its Default Region Provider Chain. Cloudwatch is a regionalized service so the SDK has to know which region it interacts with, otherwise it would fail during initializtion.

neinatu avatar Jul 13 '21 08:07 neinatu