Use write endpoint
The write endpoint is an API used by Prometheus agents or servers to write collected metric data to cloud storage.
Each workspace is assigned a unique write endpoint, which securely stores data from various sources into a centralized repository.
You can find the write endpoint of a workspace using the workspace information API. (View workspace information)
Metrics stored in the central repository can be used for up to 6 months. They are deleted immediately when the workspace is deleted.
Send metrics
To collect metrics in Advanced Managed Prometheus, you must send Prometheus-compatible metrics to the write endpoint.
You can use an exporter or expose metrics directly from your application.
Refer to the official Prometheus documentation for a list of available exporters. (Prometheus Exporters and integrations)
Example using Node Exporter
Node Exporter is one of the most widely used collection tools in the Prometheus ecosystem. It provides Prometheus-compatible metrics by converting data from specific applications or systems.
Role of Node Exporter
Node Exporter collects key hardware and OS-level metrics from Linux and Unix-based systems and sends them to the Prometheus server. It provides an HTTP endpoint that the Prometheus server can scrape. Key metrics include:
- CPU usage
- Memory usage
- Disk I/O
- Network traffic
- Filesystem status
- Operating system status
1. Use VM instance
For instructions on how to create and connect to a VM instance, refer to Create and connect instance.
Node Exporter provides the /metrics endpoint on port 9100 by default.
- Install the exporter with the commands below.
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
tar xvfz node_exporter-1.3.1.linux-amd64.tar.gz
cd node_exporter-1.3.1.linux-amd64
./node_exporter&
- Download and extract Prometheus.
cd ~
wget https://github.com/prometheus/prometheus/releases/download/v2.33.1/prometheus-2.33.1.linux-amd64.tar.gz
tar xvfz prometheus-2.33.1.linux-amd64.tar.gz
cd prometheus-2.33.1.linux-amd64
- Create a directory to store the configuration file and create the yaml file.
mkdir -p /etc/prometheus
vi /etc/prometheus/prometheus-agent.yaml
- Copy and paste the content below into the configuration file. Replace
targets,url, and credential info with actual values.
global:
scrape_interval: 15s # Scrape interval
scrape_configs:
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
remote_write:
- url: "https://advanced-managed-prometheus.kr-central-2.kakaocloud.com/workspaces/XXXXXXX/api/v1/push"
headers:
Credential-ID: 'xxxxxxxx'
Credential-Secret: 'xxxxxxxxxxxxxxxxxxxxxxxxx'
- Run Prometheus from the installation directory.
cd /root/prometheus-2.33.1.linux-amd64
./prometheus --config.file=/etc/prometheus/prometheus-agent.yaml --enable-feature=remote-write-receiver --web.listen-address=":9090" --storage.tsdb.path="/tmp/prometheus_data" &
- If Prometheus runs successfully, access it in a browser using the VM’s IP and port 9090.
http://<VM_IP>:9090
- Go to Status > Targets in the Prometheus dashboard and verify that the node_exporter target shows UP.
2. Use Kubernetes cluster
Refer to Create and manage cluster for cluster setup and Configure kubectl control for kubectl setup.
- Verify kubectl works correctly.
kubectl --kubeconfig=$KUBE_CONFIG get nodes
# Example output
# NAME STATUS ROLES AGE VERSION
# {node-name} Ready <none> 2d2h v1.18.17
# {node-name} Ready <none> 2d2h v1.18.17
- Install Helm and verify installation.
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm version
# Example output
# version.BuildInfo{Version:"v3.x.x", GitCommit:"xxxxx", ...}
- Create monitoring namespace and install Prometheus using Helm.
kubectl --kubeconfig=$KUBE_CONFIG create namespace monitoring
helm install prometheus prometheus-community/prometheus --namespace monitoring --set server.persistentVolume.enabled=false --kubeconfig=$KUBE_CONFIG
- Prometheus uses
prometheus.ymlto collect metrics. Define the scrape targets and collection interval by editing the ConfigMap. Before editing, check the Node Exporter IP address and port.
- Identify Node Exporter pod
kubectl get pods -n kube-system -o wide --kubeconfig=$KUBE_CONFIG | grep node-exporter
# Example output
# ke-prometheus-node-exporter-gzsf8 1/1 Running 0 5m 10.xxx.0.5
# ...
- Check Node Exporter port
kubectl describe pod ke-prometheus-[node-exporter-name] -n kube-system --kubeconfig=$KUBE_CONFIG
# Example command
# kubectl describe pod ke-prometheus-node-exporter-gzsf8 -n kube-system --kubeconfig=$KUBE_CONFIG
# Example output (excerpt)
# Containers:
# node-exporter:
# Ports: 9100/TCP (port information)
- Identify ConfigMap name
kubectl get configmap -n monitoring --kubeconfig=$KUBE_CONFIG
# Example output (excerpt)
# NAME DATA AGE
# prometheus-server 1 5m
- Edit ConfigMap
kubectl edit configmap [configmap name] -n monitoring --kubeconfig=$KUBE_CONFIG
# Example command
# kubectl edit configmap prometheus-server -n monitoring --kubeconfig=$KUBE_CONFIG
- Add the following to the
prometheus.ymlsection in ConfigMap
remote_write:
- url: "https://advanced-managed-prometheus.kr-central-2.kakaocloud.com/workspaces/XXXXXXX/api/v1/push"
headers:
Credential-ID: 'xxxxxxxx'
Credential-Secret: 'xxxxxxxxxxxxxxxxxxxxxxxxx'
scrape_configs:
- job_name: 'node_exporters'
static_configs:
- targets:
- 'ke-prometheus-node-exporter.kube-system:XXXXX'
# Example configuration (excerpt)
#apiVersion: v1
#data:
# alerting_rules.yml: |
# {}
# alerts: |
# {}
# allow-snippet-annotations: "false"
# prometheus.yml: |
# global:
# evaluation_interval: 1m
# scrape_interval: 1m
# scrape_timeout: 10s
# rule_files:
# - /etc/config/recording_rules.yml
# - /etc/config/alerting_rules.yml
# - /etc/config/rules
# - /etc/config/alerts
# remote_write:
# - url: 'https://advanced-managed-prometheus.kr-central-2.kakaocloud.com/workspaces/ws-ddddd15c4/api/v1/push'
# headers:
# Credential-ID: '49448eeec0824a4eaa076140..'
# Credential-Secret: '2d6ffc6ec7e48c99f72c693d90d6dd3c..'
# scrape_configs:
# - job_name: 'node_exporters'
# static_configs:
# - targets:
# - 'ke-prometheus-node-exporter.kube-system:59100'
# - job_name: prometheus
# ...
- Restart Prometheus server due to ConfigMap change
kubectl delete pod -l app=prometheus,component=server -n monitoring --kubeconfig=$KUBE_CONFIG
- Start port forwarding.
kubectl port-forward -n monitoring svc/prometheus-server 8080:80 --kubeconfig=$KUBE_CONFIG
- Access Prometheus via local browser.
http://localhost:8080/
- Go to Status > Targets in the dashboard and confirm node_exporter target is shown as UP.