Skip to content

Commit

Permalink
Merge pull request #14 from flyer5200/main
Browse files Browse the repository at this point in the history
增加docker-compose.yml配置以支持快速体验,增加配套的文档说明
  • Loading branch information
eryajf authored Sep 9, 2024
2 parents 3b2e94a + bf668f2 commit e3105fa
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@

目前应用还提供了`-v`参数,用于打印当前所使用的版本信息。

## 快速体验

本项目提供了docker-compose.yml配置文件用于快速体验。在启动前,请先在docker-compose.yml中配置好你的DNS服务商的AK/SK相关信息,并确保你的docker-compose的版本不低于[2.23.0](https://github.com/compose-spec/compose-spec/pull/429)。然后在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/次,证书信息在每天凌晨获取一次。如果你想重新获取,则重启一次应用即可。
Expand Down Expand Up @@ -139,4 +154,4 @@ record_cert_info{

| 支付宝|微信|
|:--------: |:--------: |
|![](https://t.eryajf.net/imgs/2023/01/fc21022aadd292ca.png)| ![](https://t.eryajf.net/imgs/2023/01/834f12107ebc432a.png) |
|![](https://t.eryajf.net/imgs/2023/01/fc21022aadd292ca.png)| ![](https://t.eryajf.net/imgs/2023/01/834f12107ebc432a.png) |
61 changes: 61 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e3105fa

Please sign in to comment.