This commit is contained in:
root
2024-07-09 19:32:35 +08:00
parent d47f32d3c5
commit 6c6027d5f5
6 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
# syntax=docker/dockerfile:1
ARG GRAFANA_VERSION="9.5.2"
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND="noninteractive"
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
ARG HTTP_PROXY
ARG HTTPS_PROXY
ENV http_proxy=${HTTP_PROXY}
ENV https_proxy=${HTTPS_PROXY}
# 替换 sources.list 文件以使用阿里云镜像源
# RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|http://mirrors.aliyun.com/ubuntu/|g' /etc/apt/sources.list && \
# sed -i 's|http://security.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list
# 安装必要的工具和库
RUN apt-get update && \
apt-get install -y wget vim bash ca-certificates
RUN wget https://dl.grafana.com/oss/release/grafana_${GRAFANA_VERSION}_amd64.deb && \
dpkg -i grafana_${GRAFANA_VERSION}_amd64.deb && \
rm grafana_${GRAFANA_VERSION}_amd64.deb
COPY grafana.ini /etc/grafana/grafana.ini
EXPOSE 3000
CMD ["/usr/sbin/grafana-server", "--config=/etc/grafana/grafana.ini"]

View File

@@ -0,0 +1,32 @@
# syntax=docker/dockerfile:1
ARG PROMETHEUS_VERSION="2.45.6"
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND="noninteractive"
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
ARG HTTP_PROXY
ARG HTTPS_PROXY
ENV http_proxy=${HTTP_PROXY}
ENV https_proxy=${HTTPS_PROXY}
# 替换 sources.list 文件以使用阿里云镜像源
# RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|http://mirrors.aliyun.com/ubuntu/|g' /etc/apt/sources.list && \
# sed -i 's|http://security.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list
# 安装必要的工具和库
RUN apt-get update && \
apt-get install -y wget vim bash ca-certificates
RUN wget https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz && \
tar xvfz prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz && \
mv prometheus-${PROMETHEUS_VERSION}.linux-amd64 /opt/prometheus && \
rm prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz
COPY prometheus.yml /opt/prometheus/prometheus.yml
EXPOSE 9090
CMD ["/opt/prometheus/prometheus", "--config.file=/opt/prometheus/prometheus.yml"]

7
dcgm-exporter/README.md Normal file
View File

@@ -0,0 +1,7 @@
构建和运行
使用 Docker Compose 构建和运行容器:
```shell
docker-compose up --build -d
```

View File

@@ -0,0 +1,34 @@
version: '3.8'
services:
prometheus:
build:
context: .
dockerfile: Dockerfile.prometheus
args:
PROMETHEUS_VERSION: "2.45.6"
HTTP_PROXY: "http://localhost:15777"
HTTPS_PROXY: "http://localhost:15777"
image: zly/prometheus:latest
container_name: prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/opt/prometheus/prometheus.yml
restart: unless-stopped
grafana:
build:
context: .
dockerfile: Dockerfile.grafana
args:
GRAFANA_VERSION: "9.5.2"
HTTP_PROXY: "http://localhost:15777"
HTTPS_PROXY: "http://localhost:15777"
image: zly/grafana:latest
container_name: grafana
ports:
- "3000:3000"
volumes:
- ./grafana.ini:/etc/grafana/grafana.ini
restart: unless-stopped

View File

@@ -0,0 +1,6 @@
[server]
http_port = 3000
[security]
admin_user = admin
admin_password = grafana

View File

@@ -0,0 +1,11 @@
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'dcgm-exporter'
static_configs:
- targets: ['127.0.0.1:9400']