首页 文章

无法到达我在AWS Elastic beanstalk上部署在docker中的prometheus和grafana

提问于
浏览
4

我想用Prometheus和Grafana监控我的应用程序,在AWS Elastic Beanstalk上使用Docker运行,但是在正确部署它时遇到了问题 .

这是我的 Dockerrun.aws.json

{
  "AWSEBDockerrunVersion": "2",
  "volumes": [
    {
      "name": "prometheus-conf",
      "host": {
        "sourcePath": "/var/app/current/prometheus"
      }
    }
  ],
  "containerDefinitions": [
    {
      "name": "prometheus-app",
      "image": "prom/prometheus",
      "essential": true,
      "memory": 512,
      "portMappings": [
        {
          "hostPort": 9090,
          "containerPort": 9090
        }
      ],
      "mountPoints": [
        {
          "sourceVolume": "prometheus-conf",
          "containerPath": "/opt/prometheus"
        }
      ],
      "command": [
        "--config.file=/opt/prometheus/prometheus.yml"
      ]
    },
    {
      "name": "grafana",
      "image": "grafana/grafana",
      "essential": true,
      "memory": 256,
      "links": [
        "prometheus-app"
       ],
       "portMappings": [
         {
           "hostPort": 3000,
           "containerPort": 3000
         }
       ]
     }
  ]
}

这是我在 prometheus 文件夹中的 prometheus.yml

global:
  scrape_interval:     15s
  evaluation_interval: 15s
rule_files:
scrape_configs:
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ['localhost:9090']
  - job_name: 'jParser'
    static_configs:
      - targets: ['jParser.fpemryt2er.us-east-2.elasticbeanstalk.com']

当我在 eb cli 中使用 eb local run 本地运行它时,一切正常,我可以在 localhost:9090 上访问prometheus,在 localhost:3000 上访问grafana .

当我使用_915228将其部署到AWS Elastic Beanstalk时,流程成功结束,我可以在我的仪表板中看到该实例,但在一分钟状态 OK 切换到 Severe ,消息 Environment health has transitioned from Ok to Severe. ELB health is failing or not available for all instances.100.0 % of the requests to the ELB are failing with HTTP 5xx (10 minutes ago)

enter image description here

但是,当我在EC2管理控制台中查看此实例时,它显示该实例正在运行而没有任何问题:

enter image description here

在我的任务定义控制台中,我也可以看到Prometheus和Grafana运行没有任何问题:

enter image description here

但无论如何,我不能通过EB url:port提供的输入来达到prometheus和grafana,例如: jd-env.8myne2inmq.us-west-2.elasticbeanstalk.com:9090 . 我还尝试使用公共DNS和IP,如EC2控制台中所示,但它也不起作用 .

在我的loadbalancer中,我打开了端口9090和3000:

enter image description here

请帮助我让这些应用程序正常运行 .

1 回答

  • 0

    我发现了问题 . 在Loadbalancer中打开端口 90903000 后,还需要在 Configurations/Instances/ 中切换EC2安全组 . 之后,打开这些端口的新负载 balancer 配置变为可用 .

    另一个问题是Elastic beanstalk运行状况监控系统试图检查端口 80 ,但在我的情况下没有任何东西,所以 Health 状态总是红色 . 在 Configurations/Monitoring 中,我将其更改为 endpoints HTTP:9090/graph - 现在它访问Prometheus主页并且运行状况为绿色 .

相关问题