Setup Metrics Streaming¶
Overview¶
This topic describes how user may setup metrics streaming to send metrics to CloudAEye SaaS.
Prerequisites¶
User is required to create a metrics service.
Supported Environments¶
CloudAEye SaaS supports the following application environments:
Type | Runtime Description / Cloud Services |
---|---|
Distributed cloud applications (typically follows microservices architecture) | Docker with AWS EKS - Elastic Kubernetes Service, Kubernetes System Metrics from AWS EKS |
Containerized web applications | Docker with AWS EC2 - Elastic Compute Cloud |
Serverless containerized web applications | Fargate with AWS ECS |
Serverless functions | Lambda |
Streaming Metrics¶
Install Agent on AWS EKS (Kubernetes)¶
CloudAEye SaaS console shows the instructions to setup agent for metrics streaming. However, user will need to use caeops
CLI to to set it up.
To view the instructions in console, select Services > Metrics
from the left navigation menu. User will see a list of metrics services that are already created in the system.
Click on the name of the metrics service under Service Name
column.
Under Agent instructions
section, select EKS
from the drop-down menu. The agent setup instructions for EKS will be shown. Similarly, select other choices from the drop-down menu to view instructions for other runtime environments such as EC2/Docker
, ECS/Fargate
.
User may run caeops metrics install-agent
command to setup the agent for metrics streaming.
For example,
caeops metrics install-agent --service-name demo-metrics-service --cloud aws --source kubernetes --kubernetes-cluster-name demo-cluster --app-name "demo-app"
--service-name
is the metrics service user created in create step.
Install Agent with Helm¶
For Kubernetes, user will be given instructions to run a helm
command.
1. Run the below command to download the script and install the agent. (This script installs a helm chart)
wget -O aws_kubernetes_agent.py https://cae-data-collection-agent.s3.us-east-2.amazonaws.com/kubernetes/scripts/aws_kubernetes_agent.py &&
pip3 install boto3 &&
python3 aws_kubernetes_agent.py --agent-mode 'create'
--helm-repo 'https://cae-data-collection-agent.s3.us-east-2.amazonaws.com/kubernetes/helm/cae-k8-agent/charts'
--enable-metrics 'yes' --k8-namespace 'cloudaeye' --cloud-env 'aws'
--prometheus-endpoint 'https://your-metrics-endpoint.com' --prometheus-region 'some-region'
--user-key 'some-key' --user-secret 'some-secret'
Do you want to execute the command ? (y/n)
Install Agent on Docker with AWS EC2¶
User may run caeops metrics install-agent
command with --source docker
option to setup the agent for metrics streaming on Docker with EC2 setup.
Here is an example:
caeops metrics install-agent --service-name demo-metrics-service --cloud aws --source docker --app-name "demo-app" --docker-network test --metrics-scrape-config F:\CloudAEye\user-config.yaml
Here --service-name
is the metrics service user created in create step.
Step 1
------
Download the script to run the agent. (This script deploys a docker container. Skip this step if the script is already downloaded)
←[36m wget -O aws_docker_agent.py https://cae-data-collection-agent.s3.us-east.amazonaws.com/docker/scripts/aws_docker_agent.py
Do you want to execute the command ? (y/n) y
Step 2
------
Run the below command to install the agent
←[36m python3 aws_docker_agent.py --agent-mode create --agent-type metrics --docker-network test --prometheus-endpoint https://aps-workspaces.us-east-2.amazonaws.com/workspaces/ws-a671c0-ef5-451-aa7-158af1/api/v1/remote_write --prometheus-region us-east-2 --user-key ${user-key} --user-secret ${user-secret} --default-config-url https://cae-data-collection-agent.s3.us-east.amazonaws.com/docker/scripts/docker-metrics-config.yaml --user-config-file F:\CloudAEye\user-config.yaml
Do you want to execute the command ? (y/n) y
.--. .-. .-. .--. .--.
: .--': : : :: .; :: .--'
: : : : .--. .-..-. .-' :: :: `; .-..-. .--.
: :__ : :_ ' .; :: :; :' .; :: :: :: :__ : :; :' '_.'
`.__.'`.__;`.__.'`.__.'`.__.':_;:_;`.__.'`._. ;`.__.'
.-. :
`._.'
=======================================
Install Agent => Metrics source: docker
=======================================
Open Telemetry configuration to scrape metrics :
processors:
batch: null
receivers:
prometheus:
config:
global:
scrape_interval: 3m
scrape_timeout: 10s
scrape_configs:
- job_name: prometheus
metrics_path: /metrics
static_configs:
- targets:
- expresscart:1111
exporters:
awsprometheusremotewrite:
endpoint: https://aps-workspaces.us-east-2.amazonaws.com/workspaces/ws-a6c0-e05-45a1-a2a7-1591/api/v1/remote_write
aws_auth:
region: us-east-2
service: aps
logging:
loglevel: info
service:
pipelines:
metrics:
receivers:
- prometheus
exporters:
- logging
- awsprometheusremotewrite
Configuration saved to : F:\docker-agent-test/docker-metrics-config.yaml
------------------------
Docker command generated
------------------------
docker run -d --name cae-metrics-agent --network test -e AWS_ACCESS_KEY_ID=AKIA2YKY6YOURKEY -e AWS_SECRET_ACCESS_KEY=KvfRUx7V6Ok5JCYOURSECRETJ -e AWS_REGION=us-east-2 -v F:\docker-agent-test/docker-metrics-config.yaml:/etc/otel-agent-config.yaml public.ecr.aws/aws-observability/aws-otel-collector:latest --config=/etc/otel-agent-config.yaml
Do you want to run the docker container ? (NOTE: Please make sure that you have docker already installed!) [y/n] : y
Customizing Scrape Config¶
By default, CloudAEye scrapes metrics from "/metrics" which is a Prometheus convention. User may customize when necessary.
Kubernetes¶
--metrics-scrape-config
option allows user to customize scrape target for Kubernetes.
caeops metrics install-agent --service-name "demo-metrics-service" --cloud aws --source kubernetes --app-name "demo-app" --kubernetes-cluster-name demo-cluster --metrics-scrape-config "F:/CloudAEye/docker-agent-test/k8-metrics.yaml"
Config Structure (Yaml) Generation for Kubernetes¶
User may use the following command with --generate-default-scrape-config
option to generate the Yaml file that has the required scrape target configuration.
caeops metrics install-agent --service-name "demo-metrics-service" --cloud aws --source kubernetes --generate-default-scrape-config
instances:
- prometheus_url: /metrics # default
targets: "" # metrics end point
job_name: prometheus # default
Docker on EC2¶
--metrics-scrape-config
option allows user to customize scrate target for Docker.
caeops metrics install-agent --service-name "demo-metrics-service" --cloud aws --source docker --app-name demo-app --docker-network demo --metrics-scrape-config "F:/CloudAEye/docker-agent-test/docker-metrics.yaml"
Config Structure (Yaml) Generation for Docker¶
User may use the following command with --generate-default-scrape-config
option to generate the configuration (Yaml) file to use with Docker environment on EC2.
caeops metrics install-agent --service-name "demo-metrics-service" --cloud aws --source docker --generate-default-scrape-config
receivers:
prometheus:
config:
scrape_configs:
- job_name: prometheus # default
metrics_path: /metrics # default
static_configs:
- targets: [''] # metrics end point