-
Notifications
You must be signed in to change notification settings - Fork 606
Update: OTel Container Insights Lab #1901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kathanjit
wants to merge
27
commits into
aws-samples:main
Choose a base branch
from
oussama-mechlaoui:otlp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7f93718
v1
2291b04
feat(observability): Add OTLP metrics module with Grafana, AMP plugin…
2dc38fb
Adding doc for opentelemetry
3d1fed6
fix: correct invalid .mergify.yml empty rules (#1875)
svennam92 c346940
update: Q to kiro migration (#1871)
parth-pandit fc4d380
feat: Ack now use EKS capabilities (#1870)
MilanBavadiyaMB 5fec043
feat(observability): Add Query with PromQL in CloudWatch page
kiranprakash-aws 270a2d8
feat(observability): Add Query with PromQL in CloudWatch content
kiranprakash-aws aae69ea
Merge pull request #5 from oussama-mechlaoui/otlp
kathanjit dd8e3ce
Merge pull request #6 from kiranprakash-aws/otel
kathanjit 6210b7f
Merge pull request #3 from kathanjit/doc_update
oussama-mechlaoui ae25493
feat(observability): Add Query with PromQL in CloudWatch content
kiranprakash-aws d06d2dc
Merge pull request #4 from kiranprakash-aws/otel
oussama-mechlaoui 14b26fb
Merge pull request #7 from aws-samples/main
kathanjit aa7cabb
Modifying the document and merging all the docs for OpenTelemetry
4811eeb
Resolve merge conflicts
9e30d6c
Merge pull request #8 from oussama-mechlaoui/otlp
kathanjit 8253db7
Merging branches
b8a011f
Merge pull request #5 from kathanjit/doc_update
oussama-mechlaoui e345fed
feat(observability): Update PromQL page with validated queries and ap…
kiranprakash-aws 1dd3634
Merge pull request #6 from kiranprakash-aws/otel
kiranprakash-aws e2174d0
Fixing command links
39ec421
Merge pull request #7 from kathanjit/doc_update
kathanjit af72eff
Adding Images
ad3712a
Merge pull request #8 from kathanjit/doc_update
kathanjit 9dd30ca
fixing comments
40a5c45
Merge pull request #9 from kathanjit/doc_update
kathanjit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
manifests/modules/observability/otlp-metrics/.workshop/cleanup.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| logmessage "Cleaning up OTLP metrics resources..." | ||
|
|
||
| kubectl delete amazoncloudwatchagent application-metrics-collector -n amazon-cloudwatch --ignore-not-found | ||
| kubectl delete -n other pod load-generator --ignore-not-found | ||
|
|
||
| logmessage "Disabling OTel enrichment..." | ||
| aws cloudwatch stop-otel-enrichment 2>/dev/null || true | ||
|
|
||
| logmessage "Disabling resource tags on telemetry..." | ||
| aws observabilityadmin stop-telemetry-enrichment 2>/dev/null || true | ||
359 changes: 359 additions & 0 deletions
359
manifests/modules/observability/otlp-metrics/.workshop/terraform/main.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,359 @@ | ||
| data "aws_partition" "current" {} | ||
| data "aws_region" "current" {} | ||
|
|
||
| module "eks_blueprints_addons" { | ||
| source = "aws-ia/eks-blueprints-addons/aws" | ||
| version = "1.23.0" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we be hardcoding the version ? how is this in other infra files |
||
|
|
||
| cluster_name = var.addon_context.eks_cluster_id | ||
| cluster_endpoint = var.addon_context.aws_eks_cluster_endpoint | ||
| cluster_version = var.eks_cluster_version | ||
| oidc_provider_arn = var.addon_context.eks_oidc_provider_arn | ||
|
|
||
| enable_aws_load_balancer_controller = true | ||
| aws_load_balancer_controller = { | ||
| wait = true | ||
| role_name = "${var.addon_context.eks_cluster_id}-alb-controller" | ||
| policy_name = "${var.addon_context.eks_cluster_id}-alb-controller" | ||
| } | ||
|
|
||
| observability_tag = null | ||
| } | ||
|
|
||
| resource "aws_eks_addon" "pod_identity" { | ||
| cluster_name = var.addon_context.eks_cluster_id | ||
| addon_name = "eks-pod-identity-agent" | ||
| resolve_conflicts_on_create = "OVERWRITE" | ||
| preserve = false | ||
| } | ||
|
|
||
| # IAM role for the CloudWatch Observability add-on (Pod Identity) | ||
| resource "aws_iam_role" "cloudwatch_observability" { | ||
| name = "${var.addon_context.eks_cluster_id}-cw-observability" | ||
|
|
||
| assume_role_policy = jsonencode({ | ||
| Version = "2012-10-17" | ||
| Statement = [{ | ||
| Effect = "Allow" | ||
| Principal = { | ||
| Service = "pods.eks.amazonaws.com" | ||
| } | ||
| Action = ["sts:AssumeRole", "sts:TagSession"] | ||
| }] | ||
| }) | ||
|
|
||
| tags = var.tags | ||
| } | ||
|
|
||
| resource "aws_iam_role_policy_attachment" "cloudwatch_observability" { | ||
| role = aws_iam_role.cloudwatch_observability.name | ||
| policy_arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/CloudWatchAgentServerPolicy" | ||
| } | ||
|
|
||
| resource "aws_eks_pod_identity_association" "cloudwatch_observability" { | ||
| cluster_name = var.addon_context.eks_cluster_id | ||
| namespace = "amazon-cloudwatch" | ||
| service_account = "cloudwatch-agent" | ||
| role_arn = aws_iam_role.cloudwatch_observability.arn | ||
|
|
||
| depends_on = [aws_eks_addon.pod_identity] | ||
| } | ||
|
|
||
| resource "aws_eks_addon" "amazon_cloudwatch_observability" { | ||
| cluster_name = var.addon_context.eks_cluster_id | ||
| addon_name = "amazon-cloudwatch-observability" | ||
| resolve_conflicts_on_create = "OVERWRITE" | ||
|
|
||
| configuration_values = jsonencode({ | ||
| otelContainerInsights = { | ||
| enabled = true | ||
| logs = { | ||
| enabled = false | ||
| } | ||
| } | ||
| containerLogs = { | ||
| enabled = false | ||
| } | ||
| applicationSignals = { | ||
| enabled = false | ||
| } | ||
| }) | ||
|
|
||
| depends_on = [aws_eks_pod_identity_association.cloudwatch_observability] | ||
| } | ||
|
|
||
| # Enable resource tags on telemetry (account-level prerequisite for OTel enrichment) | ||
| resource "terraform_data" "telemetry_enrichment" { | ||
| provisioner "local-exec" { | ||
| command = "aws observabilityadmin start-telemetry-enrichment" | ||
| } | ||
| } | ||
|
|
||
| # Enable OTel enrichment for AWS vended metrics (makes them queryable via PromQL with resource tags) | ||
| resource "terraform_data" "otel_enrichment" { | ||
| depends_on = [terraform_data.telemetry_enrichment] | ||
|
|
||
| provisioner "local-exec" { | ||
| command = "aws cloudwatch start-otel-enrichment" | ||
| } | ||
| } | ||
|
|
||
| resource "time_sleep" "blueprints_addons_sleep" { | ||
| depends_on = [ | ||
| module.eks_blueprints_addons, | ||
| ] | ||
|
|
||
| create_duration = "15s" | ||
| } | ||
|
|
||
| # Grafana setup with CloudWatch OTLP metrics as Prometheus-compatible data source | ||
|
|
||
| resource "kubernetes_namespace" "grafana" { | ||
| metadata { | ||
| name = "grafana" | ||
| } | ||
| } | ||
|
|
||
| module "grafana" { | ||
| source = "aws-ia/eks-blueprints-addon/aws" | ||
| version = "1.1.1" | ||
|
|
||
| depends_on = [ | ||
| time_sleep.blueprints_addons_sleep, | ||
| kubernetes_config_map.order_service_metrics_dashboard | ||
| ] | ||
|
|
||
| description = "Grafana" | ||
| chart = "grafana" | ||
| chart_version = var.grafana_chart_version | ||
| namespace = kubernetes_namespace.grafana.metadata[0].name | ||
| create_namespace = false | ||
| repository = "https://grafana.github.io/helm-charts" | ||
| values = [local.grafana_values] | ||
| wait = true | ||
| set = [{ | ||
| name = "serviceAccount.name" | ||
| value = "grafana" | ||
| }] | ||
|
|
||
| create_role = true | ||
| role_name = "${var.addon_context.eks_cluster_id}-grafana" | ||
| policy_name = "${var.addon_context.eks_cluster_id}-grafana" | ||
| source_policy_documents = [data.aws_iam_policy_document.grafana.json] | ||
| set_irsa_names = [ | ||
| "serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn", | ||
| ] | ||
| oidc_providers = { | ||
| this = { | ||
| provider_arn = var.addon_context.eks_oidc_provider_arn | ||
| service_account = "grafana" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource "kubernetes_config_map" "order_service_metrics_dashboard" { | ||
| metadata { | ||
| name = "order-service-metrics-dashboard" | ||
| namespace = kubernetes_namespace.grafana.metadata[0].name | ||
|
|
||
| labels = { | ||
| grafana_dashboard = 1 | ||
| } | ||
| } | ||
|
|
||
| data = { | ||
| "order-service-metrics-dashboard.json" = <<EOF | ||
| { | ||
| "annotations": { | ||
| "list": [] | ||
| }, | ||
| "editable": true, | ||
| "panels": [ | ||
| { | ||
| "datasource": { | ||
| "type": "grafana-amazonprometheus-datasource", | ||
| "uid": "$${datasource}" | ||
| }, | ||
| "fieldConfig": { | ||
| "defaults": { | ||
| "color": { "mode": "palette-classic" }, | ||
| "custom": { "hideFrom": { "legend": false, "tooltip": false, "viz": false } }, | ||
| "mappings": [] | ||
| } | ||
| }, | ||
| "gridPos": { "h": 9, "w": 9, "x": 0, "y": 0 }, | ||
| "id": 2, | ||
| "options": { | ||
| "legend": { "displayMode": "list", "placement": "bottom", "showLegend": true }, | ||
| "pieType": "pie", | ||
| "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false } | ||
| }, | ||
| "targets": [ | ||
| { | ||
| "datasource": { "type": "grafana-amazonprometheus-datasource", "uid": "$${datasource}" }, | ||
| "editorMode": "code", | ||
| "expr": "sum by(productId) (watch_orders_total{productId!=\"*\"})", | ||
| "legendFormat": "__auto", | ||
| "range": true, | ||
| "refId": "A" | ||
| } | ||
| ], | ||
| "title": "Orders by Product", | ||
| "type": "piechart" | ||
| }, | ||
| { | ||
| "datasource": { | ||
| "type": "grafana-amazonprometheus-datasource", | ||
| "uid": "$${datasource}" | ||
| }, | ||
| "fieldConfig": { | ||
| "defaults": { | ||
| "color": { "mode": "thresholds" }, | ||
| "mappings": [], | ||
| "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] } | ||
| } | ||
| }, | ||
| "gridPos": { "h": 9, "w": 6, "x": 9, "y": 0 }, | ||
| "id": 6, | ||
| "options": { | ||
| "colorMode": "value", | ||
| "graphMode": "none", | ||
| "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false } | ||
| }, | ||
| "targets": [ | ||
| { | ||
| "datasource": { "type": "grafana-amazonprometheus-datasource", "uid": "$${datasource}" }, | ||
| "editorMode": "code", | ||
| "expr": "sum(watch_orders_total{productId=\"*\"}) by (productId)", | ||
| "legendFormat": "__auto", | ||
| "range": true, | ||
| "refId": "A" | ||
| } | ||
| ], | ||
| "title": "Order Count", | ||
| "type": "stat" | ||
| }, | ||
| { | ||
| "datasource": { | ||
| "type": "grafana-amazonprometheus-datasource", | ||
| "uid": "$${datasource}" | ||
| }, | ||
| "fieldConfig": { | ||
| "defaults": { | ||
| "color": { "mode": "palette-classic" }, | ||
| "custom": { | ||
| "drawStyle": "line", | ||
| "fillOpacity": 0, | ||
| "lineWidth": 1, | ||
| "pointSize": 5, | ||
| "showPoints": "auto" | ||
| }, | ||
| "mappings": [], | ||
| "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] } | ||
| } | ||
| }, | ||
| "gridPos": { "h": 8, "w": 15, "x": 0, "y": 9 }, | ||
| "id": 4, | ||
| "options": { | ||
| "legend": { "displayMode": "list", "placement": "bottom", "showLegend": true } | ||
| }, | ||
| "targets": [ | ||
| { | ||
| "datasource": { "type": "grafana-amazonprometheus-datasource", "uid": "$${datasource}" }, | ||
| "editorMode": "code", | ||
| "expr": "sum by (productId)(rate(watch_orders_total{productId=\"*\"}[2m]))", | ||
| "legendFormat": "__auto", | ||
| "range": true, | ||
| "refId": "A" | ||
| } | ||
| ], | ||
| "title": "Order Rate", | ||
| "type": "timeseries" | ||
| } | ||
| ], | ||
| "schemaVersion": 37, | ||
| "style": "dark", | ||
| "tags": [], | ||
| "templating": { | ||
| "list": [ | ||
| { | ||
| "current": {}, | ||
| "hide": 0, | ||
| "includeAll": false, | ||
| "label": "Data Source", | ||
| "multi": false, | ||
| "name": "datasource", | ||
| "options": [], | ||
| "query": "grafana-amazonprometheus-datasource", | ||
| "refresh": 1, | ||
| "regex": "", | ||
| "skipUrlSync": false, | ||
| "type": "datasource" | ||
| } | ||
| ] | ||
| }, | ||
| "time": { "from": "now-3h", "to": "now" }, | ||
| "title": "Order Service Metrics", | ||
| "uid": "otlp-orders", | ||
| "version": 1 | ||
| } | ||
| EOF | ||
| } | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "grafana" { | ||
| statement { | ||
| effect = "Allow" | ||
| resources = ["*"] | ||
| actions = [ | ||
| "cloudwatch:DescribeAlarmsForMetric", | ||
| "cloudwatch:GetMetricData", | ||
| "cloudwatch:ListMetrics", | ||
| "cloudwatch:QueryMetrics", | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| locals { | ||
| grafana_values = <<EOF | ||
| image: | ||
| tag: "12.1.7" | ||
|
|
||
| env: | ||
| AWS_SDK_LOAD_CONFIG: true | ||
| GF_AUTH_SIGV4_AUTH_ENABLED: true | ||
| GF_INSTALL_PLUGINS: grafana-amazonprometheus-datasource 3.0.0 | ||
|
|
||
| ingress: | ||
| enabled: true | ||
| hosts: [] | ||
| annotations: | ||
| alb.ingress.kubernetes.io/scheme: internet-facing | ||
| alb.ingress.kubernetes.io/target-type: ip | ||
| alb.ingress.kubernetes.io/inbound-cidrs: ${var.inbound_cidrs} | ||
| ingressClassName: alb | ||
|
|
||
| dashboardProviders: | ||
| dashboardproviders.yaml: | ||
| apiVersion: 1 | ||
| providers: | ||
| - name: orders-service | ||
| orgId: 1 | ||
| folder: "retail-app-metrics" | ||
| type: file | ||
| disableDeletion: false | ||
| editable: false | ||
| options: | ||
| path: /var/lib/grafana/dashboards/orders-service | ||
|
|
||
| dashboardsConfigMaps: | ||
| orders-service: "order-service-metrics-dashboard" | ||
|
|
||
| sidecar: | ||
| dashboards: | ||
| enabled: true | ||
| searchNamespace: ALL | ||
| label: app.kubernetes.io/component | ||
| labelValue: grafana | ||
| EOF | ||
| } | ||
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dindt see in any module where the cleanup is referenced. I see that in the Readme. Usually at the end of each lap we explicity ask them to run cleanup.