尝试使用Amazon托管的Prometheus服务和Amazon托管的Grafana服务
通过使用Amazon Managed Service for Prometheus和Amazon Managed Grafana,我尝试将Raspberry Pi的指标可视化。(名字有点长…而且没有统一感…)
亚马逊Prometheus托管服务的设置步骤

只需要确定工作空间的名称。

出来上がり。非常简单。

通过树莓派4将指标发送
因为需要IAM用户的访问密钥信息,所以我们将创建IAM用户。需要的策略可能是这样的:可能仅需要aps: RemoteWrite。
最值得注意的是服务名称是 AMP。另外,Action的前缀是 aps(笑)。


使用Docker Compose启动Prometheus和Node exporter。
version: '3.8'
services:
prometheus:
image: quay.io/prometheus/prometheus:latest
network_mode: host
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
node-exporter:
image: quay.io/prometheus/node-exporter:latest
container_name: node_exporter
command:
- '--path.rootfs=/host'
network_mode: host
pid: host
restart: unless-stopped
volumes:
- '/:/host:ro,rslave'
将身份验证信息设置在remote_write处。
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
remote_write:
- url: https://aps-workspaces.ap-northeast-1.amazonaws.com/workspaces/ws-0ae04b80-d5e2-4b2c-a198-5a0c60989b58/api/v1/remote_write
sigv4:
# The AWS region. If blank, the region from the default credentials chain
# is used.
region: ap-northeast-1
# The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID`
# and `AWS_SECRET_ACCESS_KEY` are used.
access_key: XXXXXXXXXXXXXXXXXXXX
secret_key: XXXXXXXXXXXXXXXXXXXX
启动
# docker-compose up
设置 Amazon 托管 Grafana。

给工作区命名

选择用于登录Grafana界面的身份验证信息。我们选择了AWS SSO。

您可以选择Grafana访问的AWS资源。您之后还可以进行更改。


请问是否需要添加一个用户进行登录。请点击”用户和用户组设置”。

本次将添加由AWS SSO创建的组。

在权限方面,有两种角色可供选择:浏览者和管理员。如果要将默认角色从浏览者变更为管理员,只需勾选“创建管理员”并点击按钮即可。(是否有将角色重新设为浏览者的方法呢?)

Grafana登录
从管理控制台显示的工作空间URL进行访问。使用配置的AWS SSO用户登录后,Grafana画面将显示出来。菜单中有AWS的图标。

在数据源中添加Amazon Managed Service for Prometheus。
您可以通过AWS图标来找到数据源并添加它。

如果您可以做到这一点,那么这与普通的Grafana一样。
