nerdswords / yet-another-cloudwatch-exporter

Prometheus exporter for AWS CloudWatch - Discovers services through AWS tags, gets CloudWatch metrics data and provides them as Prometheus metrics with AWS tags as labels
Apache License 2.0
981 stars 334 forks source link

[BUG] Yaml config error log is not logged when debug mode is enabled #1377

Open AmmarovTou opened 7 months ago

AmmarovTou commented 7 months ago

Is there an existing issue for this?

YACE version

v0.57.1

Config file

  discovery:
    jobs:
    - type: sagemaker
      regions:
        - <aws_region>
      roles:
        - roleArn: "arn:aws:iam::<account_id>:role/<role_name>"
      dimensions:
        - name: EndpointName
          value: <endpoint1_name>
        - name: EndpointName
          value: <endpoint2_name>
      period: 120
      length: 3600
      metrics:
        - name: Invocations
          statistics: [Sum]

Current Behavior

Hi, I'm not completely certain if this is an actual bug, or if it's really the intended behavior, if so then please consider this issue as a question, thanks.

The job configuration attached above has a problem, it defines "dimensions", while the job type is "discovery" not "static", which leads to yace logging an error about the misconfiguration but only when debug mode is disabled, and therefore metrics not getting scraped. If debug mode is enabled, it doesn't log that error, and yace works ok.

More details:

When debug mode is enabled:

extraArgs:
  debug: true

It doesn't log any error regarding the job's configuration, it works ok and scrapes the metrics.

When debug mode is disabled:

extraArgs:
  debug: false

then yace logs:

{
  "caller": "main.go:240",
  "level": "info",
  "msg": "Parsing config",
  "ts": "2024-04-09T09:07:14.573455285Z",
  "version": "v0.57.1"
}
{
  "caller": "config.go:515",
  "err": "line 115: field dimensions not found in type config.Job",
  "level": "warn",
  "msg": "config file syntax error",
  "ts": "2024-04-09T09:07:14.580801808Z",
  "version": "v0.57.1"
}
{
  "caller": "config.go:515",
  "err": "line 138: field dimensions not found in type config.Job",
  "level": "warn",
  "msg": "config file syntax error",
  "ts": "2024-04-09T09:07:14.580840602Z",
  "version": "v0.57.1"
}
{
  "caller": "config.go:517",
  "level": "warn",
  "msg": "Config file error(s) detected: Yace might not work as expected. Future versions of Yace might fail to run with an invalid config file.",
  "ts": "2024-04-09T09:07:14.580846482Z",
  "version": "v0.57.1"
}
{
  "caller": "main.go:325",
  "feature_flags": "",
  "level": "info",
  "msg": "Yace startup completed",
  "ts": "2024-04-09T09:07:14.580978014Z",
  "version": "v0.57.1"
}

Expected Behavior

Yaml misconfiguration error log to be logged when debug mode is enabled.

Steps To Reproduce

  1. Create a sagemaker job, and place it under "discovery" jobs type.
  2. Add "dimensions" to the sagemaker job as shared in the config file above.
  3. Make sure to disable debug mode.
  4. Apply, and then the misconfiguration error log should appear.

Anything else?

No response