Skip to content

caeops > metrics

install-agent

Description


This command helps you setup an agent that collects metrics from any source (supported by CloudAEye) running on a given cloud env (supported by CloudAEye) and ships them to the provided metrics service endpoint

Run caeops metrics install-agent --help for more help.

Synopsis


  install-agent
--service-name [value]
--cloud [value]
--source [value]
--app-name [value]
[--kubernetes-cluster-name [value]]
[--metrics-scrape-config [value]]
[--docker-network [value]]
[--metrics-scrape-config [value]]
[--generate-default-scrape-config [value]]
[--ecs-cluster-name [value]]
[--enable-cloud-services [value]]

Options


--service-name (string)

Name of the metrics service

--cloud (string)

The type of cloud service providers. Supported providers : aws

--source (string)

The type of cloud source. Supported resources : kubernetes | docker | ecs-fargate

--app-name (string)

A representative name for the current app sending the metrics

--kubernetes-cluster-name (string)

Name of the kubernetes cluster where the agent needs to run (for source='kubernetes')

--ecs-cluster-name (string)

Name of the ECS cluster where the agent needs to run (for source='ecs-fargate')

--docker-network (string)

Name of the docker network on which the docker agent needs to run (for source='docker')

--metrics-scrape-config (string)

Absolute path to the docker application metrics end points configuration file to scrape metrics

--generate-default-scrape-config

Generates the default metrics end point configuration files based on the 'source' type

--enable-cloud-services (string)

Provide the name of AWS services where you want the metrics to collect from. You can give a string of comma separated values. Possible services are as follows - aws-natgateway - aws-elb - aws-apigateway - aws-ec2 - aws-ecs - aws-fargate - aws-lambda - aws-dynamodb - aws-rds - aws-docdb - aws-cassandra - aws-ebs - aws-s3 - aws-efs - aws-cognito - aws-sns - aws-sqs - aws-events - aws-states - aws-ses

Examples


Example 1

  • The following metrics install-agent example generates commands to install an agent for a kubernetes source on aws cloud
caeops metrics install-agent
        --service-name mymetrics --cloud aws --source kubernetes --app-name "Test App"
        --kubernetes-cluster-name test-cluster --metrics-scrape-config "/home/test/scrape_config.yaml"
Output

Instructions -> (string)

