Skip to main content

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)

info

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

info

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.

  1. Install the exporter with the commands below.
Install Node Exporter
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&
  1. Download and extract Prometheus.
Install 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
  1. Create a directory to store the configuration file and create the yaml file.
Set config file path
mkdir -p /etc/prometheus
vi /etc/prometheus/prometheus-agent.yaml
  1. Copy and paste the content below into the configuration file. Replace targets, url, and credential info with actual values.
Set yaml file
global:
scrape_interval: 15s # Scrape interval
scrape_configs:
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
remote_write:
- url: "http://managed-promethues.kr-central-2.kakaocloud.com/workspaces/XXXXXXX/api/v1/push"
headers:
Credential-ID: 'xxxxxxxx'
Credential-Secret: 'xxxxxxxxxxxxxxxxxxxxxxxxx'
  1. Run Prometheus from the installation directory.
Run Prometheus
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" &
  1. If Prometheus runs successfully, access it in a browser using the VM’s IP and port 9090.
Verify Prometheus
http://<VM_IP>:9090
  1. Go to Status > Targets in the Prometheus dashboard and verify that the node_exporter target shows UP.

2. Use Kubernetes cluster

info

Refer to Create and manage cluster for cluster setup and Configure kubectl control for kubectl setup.

  1. Verify kubectl works correctly.
Verify kubectl
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
  1. Install Helm and verify installation.
Install Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
Verify Helm
helm version

# Example output
# version.BuildInfo{Version:"v3.x.x", GitCommit:"xxxxx", ...}
  1. Create monitoring namespace and install Prometheus using Helm.
Create namespace
kubectl --kubeconfig=$KUBE_CONFIG create namespace monitoring
Install Prometheus
helm install prometheus prometheus-community/prometheus --namespace monitoring --set server.persistentVolume.enabled=false --kubeconfig=$KUBE_CONFIG
  1. Prometheus uses prometheus.yml to collect metrics. Update the config by editing the ConfigMap.
  • Identify Node Exporter pod
Check Node Exporter pod
kubectl get pods -n kube-system -o wide --kubeconfig=$KUBE_CONFIG | grep node-exporter
  • Check Node Exporter port
Check Node Exporter port
kubectl describe pod ke-prometheus-[node-exporter-name] -n kube-system --kubeconfig=$KUBE_CONFIG
  • Identify ConfigMap name
Check ConfigMap name
kubectl get configmap -n monitoring --kubeconfig=$KUBE_CONFIG
  • Edit ConfigMap
Edit ConfigMap
kubectl edit configmap [configmap name] -n monitoring --kubeconfig=$KUBE_CONFIG
  • Add the following to the prometheus.yml section in ConfigMap
Edit file
remote_write:
- url: "http://managed-promethues.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'
  • Restart Prometheus server due to ConfigMap change
Restart Prometheus
kubectl delete pod -l app=prometheus,component=server -n monitoring --kubeconfig=$KUBE_CONFIG
  1. Start port forwarding.
Port forward
kubectl port-forward -n monitoring svc/prometheus-server 8080:80 --kubeconfig=$KUBE_CONFIG
  1. Access Prometheus via local browser.
Verify Prometheus
http://localhost:8080/
  1. Go to Status > Targets in the dashboard and confirm node_exporter target is shown as UP.