New Relic Prometheus Configurator Image 是由 New Relic ***提供的容器化工具,旨在简化 Prometheus 与 New Relic 平台的集成配置流程。该镜像通过自动化生成和管理 Prometheus 配置文件(如 prometheus.yml),帮助用户快速实现 Prometheus 指标向 New Relic 的采集与上报,减少手动配置的复杂度和出错风险。
| 功能特性 | 说明 |
|---|---|
| 自动化配置生成 | 基于环境变量或输入参数自动生成 prometheus.yml,无需手动编写配置文件。 |
| New Relic Remote Write 集成 | 预置 New Relic Remote Write 端点配置,支持指标直接上报至 New Relic。 |
| 指标过滤与转换 | 支持通过规则(如正则表达式)筛选需上报的指标,减少无效数据传输。 |
| 密钥安全管理 | 支持通过环境变量注入 New Relic 许可证密钥,避免配置文件硬编码敏感信息。 |
| 轻量级设计 | 基于 Alpine 基础镜像,体积小(<50MB),启动速度快,适合容器化部署。 |
| 多环境适配 | 支持开发、测试、生产等多环境配置参数切换,灵活适配不同场景需求。 |
从 Docker Hub 或 New Relic ***镜像仓库拉取最新版本镜像:
bashdocker pull newrelic/newrelic-prometheus-configurator:latest
通过运行容器生成 prometheus.yml,并挂载到本地目录以便 Prometheus 使用:
bashdocker run -it --rm \ -e NEW_RELIC_LICENSE_KEY=<YOUR_NEW_RELIC_LICENSE_KEY> \ -v $(pwd)/prometheus-config:/output \ newrelic/newrelic-prometheus-configurator:latest
/output 目录生成 prometheus.yml,并通过本地挂载的 ./prometheus-config 目录输出到宿主机。将生成的 prometheus.yml 挂载到 Prometheus 容器中,示例 Docker Compose 配置:
yaml# docker-compose.yml version: '3' services: prometheus: image: prom/prometheus:latest volumes: - ./prometheus-config/prometheus.yml:/etc/prometheus/prometheus.yml # 挂载生成的配置文件 ports: - "9090:9090" restart: always configurator: image: newrelic/newrelic-prometheus-configurator:latest environment: - NEW_RELIC_LICENSE_KEY=<YOUR_NEW_RELIC_LICENSE_KEY> - PROMETHEUS_CONFIG_OUTPUT_PATH=/output/prometheus.yml volumes: - ./prometheus-config:/output restart: on-failure # 配置生成后可停止,或按需设置为 "always" 监控配置变更
通过环境变量控制配置生成逻辑,常用参数如下:
| 环境变量名 | 用途 | 示例值 | 是否必填 |
|---|---|---|---|
NEW_RELIC_LICENSE_KEY | New Relic 许可证密钥,用于身份验证。 | eu01xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(从 New Relic 控制台获取) | 是 |
PROMETHEUS_CONFIG_OUTPUT_PATH | 生成的 prometheus.yml 输出路径。 | /output/prometheus.yml(容器内路径,需通过挂载映射到宿主机) | 否(默认 /etc/prometheus/prometheus.yml) |
REMOTE_WRITE_URL | New Relic Remote Write 端点 URL。 | [***]{NEW_RELIC_LICENSE_KEY} | 否(默认根据密钥自动匹配区域端点) |
METRIC_INCLUDE_PATTERNS | 需上报的指标过滤规则(正则表达式)。 | ^node_cpu_.*,^kube_pod_.*(仅上报节点 CPU 和 Kubernetes Pod 指标) | 否(默认全部指标) |
METRIC_EXCLUDE_PATTERNS | 需排除的指标过滤规则(正则表达式)。 | ^go_.*,^process_.*(排除 Go 运行时和进程指标) | 否(默认无排除规则) |
LOG_LEVEL | 日志级别(debug/info/warn/error)。 | info | 否(默认 info) |
通过 docker-compose.yml 集成 Prometheus 和 Configurator,实现配置自动生成与 Prometheus 联动:
yaml# docker-compose.yml version: '3.8' services: prometheus-configurator: image: newrelic/newrelic-prometheus-configurator:latest environment: - NEW_RELIC_LICENSE_KEY=eu01xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # 替换为实际密钥 - METRIC_INCLUDE_PATTERNS=^node_cpu_.*,^node_memory_.*,^kube_pod_.* - METRIC_EXCLUDE_PATTERNS=^node_cpu_guest.* # 排除 guest CPU 指标 - PROMETHEUS_CONFIG_OUTPUT_PATH=/config/prometheus.yml volumes: - prometheus-config:/config # 共享配置目录给 Prometheus restart: on-failure # 配置生成成功后可停止,或按需设置为 "always" prometheus: image: prom/prometheus:v2.45.0 volumes: - prometheus-config:/etc/prometheus # 挂载生成的配置文件 - prometheus-data:/prometheus # 持久化 Prometheus 数据 ports: - "9090:9090" command: - '--config.file=/etc/prometheus/prometheus.yml' # 使用生成的配置 depends_on: - prometheus-configurator # 确保配置生成后启动 Prometheus restart: always volumes: prometheus-config: # 共享配置卷 prometheus-data: # Prometheus 数据卷
启动容器后,检查挂载目录下是否生成 prometheus.yml:
bashcat ./prometheus-config/prometheus.yml
预期输出应包含 remote_write 配置,指向 New Relic 端点:
yamlremote_write: - url: "[***]" write_relabel_configs: - source_labels: [__name__] regex: "(node_cpu_.*|node_memory_.*|kube_pod_.*)" action: keep - source_labels: [__name__] regex: "node_cpu_guest.*" action: drop
访问 Prometheus 控制台(http://localhost:9090),在「Status > Configuration」中确认配置加载成功,且「Remote Write Targets」显示正常连接。
NEW_RELIC_LICENSE_KEY 为敏感信息,建议通过容器平台的密钥管理功能(如 Kubernetes Secrets)注入,避免明文暴露。METRIC_INCLUDE_PATTERNS 和 METRIC_EXCLUDE_PATTERNS 合理过滤指标,避免大量无效数据导致的流量和存储成本增加。newrelic/newrelic-prometheus-configurator:latest)以获取功能更新和安全补丁。来自真实用户的反馈,见证轩辕镜像的优质服务
免费版仅支持 Docker Hub 加速,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
免费版仅支持 docker.io;专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像加速服务
在 Docker Desktop 配置镜像加速
Docker Compose 项目配置加速
Kubernetes 集群配置 Containerd
在宝塔面板一键配置镜像加速
Synology 群晖 NAS 配置加速
飞牛 fnOS 系统配置镜像加速
极空间 NAS 系统配置加速服务
爱快 iKuai 路由系统配置加速
绿联 NAS 系统配置镜像加速
QNAP 威联通 NAS 配置加速
Podman 容器引擎配置加速
HPC 科学计算容器配置加速
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名加速
需要其他帮助?请查看我们的 常见问题 或 官方QQ群: 13763429