Answers: <p>This question appears to express a more general desire to understand Prometheus and how it can scrape metrics from other systems, including those that have built-in metrics capabilities, as well as those that use Prometheus Exporters. I recommend having a look at the Prometheus documentation on this topic: <a href="https://prometheus.io/docs/instrumenting/exporters" rel="nofollow noreferrer">https://prometheus.io/docs/instrumenting/exporters</a></p>
  <p>Typically, a general setup might look something like this:</p>
  <pre><code>┌─────────────────────┐                                   
  │ system              │                                   
  └───┬─────────────────┴──┐                                
      │ Prometheus Exporter│                                
      └────────────────────┘                                
                                ┌────────────┐   ┌─────────┐
  ┌─────────────────────┐       │            │   │         │
  │ system              │       │ Prometheus │   │ Grafana │
  └───┬─────────────────┴──┐    │            │   │         │
      │ Prometheus Exporter│    └────────────┘   └─────────┘
      └────────────────────┘                                
                                                            
      ┌────────────────────┐                                
      │ system with        │                                
      │ built-in metrics   │                                
      │ capability         │                                
      └────────────────────┘                                
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2024-04-22T19:44:02.797Z
Answers: Per my post I've done this already for Java metrics via the JMX exporter. I just didn't know how to do it for other metrics.
Answers: Chris F
Answers: CC BY-SA 4.0
Answers: 2024-04-17T13:56:38.870Z
Answers: 2024-04-17T13:56:38.870Z
Answers: mikequentel
Answers: <p>Prometheus is designed to use a <code>pull</code> system for collecting metrics, wherein each component you want to monitor will have to somehow &quot;publish&quot; its metrics in a way Prometheus can then reach out and scrape into its database. This is different than a <code>push</code> system in which an agent is installed onto the underlying infrastructure and it reports out to the monitoring controller.</p>
  <p>Therefore, you'll have to set up your application to report metrics in a format that Prometheus understands. In a standard setup of Prometheus, there will be some open page on the application at <code>/metrics</code> (if a web app) that lists all the metrics one by one in Prometheus format, e.g.:</p>
  <pre><code>metric_name{metadata=&quot;label&quot;}metric_value
  
  http_responses_200_count{env=&quot;dev&quot;}2913
  http_responses_500_count{env=&quot;dev&quot;}12
  http_responses_500_count{env=&quot;prod&quot;}2
  ...
  </code></pre>
  <p>Now to actually <em>get</em> these metrics into this format that Prometheus expects, you'll either have to use <a href="https://prometheus.io/docs/instrumenting/exporters/" rel="nofollow noreferrer">some kind of exporter that already exists</a> (although the one provided for AWS ECS only has metrics like count of container instances and other high level details), or you'll have to kind of create your own.</p>
  <p>Shameless plug, but I've <a href="https://github.com/christophersinclair/json2prom" rel="nofollow noreferrer">actually built a <code>json2prom</code> API</a> that you can spin up somewhere and push your desired metrics to in JSON, and it will publish it in Prometheus format for your Prometheus instance to then target and scrape. Not sure if that fits your use case, but have a look at it.</p>
  <p>Otherwise, maybe setting up <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/deploy-container-insights-ECS-cluster.html" rel="nofollow noreferrer">ECS Container Insights</a> through CloudWatch and viewing it in Grafana would be a simpler approach? Grafana can use multiple different datasources, including CloudWatch itself - it doesn't have to be just Prometheus.</p>
  
Answers: CC BY-SA 4.0
Answers: 2024-04-22T19:06:05.130Z
Answers: Thanks. I've reading about cAdvisor (https://github.com/google/cadvisor) to use for Docker containers.
Answers: Chris F
Answers: CC BY-SA 4.0
Answers: 2024-04-19T23:07:34.877Z
Answers: 2024-04-19T23:07:34.877Z
Answers: Christopher Sinclair
Body: <p>We have a container running in ECS, and we want to collect the following metrics (truncated list) in Prometheus and eventually view them in Grafana. How do I setup the Prometheus agent on the container to collect them? I've read these two articles, and am able to collect JMX metrics and see them in AWS CloudWatch and view them in Grafana. I just want to know how to set up these (non-JMX?) metrics. Thanks!</p>
  <ul>
  <li><a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Setup-ECS.html" rel="nofollow noreferrer">Set up and configure Prometheus metrics collection on Amazon ECS clusters</a></li>
  <li><a href="https://aws.amazon.com/blogs/mt/monitor-and-scale-your-amazon-ecs-on-aws-fargate-application-using-prometheus-metrics/" rel="nofollow noreferrer">Monitor and scale your Amazon ECS on AWS Fargate application using Prometheus metrics</a></li>
  </ul>
  <pre><code>{
    &quot;mem&quot;: 7258243,
    &quot;mem.free&quot;: 3979697,
    &quot;processors&quot;: 1,
    &quot;instance.uptime&quot;: 473683,
    &quot;uptime&quot;: 506915,
    &quot;systemload.average&quot;: 2.41357421875,
    &quot;heap.committed&quot;: 7095424,
    &quot;heap.init&quot;: 7340032,
    &quot;heap.used&quot;: 3115726,
    &quot;heap&quot;: 7095424,
    &quot;nonheap.committed&quot;: 167552,
    &quot;nonheap.init&quot;: 2496,
    &quot;nonheap.used&quot;: 162819,
    &quot;nonheap&quot;: 0,
    &quot;threads.peak&quot;: 45,
    &quot;threads.daemon&quot;: 28,
    ...
  }
  </code></pre>
  