Step 1
------
Download the script to run the agent. (This script deploys a helm chart. Skip this step if the script is already downloaded)[36m    wget -O aws_kubernetes_agent.py https://cae-data-collection-agent.s3.us-east-2.amazonaws.com/kubernetes/scripts/aws_kubernetes_agent.py

Do you want to execute the command ? (y/n)n


Step 2
------
If no K8 agent is installed or active, run the below command to install a new K8 agent. (NOTE: If a K8 agent is already running for logs/metrics, skip this step and go to next step)[36m  python3 aws_kubernetes_agent.py --helm-repo "https://cae-data-collection-agent.s3.us-east-2.amazonaws.com/kubernetes/helm/cae-k8-agent/charts" --enable-metrics "yes" --k8-cluster-name "test-cluster" --k8-namespace "cloudaeye" --cloud-env "aws" --prometheus-endpoint "https://endpoint.com" --prometheus-region "someregion" --app-name "Test App" --app-key "TA" --user-key "somekey" --user-secret "somesecret" --agent-mode "create" --user-config-file "/home/test/scrape_config.yaml" --enable-cloud-services "aws-ec2,aws-ecs"

Do you want to execute the command ? (y/n)y

 .--. .-.                 .-. .--.  .--.
: .--': :                 : :: .; :: .--'
: :   : :   .--. .-..-. .-' ::    :: `;  .-..-. .--.
: :__ : :_ ' .; :: :; :' .; :: :: :: :__ : :; :' '_.'
`.__.'`.__;`.__.'`.__.'`.__.':_;:_;`.__.'`._. ;`.__.'
                                          .-. :
                                          `._.'


==================================================
Install Agent (via helm) => Log source: kubernetes
==================================================


----------------------
Helm command generated
----------------------

helm install cae-k8-agent cae-k8-agent --create-namespace --namespace cloudaeye --set namespace=cloudaeye --set client.cloud_env=aws --set client.app_name="Test App" --set client.app_key="TA" --repo https://cae-data-collection-agent.s3.us-east-2.amazonaws.com/kubernetes/helm/cae-k8-agent/charts --set user.key=somekey --set user.secret=somesecret --set client.cluster_name="test-cluster" --set metrics.enabled=true --set metrics.prometheusRegion=someregion  --set metrics.prometheusEndpoint=https://endpoint.com -f "/home/test/scrape_config.yaml" --set enableCloudServices="aws-ec2|aws-ecs" 
Do you want to execute the helm command ?
(NOTE: Please make sure that you are connected to the right k8 cluster before running the helm command !) [y/n] :y

Example 2

  • The following metrics install-agent example generates commands to install an agent for a ecs-fargate source on aws cloud
caeops metrics install_agent --service-name "test-metrics" --cloud aws --source ecs-fargate --ecs-cluster-name demo-cluster --app-name "Test App"
Output

Instructions -> (string)

Step 1
------
1.0> Copy and save the generated task definition template to a local file. This template runs CloudAEye"s metrics agent as a task.
Edit the template to replace the placeholders with your app details

{
  "executionRoleArn": "${EXECUTION_ROLE_ARN}",
  "taskRoleArn": "${TASK_ROLE_ARN}",
  "containerDefinitions": [
    {
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "/ecs/aws-otel-collector",
          "awslogs-region": "us-east-2",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "command": [
        "--config=/etc/adot-collector-config/ecs-fargate-adot-config.yaml"
      ],
      "mountPoints": [
        {
          "containerPath": "/etc/adot-collector-config",
          "sourceVolume": "adot-config-volume"
        }
      ],
      "image": "public.ecr.aws/aws-observability/aws-otel-collector:latest",
      "dependsOn": [
        {
          "containerName": "adot-config",
          "condition": "COMPLETE"
        }
      ],
      "name": "aws-otel-collector"
    },
    {
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "/ecs/aws-otel-collector",
          "awslogs-region": "us-east-2",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "environment": [
        {
          "name": "FILENAME",
          "value": "/etc/adot-collector-config/ecs-fargate-adot-config.yaml"
        },
        {
          "name": "PROMETHEUS_ENDPOINT",
          "value": "https://metricsendpoint.com"
        },
        {
          "name": "PROMETHEUS_REGION",
          "value": "metrics-region"
        },
        {
          "name": "TARGET_HOST",
          "value": "${TARGET_HOST}"
        },
        {
          "name": "CAE_ACCESS_KEY_ID",
          "value": "somekey"
        },
        {
          "name": "CAE_SECRET_ACCESS_KEY",
          "value": "somesecret"
        },
        {
          "name": "TARGET_PORT",
          "value": "80"
        },
        {
          "name": "TARGET_URL",
          "value": "/metrics"
        }
      ],
      "mountPoints": [
        {
          "containerPath": "/etc/adot-collector-config",
          "sourceVolume": "adot-config-volume"
        }
      ],
      "image": "public.ecr.aws/cloudaeye/adot-config:latest",
      "name": "adot-config",
      "essential": false
    }
  ],
  "memory": "1024",
  "family": "cae-metrics-agent",
  "requiresCompatibilities": ["FARGATE"],
  "networkMode": "awsvpc",
  "cpu": "512",
  "volumes": [
    {
      "name": "adot-config-volume"
    }
  ]
}


Step 2
------
2.0> Now create/update your task definition (Make sure you have necessary AWS permissions)


aws ecs register-task-definition --cli-input-json file://TEMPLATE_DEFINITION_FILE.json


2.2> Run/update task with the above definition template (Make sure you have necessary AWS permissions)


aws ecs run-task --cluster demo-cluster --task-definition TASK_DEFINITION_NAME --network-configuration awsvpcConfiguration={subnets=[""],securityGroups=[""],assignPublicIp=""}
Back to top