diff --git a/README.md b/README.md index cc074e3..1784ae5 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,19 @@ 目前应用还提供了`-v`参数,用于打印当前所使用的版本信息。 +## 快速体验 +本项目提供了docker-compose.yml配置文件用于快速体验。在启动前,请先在docker-compose.yml中配置好你的DNS服务商的AK/SK相关信息。然后在docker-compose.yml所在目录下执行以下命令: +```bash +docker-compose up -d +``` +> 不懂docker-compose的用户,可以参考: [docker-compose官方教程](https://docs.docker.com/compose/reference/) 或 [中文教程](https://www.runoob.com/docker/docker-compose.html) + +docker-compose.yml中定义了三个容器,分别是cloud_dns_exporter(用于获取域名和解析/证书信息),grafana(用于展示域名和解析/证书信息),prometheus(用于持久化存储域名和解析/证书信息) + +使用docker-compose.yml启动后,通过http://localhost:3000访问Grafana的WebUI,使用默认的用户名和密码admin/admin登录。 + +Grafana中添加Prometheus类型的数据源,地址为http://prometheus:9090,然后保存。再导入Grafana Dashboard 21798,数据源选择刚才添加的prometheus数据源,即可看到UI展示效果。 + ## 一些注意 - 为了提高请求指标数据时的效率,项目设计为通过定时任务提前将数据缓存的方案,默认情况下,域名及解析记录信息为30s/次,证书信息在每天凌晨获取一次。如果你想重新获取,则重启一次应用即可。 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b5df607 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,61 @@ +version: '3' +services: + cloud_dns_exporter: + image: registry.cn-hangzhou.aliyuncs.com/eryajf/cloud_dns_exporter:latest + container_name: cloud_dns_exporter + ports: + - "21798:21798" + configs: + - source: cloud_dns_exporter_config + target: /app/config.yaml + environment: + - TZ=Asia/Shanghai + grafana: + image: bitnami/grafana:11.2.0 + container_name: grafana + environment: + - GF_SECURITY_ADMIN_PASSWORD=admin #设置admin用户默认密码 + - TZ=Asia/Shanghai + ports: + - "3000:3000" + volumes: + - grafana_data:/opt/bitnami/grafana/data + prometheus: + image: bitnami/prometheus:2.54.1 + container_name: prometheus + environment: + - TZ=Asia/Shanghai + ports: + - "9090:9090" + configs: + - source: prometheus_config + target: /opt/bitnami/prometheus/conf/prometheus.yml + volumes: + - prometheus_data:/opt/bitnami/prometheus/data + +# 示例配置 +configs: + # 云解析配置,以阿里云DNS为例 + cloud_dns_exporter_config: + content: | + cloud_providers: + aliyun: + accounts: + - name: a1 + secretId: "your cloud dns accessKey" + secretKey: "your cloud dns secretKey" + # prometheus配置示例(无需修改) + prometheus_config: + content: | + scrape_configs: + - job_name: 'cloud_dns_exporter' + metrics_path: 'metrics' + scrape_interval: 15s + static_configs: + - targets: ['cloud_dns_exporter:21798'] + +volumes: + grafana_data: + driver: local + prometheus_data: + driver: local \ No newline at end of file