我有下面的Dockerfile
FROM prom/prometheus
ADD prometheus.yml /etc/prometheus/用prometheus.yml
global:
scrape_interval: 15s
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'prometheus'
metrics_path: /metrics
scrape_interval: 15s
static_configs:
- targets: ['localhost:9090']
- job_name: 'auth-service'
scrape_interval: 15s
metrics_path: /actuator/prometheus
static_configs:
- targets: ['localhost:8080']并使用以下命令运行它:
docker build -t prometheus .
docker run -d -p 9090:9090 --rm prometheusprometheus拥有up状态
8月-服务状态为down (Get "http://localhost:8080/actuator/prometheus":拨号tcp 127.0.0.1:8080:连接:连接被拒绝“)
我如何解决auth-service,的问题,因为从本地机器我可以从这个地址http://localhost:8080/actuator/prometheus获得指标。
v.balun@macbook-vbalun Trainter-Prometheus % curl -X GET
http://localhost:8080/actuator/prometheus
# HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for the
Java virtual machine to use
# TYPE jvm_memory_committed_bytes gauge
jvm_memory_committed_bytes{area="heap",id="G1 Survivor Space",} 4194304.0
jvm_memory_committed_bytes{area="heap",id="G1 Old Gen",} 3.145728E7
jvm_memory_committed_bytes{area="nonheap",id="Metaspace",} 3.0982144E7
jvm_memory_committed_bytes{area="nonheap",id="CodeHeap 'non-nmethods'",} 2555904.0
jvm_memory_committed_bytes{area="heap",id="G1 Eden Space",} 2.7262976E7
jvm_memory_committed_bytes{area="nonheap",id="Compressed Class Space",} 4325376.0
jvm_memory_committed_bytes{area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 6291456.0发布于 2020-12-24 20:11:53
你的问题似乎与普罗米修斯无关,似乎是在码头网络层面。
在您的prometheus容器中,您会这样说:
static_configs:
- targets: ['localhost:8080']但是请记住,localhost现在不是您的物理主机(就像您在Docker之外本地运行它时那样),它现在在容器中,并且在同一个容器中,很可能您没有运行您的服务……
根据所提供的资料,我建议你如下:
localhost来代替auth-service的ip地址,这是由对接者给出的地址,您可以运行docker inspect...来获得它。如果#1和#2没有工作,那么H 112如果auth-service运行在同一物理主机内的另一个容器中,那么您可以使用桥接网络来实现容器之间的通信,这里有更多详细信息:https://docs.docker.com/network/bridge/,一旦两个容器在同一个网络中运行,您可以使用容器名称来引用它,而不是localhost,类似于:
static_configs:
- targets: ['auth-service:8080']https://stackoverflow.com/questions/65442417
复制相似问题