Comments: CC BY-SA 4.0
Comments: 2024-10-22T10:48:22.927Z
Comments: Did you find any solution to your question apart from others answers??
Comments: Ajay
Tags: <prometheus>
Title: How collect these metrics in Prometheus for an AWS ECS container?
UserDisplayName: Chris F
ThreadText: # How collect these metrics in Prometheus for an AWS ECS container?
  
  (Asked by: username_0 on 2024-04-15)
  
  We have a container running in ECS, and we want to collect the following metrics (truncated list) in Prometheus and eventually view them in Grafana. How do I setup the Prometheus agent on the container to collect them? I've read these two articles, and am able to collect JMX metrics and see them in AWS CloudWatch and view them in Grafana. I just want to know how to set up these (non-JMX?) metrics. Thanks!
  
  * [Set up and configure Prometheus metrics collection on Amazon ECS clusters](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Setup-ECS.html)
  * [Monitor and scale your Amazon ECS on AWS Fargate application using Prometheus metrics](https://aws.amazon.com/blogs/mt/monitor-and-scale-your-amazon-ecs-on-aws-fargate-application-using-prometheus-metrics/)
  
  ```
  {
    "mem": 7258243,
    "mem.free": 3979697,
    "processors": 1,
    "instance.uptime": 473683,
    "uptime": 506915,
    "systemload.average": 2.41357421875,
    "heap.committed": 7095424,
    "heap.init": 7340032,
    "heap.used": 3115726,
    "heap": 7095424,
    "nonheap.committed": 167552,
    "nonheap.init": 2496,
    "nonheap.used": 162819,
    "nonheap": 0,
    "threads.peak": 45,
    "threads.daemon": 28,
    ...
  }
  
  ```
  
  **Tags:** prometheus
  
  > **Comments:**
  > **username_1**: Did you find any solution to your question apart from others answers??  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2024-04-17. Score: 0
  
  This question appears to express a more general desire to understand Prometheus and how it can scrape metrics from other systems, including those that have built-in metrics capabilities, as well as those that use Prometheus Exporters. I recommend having a look at the Prometheus documentation on this topic: <https://prometheus.io/docs/instrumenting/exporters>
  
  Typically, a general setup might look something like this:
  
  ```
  ┌─────────────────────┐                                   
  │ system              │                                   
  └───┬─────────────────┴──┐                                
      │ Prometheus Exporter│                                
      └────────────────────┘                                
                                ┌────────────┐   ┌─────────┐
  ┌─────────────────────┐       │            │   │         │
  │ system              │       │ Prometheus │   │ Grafana │
  └───┬─────────────────┴──┐    │            │   │         │
      │ Prometheus Exporter│    └────────────┘   └─────────┘
      └────────────────────┘                                
                                                            
      ┌────────────────────┐                                
      │ system with        │                                
      │ built-in metrics   │                                
      │ capability         │                                
      └────────────────────┘                                
  
  ```
  
  > **Comments:**
  > **username_0**: Per my post I've done this already for Java metrics via the JMX exporter. I just didn't know how to do it for other metrics.  
  
  ---
  
  ### Answer by username_3 on 2024-04-19. Score: 0
  
  Prometheus is designed to use a `pull` system for collecting metrics, wherein each component you want to monitor will have to somehow "publish" its metrics in a way Prometheus can then reach out and scrape into its database. This is different than a `push` system in which an agent is installed onto the underlying infrastructure and it reports out to the monitoring controller.
  
  Therefore, you'll have to set up your application to report metrics in a format that Prometheus understands. In a standard setup of Prometheus, there will be some open page on the application at `/metrics` (if a web app) that lists all the metrics one by one in Prometheus format, e.g.:
  
  ```
  metric_name{metadata="label"}metric_value
  
  http_responses_200_count{env="dev"}2913
  http_responses_500_count{env="dev"}12
  http_responses_500_count{env="prod"}2
  ...
  
  ```
  
  Now to actually *get* these metrics into this format that Prometheus expects, you'll either have to use [some kind of exporter that already exists](https://prometheus.io/docs/instrumenting/exporters/) (although the one provided for AWS ECS only has metrics like count of container instances and other high level details), or you'll have to kind of create your own.
  
  Shameless plug, but I've [actually built a `json2prom` API](https://github.com/username_3/json2prom) that you can spin up somewhere and push your desired metrics to in JSON, and it will publish it in Prometheus format for your Prometheus instance to then target and scrape. Not sure if that fits your use case, but have a look at it.
  
  Otherwise, maybe setting up [ECS Container Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/deploy-container-insights-ECS-cluster.html) through CloudWatch and viewing it in Grafana would be a simpler approach? Grafana can use multiple different datasources, including CloudWatch itself - it doesn't have to be just Prometheus.
  
  > **Comments:**
  > **username_0**: Thanks. I've reading about cAdvisor (https://github.com/google/cadvisor) to use for Docker containers.  
  
  ---
  
  