title: How to make prometheus work with grafana in Docker?
body: <p>The main goal is to link prometheus as a backend in grafana, but entering <code>http://localhost:9090</code> as the url in grafana returns <code>HTTP Error Bad Gateway</code></p>
  
  <p>I started a prometheus docker image but it's not listening on port 9090 on IPv4.</p>
  
  <pre><code>netstat -ntulp
  
  Active Internet connections (only servers)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
  tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      15895/nginx: master 
  tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      3190/sshd           
  tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      24970/postmaster    
  tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      3148/master         
  tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      15895/nginx: master 
  tcp6       0      0 :::9100                 :::*                    LISTEN      16652/node_exporter 
  tcp6       0      0 :::80                   :::*                    LISTEN      15895/nginx: master 
  tcp6       0      0 :::22                   :::*                    LISTEN      3190/sshd           
  tcp6       0      0 :::3000                 :::*                    LISTEN      28436/docker-proxy  
  tcp6       0      0 ::1:5432                :::*                    LISTEN      24970/postmaster    
  tcp6       0      0 ::1:25                  :::*                    LISTEN      3148/master         
  tcp6       0      0 :::9090                 :::*                    LISTEN      31648/docker-proxy  
  udp        0      0 0.0.0.0:68              0.0.0.0:*                           2806/dhclient       
  udp        0      0 127.0.0.1:323           0.0.0.0:*                           1639/chronyd        
  udp6       0      0 ::1:323                 :::*                                1639/chronyd  
  </code></pre>
  
  <p>This is my docker command:</p>
  
  <pre><code>docker run -d -p 9090:9090 --name prometheus -v /etc/prometheus.yml:/etc/prometheus/prometheus.yml -v /mnt/vol-0001/prometheus_data/:/etc/prometheus/data prom/prometheus --log.level=debug
  </code></pre>
  
  <p>I used <code>-p 9090:9090</code> and <code>-p 0.0.0.0:9090</code> with same results</p>
  
  <p><code>docker logs prometheus</code> returns:</p>
  
  <pre><code>level=info ts=2018-12-19T21:07:59.332452641Z caller=main.go:243 msg="Starting Prometheus" version="(version=2.6.0, branch=HEAD, revision=dbd1d58c894775c0788470944b818cc724f550fb)"
  level=info ts=2018-12-19T21:07:59.332554622Z caller=main.go:244 build_context="(go=go1.11.3, user=root@bf5760470f13, date=20181217-15:14:46)"
  level=info ts=2018-12-19T21:07:59.332584047Z caller=main.go:245 host_details="(Linux 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 9dd3a9318064 (none))"
  level=info ts=2018-12-19T21:07:59.332610547Z caller=main.go:246 fd_limits="(soft=65536, hard=65536)"
  level=info ts=2018-12-19T21:07:59.332631287Z caller=main.go:247 vm_limits="(soft=unlimited, hard=unlimited)"
  level=info ts=2018-12-19T21:07:59.334232116Z caller=main.go:561 msg="Starting TSDB ..."
  level=info ts=2018-12-19T21:07:59.334671887Z caller=repair.go:48 component=tsdb msg="found healthy block" mint=1545204931123 maxt=1545220800000 ulid=01CZ3PHTVQQTW7Q122X7Y15WV4
  level=info ts=2018-12-19T21:07:59.334756938Z caller=repair.go:48 component=tsdb msg="found healthy block" mint=1545242400000 maxt=1545249600000 ulid=01CZ44997810VTYP3GV0KJXXN1
  level=info ts=2018-12-19T21:07:59.334819198Z caller=repair.go:48 component=tsdb msg="found healthy block" mint=1545220800000 maxt=1545242400000 ulid=01CZ4499ASP4RG8BPR8PE5WAKY
  level=info ts=2018-12-19T21:07:59.346244745Z caller=web.go:429 component=web msg="Start listening for connections" address=0.0.0.0:9090
  level=info ts=2018-12-19T21:07:59.461554488Z caller=main.go:571 msg="TSDB started"
  level=info ts=2018-12-19T21:07:59.461625871Z caller=main.go:631 msg="Loading configuration file" filename=prometheus.yml
  level=debug ts=2018-12-19T21:07:59.462558422Z caller=manager.go:213 component="discovery manager scrape" msg="Starting provider" provider=string/0 subs=[prometheus]
  level=info ts=2018-12-19T21:07:59.462601563Z caller=main.go:657 msg="Completed loading of configuration file" filename=prometheus.yml
  level=info ts=2018-12-19T21:07:59.462615458Z caller=main.go:530 msg="Server is ready to receive web requests."
  level=debug ts=2018-12-19T21:07:59.462669264Z caller=manager.go:231 component="discovery manager scrape" msg="discoverer channel closed" provider=string/0
  </code></pre>
  
  <p>I also tried disabling the firewall to make sure it wasn't the cause of this headache.</p>
  
  <p>I'm no docker/kubernetes expert, you help is appreciate.</p>