feat: add apisix/etcd/grafana/prometheus
This commit is contained in:
25
src/grafana/.env.example
Normal file
25
src/grafana/.env.example
Normal file
@@ -0,0 +1,25 @@
|
||||
# Grafana Environment Variables
|
||||
|
||||
# Grafana image version
|
||||
GRAFANA_VERSION=12.1.1
|
||||
|
||||
# Host port mapping (maps to Grafana port 3000 in container)
|
||||
GRAFANA_PORT_OVERRIDE=3000
|
||||
|
||||
# Admin username
|
||||
GRAFANA_ADMIN_USER=admin
|
||||
|
||||
# Admin password - CHANGE THIS FOR PRODUCTION!
|
||||
GRAFANA_ADMIN_PASSWORD=admin
|
||||
|
||||
# Allow users to sign up themselves
|
||||
GRAFANA_ALLOW_SIGN_UP=false
|
||||
|
||||
# Comma-separated list of plugins to install
|
||||
GRAFANA_PLUGINS=
|
||||
|
||||
# Root URL for Grafana (used for links and redirects)
|
||||
GRAFANA_ROOT_URL=http://localhost:3000
|
||||
|
||||
# Secret key for signing cookies and encrypting database - SET THIS FOR PRODUCTION!
|
||||
GRAFANA_SECRET_KEY=
|
||||
75
src/grafana/README.md
Normal file
75
src/grafana/README.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Grafana
|
||||
|
||||
[English](./README.md) | [中文](./README.zh.md)
|
||||
|
||||
This service deploys Grafana, an open-source analytics and monitoring platform for visualizing metrics from various data sources.
|
||||
|
||||
## Services
|
||||
|
||||
- `grafana`: The Grafana web interface and API server.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable Name | Description | Default Value |
|
||||
| ---------------------- | ---------------------------------------------------------- | ----------------------- |
|
||||
| GRAFANA_VERSION | Grafana image version | `12.1.1` |
|
||||
| GRAFANA_PORT_OVERRIDE | Host port mapping (maps to Grafana port 3000 in container) | `3000` |
|
||||
| GRAFANA_ADMIN_USER | Admin username | `admin` |
|
||||
| GRAFANA_ADMIN_PASSWORD | Admin password | `admin` |
|
||||
| GRAFANA_ALLOW_SIGN_UP | Allow users to sign up themselves | `false` |
|
||||
| GRAFANA_PLUGINS | Comma-separated list of plugins to install | `""` |
|
||||
| GRAFANA_ROOT_URL | Root URL for Grafana (used for links and redirects) | `http://localhost:3000` |
|
||||
| GRAFANA_SECRET_KEY | Secret key for signing cookies and encrypting database | `""` |
|
||||
|
||||
Please modify the `.env` file as needed for your use case.
|
||||
|
||||
## Volumes
|
||||
|
||||
- `grafana_data`: A volume for storing Grafana's database and configuration.
|
||||
- `grafana_logs`: A volume for storing Grafana logs.
|
||||
- `grafana.ini`: Optional custom configuration file (mount to `/etc/grafana/grafana.ini`).
|
||||
- `provisioning`: Optional directory for provisioning datasources and dashboards (mount to `/etc/grafana/provisioning`).
|
||||
|
||||
## Default Credentials
|
||||
|
||||
- Username: `admin` (configurable via `GRAFANA_ADMIN_USER`)
|
||||
- Password: `admin` (configurable via `GRAFANA_ADMIN_PASSWORD`)
|
||||
|
||||
## Security Notes
|
||||
|
||||
- **Change the default admin password** in production environments.
|
||||
- Set a strong `GRAFANA_SECRET_KEY` for production use.
|
||||
- Consider disabling sign-up (`GRAFANA_ALLOW_SIGN_UP=false`) in production.
|
||||
- Use HTTPS in production by configuring a reverse proxy or Grafana's TLS settings.
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
### Installing Plugins
|
||||
|
||||
Set the `GRAFANA_PLUGINS` environment variable with a comma-separated list of plugin IDs:
|
||||
|
||||
```env
|
||||
GRAFANA_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource
|
||||
```
|
||||
|
||||
### Custom Configuration
|
||||
|
||||
Mount a custom `grafana.ini` file to `/etc/grafana/grafana.ini`:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./grafana.ini:/etc/grafana/grafana.ini
|
||||
```
|
||||
|
||||
### Provisioning Datasources and Dashboards
|
||||
|
||||
Mount a provisioning directory with datasource and dashboard configurations:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./provisioning:/etc/grafana/provisioning
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Grafana is licensed under the AGPL v3.0 license. Commercial licenses are available from Grafana Labs.
|
||||
75
src/grafana/README.zh.md
Normal file
75
src/grafana/README.zh.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Grafana
|
||||
|
||||
[English](./README.md) | [中文](./README.zh.md)
|
||||
|
||||
本服务部署 Grafana,这是一个开源的分析和监控平台,用于可视化来自各种数据源的指标。
|
||||
|
||||
## 服务
|
||||
|
||||
- `grafana`: Grafana Web 界面和 API 服务器。
|
||||
|
||||
## 环境变量
|
||||
|
||||
| 变量名 | 描述 | 默认值 |
|
||||
| ---------------------- | ------------------------------------------------ | ----------------------- |
|
||||
| GRAFANA_VERSION | Grafana 镜像版本 | `12.1.1` |
|
||||
| GRAFANA_PORT_OVERRIDE | 主机端口映射(映射到容器中的 Grafana 端口 3000) | `3000` |
|
||||
| GRAFANA_ADMIN_USER | 管理员用户名 | `admin` |
|
||||
| GRAFANA_ADMIN_PASSWORD | 管理员密码 | `admin` |
|
||||
| GRAFANA_ALLOW_SIGN_UP | 允许用户自行注册 | `false` |
|
||||
| GRAFANA_PLUGINS | 要安装的插件列表(逗号分隔) | `""` |
|
||||
| GRAFANA_ROOT_URL | Grafana 的根 URL(用于链接和重定向) | `http://localhost:3000` |
|
||||
| GRAFANA_SECRET_KEY | 用于签名 cookies 和加密数据库的密钥 | `""` |
|
||||
|
||||
请根据您的使用情况修改 `.env` 文件。
|
||||
|
||||
## 数据卷
|
||||
|
||||
- `grafana_data`: 用于存储 Grafana 数据库和配置的数据卷。
|
||||
- `grafana_logs`: 用于存储 Grafana 日志的数据卷。
|
||||
- `grafana.ini`: 可选的自定义配置文件(挂载到 `/etc/grafana/grafana.ini`)。
|
||||
- `provisioning`: 用于预配置数据源和仪表板的可选目录(挂载到 `/etc/grafana/provisioning`)。
|
||||
|
||||
## 默认凭据
|
||||
|
||||
- 用户名: `admin`(可通过 `GRAFANA_ADMIN_USER` 配置)
|
||||
- 密码: `admin`(可通过 `GRAFANA_ADMIN_PASSWORD` 配置)
|
||||
|
||||
## 安全注意事项
|
||||
|
||||
- **在生产环境中更改默认管理员密码**。
|
||||
- 为生产环境设置强 `GRAFANA_SECRET_KEY`。
|
||||
- 考虑在生产环境中禁用注册(`GRAFANA_ALLOW_SIGN_UP=false`)。
|
||||
- 通过配置反向代理或 Grafana 的 TLS 设置在生产环境中使用 HTTPS。
|
||||
|
||||
## 常见用例
|
||||
|
||||
### 安装插件
|
||||
|
||||
使用逗号分隔的插件 ID 列表设置 `GRAFANA_PLUGINS` 环境变量:
|
||||
|
||||
```env
|
||||
GRAFANA_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource
|
||||
```
|
||||
|
||||
### 自定义配置
|
||||
|
||||
将自定义 `grafana.ini` 文件挂载到 `/etc/grafana/grafana.ini`:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./grafana.ini:/etc/grafana/grafana.ini
|
||||
```
|
||||
|
||||
### 预配置数据源和仪表板
|
||||
|
||||
挂载包含数据源和仪表板配置的预配置目录:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./provisioning:/etc/grafana/provisioning
|
||||
```
|
||||
|
||||
## 许可证
|
||||
|
||||
Grafana 采用 AGPL v3.0 许可证。商业许可证可从 Grafana Labs 获得。
|
||||
46
src/grafana/docker-compose.yaml
Normal file
46
src/grafana/docker-compose.yaml
Normal file
@@ -0,0 +1,46 @@
|
||||
x-default: &default
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- &localtime /etc/localtime:/etc/localtime:ro
|
||||
- &timezone /etc/timezone:/etc/timezone:ro
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 100m
|
||||
|
||||
services:
|
||||
grafana:
|
||||
<<: *default
|
||||
image: grafana/grafana:${GRAFANA_VERSION:-12.1.1}
|
||||
container_name: grafana
|
||||
ports:
|
||||
- "${GRAFANA_PORT_OVERRIDE:-3000}:3000"
|
||||
volumes:
|
||||
- *localtime
|
||||
- *timezone
|
||||
- grafana_data:/var/lib/grafana
|
||||
- grafana_logs:/var/log/grafana
|
||||
|
||||
# Optional: Mount custom configuration
|
||||
# - ./grafana.ini:/etc/grafana/grafana.ini
|
||||
# - ./provisioning:/etc/grafana/provisioning
|
||||
environment:
|
||||
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin}
|
||||
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
|
||||
- GF_USERS_ALLOW_SIGN_UP=${GRAFANA_ALLOW_SIGN_UP:-false}
|
||||
- GF_INSTALL_PLUGINS=${GRAFANA_PLUGINS:-}
|
||||
- GF_SERVER_ROOT_URL=${GRAFANA_ROOT_URL:-http://localhost:3000}
|
||||
- GF_SECURITY_SECRET_KEY=${GRAFANA_SECRET_KEY:-}
|
||||
user: "472:472" # Grafana user
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 1G
|
||||
reservations:
|
||||
cpus: '0.25'
|
||||
memory: 256M
|
||||
|
||||
volumes:
|
||||
grafana_data:
|
||||
grafana_logs:
|
||||
Reference in New Issue
Block a user