AWS / Cloud / How To / Kubernetes
https://aws.amazon.com/prometheus
Hi everyone! Here i am setting up Amazon Managed Service for Prometheus (AMP) to monitor my AWS EKS. Sharing the journey to and steps to provision AMP below:
Amazon Managed Service for Prometheus (AMP) is an AWS fully-managed monitoring and alerting service which is 100% compatible with Prometheus that makes it easy to monitor containerized applications and infrastructure at scale.
AMP supports the same metrics, the same PromQL queries, and can also make use of the 150+ Prometheus exporters. AMP runs across multiple Availability Zones for high availability, and is powered by CNCF Cortex for horizontal scalability. AMP will easily scale to ingest, store, and query millions of time series metrics.
The unique architecture for Amazon Managed Prometheus (AMP) is that you will still require a Prometheus server (deployment pod) which retrieve metrics/data from AWS EKS API and pushes those data to Amazon Managed Prometheus (AMP).
Prerequisite:
Enable service accounts to access AWS resources in three steps
1. Create an IAM OIDC provider for your cluster – You only need to do this once for a cluster.
2. Create an IAM role and attach an IAM policy to it with the permissions that your service accounts need – We recommend creating separate roles for each unique collection of permissions that pods need.
3. Associate an IAM role with a service account – Complete this task for each Kubernetes service account that needs access to AWS resources.
From the steps above, what you are performing is to create an AWS IAM role with attached IAM policy to be associated to a Kubernetes service account.
AWS Console > AWS AMP > Create a AWS Prometheus workspace (eg. Prometheus-Workspace )
Amazon Managed Service for Prometheus does not directly scrape operational metrics from containerized workloads in a Kubernetes cluster. It requires users to deploy and manage a standard Prometheus server.
Set the following environment variables before deploying the helm chart :
IAM_PROXY_PROMETHEUS_ROLE_ARN=arn:aws:iam::<AWS-Account-ID>:role/<EKS-AMP-ServiceAccount-Role>
WORKSPACE_ID=<AWS Prometheus Workspace ID>
AWS_REGION=<your AWS account region>
Now create a file called ‘amp_ingest_override_values.yaml‘ with the following content in it:
‘iamproxy-service-account‘ is the newly created Kubernetes service account
The following code below is a set of default values for prometheus server helm chart which enable remoteWrite to AMP:
#amp_ingest_override_values.yaml
serviceAccounts:
## Disable alert manager roles
##
server:
name: "iamproxy-service-account"
alertmanager:
create: false
## Disable pushgateway
##
pushgateway:
create: false
server:
remoteWrite:
-
queue_config:
max_samples_per_send: 1000
max_shards: 200
capacity: 2500
## Use a statefulset instead of a deployment for resiliency
##
statefulSet:
enabled: true
## Store blocks locally for short time period only
##
retention: 1h
## Disable alert manager
##
alertmanager:
enabled: false
## Disable pushgateway
##
pushgateway:
enabled: false
Deploy the helm chart:
kubectl apply -f amp_ingest_override_values.yaml
Now we can deploy the Prometheus server (Pod) after you have set the configuration:
helm repo add prometheus-community https://prometheus-community.github.io/helm-chart
kubectl create ns prometheus
helm install prometheus-for-amp prometheus-community/prometheus -n prometheus -f ./amp_ingest_override_values.yaml \
--set serviceAccounts.server.annotations."eks\.amazonaws\.com/role-arn"="${IAM_PROXY_PROMETHEUS_ROLE_ARN}" \
--set server.remoteWrite[0].url="https://aps-workspaces.${AWS_REGION}.amazonaws.com/workspaces/${WORKSPACE_ID}/api/v1/remote_write" \
--set server.remoteWrite[0].sigv4.region=${AWS_REGION}
Now check the Service account in Kubernetes (AWS EKS):
kubectl get ServiceAccount -A
kubectl get pods --all-namespaces
Enter the following code to deploy Grafana pods in your AWS EKS cluster :
#Add Grafana helm chart rep
helm repo add grafana https://grafana.github.io/helm-charts
#Create a Grafana namespace
kubectl create ns grafana
#Install Grafana for AMP
helm install grafana-for-amp grafana/grafana -n grafana
#Check the Grafana pods
kubectl get pods --all-namespaces
#amp_query_override_values.yaml
serviceAccount
name: "iamproxy-service-account"
annotations:
eks.amazonaws.com/role-arn: "${IAM_PROXY_PROMETHEUS_ROLE_ARN}"
grafana.ini:
auth:
sigv4_auth_enabled: true:
helm upgrade --install grafana-for-amp grafana/grafana -n grafana -f ./amp_query_override_values.yaml
Port forward Grafana deployment so we can access the UI from our browser:
#Check Grafana pods
kubectl get pods --all-namespaces
#Port forward Grafana so we can access the dashboard UI from our browser port 5001
kubectl port-forward -n grafana pods/<grafana pod name> 5001:3000
Get the default Grafana admin password:
kubectl get secrets grafana-for-amp -n grafana -o jsonpath='{.data.admin-password}'|base64 --decode
2. Input the AWS AMP Workspace query URL under HTTP/URL
3. Turn on SigV4 auth
4. Change default region of the AMP and AWS EKS cluster resides in
5. Lastly, Save & Test the data source. (Ensure the tick and Data source is working)
Credits/References:
Disclaimer:
The views expressed and the content shared in all published articles on this website are solely those of the respective authors, and they do not necessarily reflect the views of the author’s employer or the techbeatly platform. We strive to ensure the accuracy and validity of the content published on our website. However, we cannot guarantee the absolute correctness or completeness of the information provided. It is the responsibility of the readers and users of this website to verify the accuracy and appropriateness of any information or opinions expressed within the articles. If you come across any content that you believe to be incorrect or invalid, please contact us immediately so that we can address the issue promptly.
Tags: AWS · Monitoring
Tan Kai Jian
Schnauzer Lover | Amazon Web Services | Microsoft Azure | An individual passionate in commercial cloud - design, operations & ever changing automation on infrastructure. Evergreen learning is what i believe , it is a journey not a destination
This site uses Akismet to reduce spam. Learn how your comment data is processed.1 Response
Leave a Reply Cancel reply
[…] on the previous article of setting up Amazon Managed Service for Prometheus (AMP) with open source Grafana , we will now be provisioning Amazon Managed Grafana to integrated with […]