amazon-cloudwatch-agent icon indicating copy to clipboard operation
amazon-cloudwatch-agent copied to clipboard

ECS Service Discovery without Writing EMF Logs

Open GreasyAvocado opened this issue 2 years ago • 3 comments

Hi,

I have an ECS cluster and a self-hosted Prometheus. I'd like to use CW agent in order to perform service discovery on my ECS services, and then have Prometheus scrape the metrics of the discovered containers.

I implemented it according to this doc: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Setup-configure-ECS.html

The discovery process works well, and I get a targets file under /tmp/cwagent_ecs_auto_sd.yaml, which Prometheus can then use. The problem is that the agent also writes EMF logs to CloudWatch Logs (/aws/ecs/containerinsights/${cluster_name}/prometheus), which I don't need.

Is it possible to somehow keep the ecs_service_discovery flag in the agent's config, while disabling the agent from sending EMF logs?

I've tried using this config, but EMF logs were still being sent this way:

  "logs": {
    "metrics_collected": {
      "prometheus": {
        "prometheus_config_path": "env:PROMETHEUS_CONFIG_CONTENT",
        "ecs_service_discovery": {
          "sd_frequency": "1m",
          "sd_result_file": "/tmp/cwagent_ecs_auto_sd.yaml",
          "docker_label": {
            "sd_port_label": "ECS_PROMETHEUS_EXPORTER_PORT"
          }
        },
        "emf_processor": {
          "metric_declaration": [
            {
              "dimensions": [["Namespace"]],
              "source_labels": ["Namespace"],
              "label_matcher": "dont_send_metrics",
              "metric_selectors": ["dont_send_metrics"]
            }
          ]
        }
      }
    },
    "force_flush_interval": 5
  }
}

Any sugestions?

Thanks!

GreasyAvocado avatar Jul 12 '23 11:07 GreasyAvocado

This issue was marked stale due to lack of activity.

github-actions[bot] avatar Oct 11 '23 00:10 github-actions[bot]

If you use ADOT, you can use the https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/ecsobserver to generate the target file . You can set the exporter to noop or use its prometheus related exporters (remote write etc.), it won't generate the EMF log.

I think https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/ecstaskobserver won't generate the sd file for prometheus but I am not the author of that plugin so I don't know much about it.

pingleig avatar Oct 30 '23 22:10 pingleig

That's exactly what I ended up doing. Works great!

GreasyAvocado avatar Oct 31 '23 14:10 GreasyAvocado

This issue was marked stale due to lack of activity.

github-actions[bot] avatar Aug 14 '24 00:08 github-actions[bot]

Closing this because it has stalled. Feel free to reopen if this issue is still relevant, or to ping the collaborator who labeled it stalled if you have any questions.

github-actions[bot] avatar Sep 16 '24 00:09 github-actions[bot]