Skip to content

Commit 47191e4

Browse files
committed
adding nginx module
1 parent 6564853 commit 47191e4

File tree

10 files changed

+280
-0
lines changed

10 files changed

+280
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Observability Pattern for Nginx
2+
3+
This module provides an automated experience around Observability for Nginx workloads.
4+
It provides the following resources:
5+
6+
- AWS Distro For OpenTelemetry Operator and Collector
7+
- AWS Managed Grafana Dashboard and data source
8+
- Alerts and recording rules with AWS Managed Service for Prometheus
9+
10+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
11+
## Requirements
12+
13+
| Name | Version |
14+
|------|---------|
15+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
16+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72 |
17+
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.10 |
18+
19+
## Providers
20+
21+
| Name | Version |
22+
|------|---------|
23+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.72 |
24+
25+
## Modules
26+
27+
| Name | Source | Version |
28+
|------|--------|---------|
29+
| <a name="module_helm_addon"></a> [helm\_addon](#module\_helm\_addon) | ../helm-addon | n/a |
30+
31+
## Resources
32+
33+
| Name | Type |
34+
|------|------|
35+
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
36+
37+
## Inputs
38+
39+
| Name | Description | Type | Default | Required |
40+
|------|-------------|------|---------|:--------:|
41+
| <a name="input_addon_context"></a> [addon\_context](#input\_addon\_context) | Input configuration for the addon | <pre>object({<br> aws_caller_identity_account_id = string<br> aws_caller_identity_arn = string<br> aws_eks_cluster_endpoint = string<br> aws_partition_id = string<br> aws_region_name = string<br> eks_cluster_id = string<br> eks_oidc_issuer_url = string<br> eks_oidc_provider_arn = string<br> irsa_iam_permissions_boundary = string<br> irsa_iam_role_path = string<br> tags = map(string)<br> })</pre> | n/a | yes |
42+
| <a name="input_amazon_prometheus_workspace_endpoint"></a> [amazon\_prometheus\_workspace\_endpoint](#input\_amazon\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus Workspace Endpoint | `string` | `null` | no |
43+
| <a name="input_amazon_prometheus_workspace_region"></a> [amazon\_prometheus\_workspace\_region](#input\_amazon\_prometheus\_workspace\_region) | Amazon Managed Prometheus Workspace's Region | `string` | `null` | no |
44+
| <a name="input_helm_config"></a> [helm\_config](#input\_helm\_config) | Helm Config for Prometheus | `any` | `{}` | no |
45+
46+
## Outputs
47+
48+
No outputs.
49+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
locals {
2+
name = "adot-collector-nginx"
3+
namespace = try(var.helm_config.namespace, local.name)
4+
}
5+
6+
data "aws_partition" "current" {}
7+
8+
module "helm_addon" {
9+
source = "../helm-addon"
10+
11+
helm_config = merge(
12+
{
13+
name = local.name
14+
chart = "${path.module}/otel-config"
15+
version = "0.2.0"
16+
namespace = local.namespace
17+
description = "ADOT helm Chart deployment configuration"
18+
},
19+
var.helm_config
20+
)
21+
22+
set_values = [
23+
{
24+
name = "ampurl"
25+
value = "${var.amazon_prometheus_workspace_endpoint}api/v1/remote_write"
26+
},
27+
{
28+
name = "region"
29+
value = var.amazon_prometheus_workspace_region
30+
},
31+
{
32+
name = "prometheusMetricsEndpoint"
33+
value = "metrics"
34+
},
35+
{
36+
name = "prometheusMetricsPort"
37+
value = 8888
38+
},
39+
{
40+
name = "scrapeInterval"
41+
value = "15s"
42+
},
43+
{
44+
name = "scrapeTimeout"
45+
value = "10s"
46+
},
47+
{
48+
name = "scrapeSampleLimit"
49+
value = 1000
50+
}
51+
]
52+
53+
irsa_config = {
54+
create_kubernetes_namespace = try(var.helm_config["create_namespace"], true)
55+
kubernetes_namespace = local.namespace
56+
create_kubernetes_service_account = true
57+
kubernetes_service_account = try(var.helm_config.service_account, local.name)
58+
irsa_iam_policies = ["arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonPrometheusRemoteWriteAccess"]
59+
}
60+
61+
addon_context = var.addon_context
62+
}

modules/add-ons/adot-collector-nginx/outputs.tf

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
variable "helm_config" {
2+
description = "Helm Config for Prometheus"
3+
type = any
4+
default = {}
5+
}
6+
7+
variable "amazon_prometheus_workspace_endpoint" {
8+
description = "Amazon Managed Prometheus Workspace Endpoint"
9+
type = string
10+
default = null
11+
}
12+
13+
variable "amazon_prometheus_workspace_region" {
14+
description = "Amazon Managed Prometheus Workspace's Region"
15+
type = string
16+
default = null
17+
}
18+
19+
variable "addon_context" {
20+
description = "Input configuration for the addon"
21+
type = object({
22+
aws_caller_identity_account_id = string
23+
aws_caller_identity_arn = string
24+
aws_eks_cluster_endpoint = string
25+
aws_partition_id = string
26+
aws_region_name = string
27+
eks_cluster_id = string
28+
eks_oidc_issuer_url = string
29+
eks_oidc_provider_arn = string
30+
irsa_iam_permissions_boundary = string
31+
irsa_iam_role_path = string
32+
tags = map(string)
33+
})
34+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_version = ">= 1.0.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 3.72"
8+
}
9+
kubernetes = {
10+
source = "hashicorp/kubernetes"
11+
version = ">= 2.10"
12+
}
13+
}
14+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: opentelemetry
3+
description: A Helm chart to install otel operator
4+
type: application
5+
version: 0.2.0
6+
appVersion: v0.1.0
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: otel-prometheus-role
5+
rules:
6+
- apiGroups:
7+
- ""
8+
resources:
9+
- nodes
10+
- nodes/proxy
11+
- services
12+
- endpoints
13+
- pods
14+
verbs:
15+
- get
16+
- list
17+
- watch
18+
- apiGroups:
19+
- extensions
20+
resources:
21+
- ingresses
22+
verbs:
23+
- get
24+
- list
25+
- watch
26+
- nonResourceURLs:
27+
- /metrics
28+
verbs:
29+
- get
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: otel-prometheus-role-binding
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: ClusterRole
8+
name: otel-prometheus-role
9+
subjects:
10+
- kind: ServiceAccount
11+
name: adot-collector-nginx
12+
namespace: adot-collector-nginx
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
apiVersion: opentelemetry.io/v1alpha1
2+
kind: OpenTelemetryCollector
3+
metadata:
4+
name: adot
5+
spec:
6+
image: public.ecr.aws/aws-observability/aws-otel-collector:latest
7+
mode: deployment
8+
serviceAccount: adot-collector-nginx
9+
config: |
10+
receivers:
11+
prometheus:
12+
config:
13+
global:
14+
scrape_interval: {{ .Values.scrapeInterval }}
15+
scrape_timeout: {{ .Values.scrapeTimeout }}
16+
17+
scrape_configs:
18+
- job_name: 'kubernetes-pod-nginx'
19+
sample_limit: {{ .Values.scrapeSampleLimit }}
20+
metrics_path: /{{ .Values.prometheusMetricsEndpoint }}
21+
kubernetes_sd_configs:
22+
- role: pod
23+
relabel_configs:
24+
- source_labels: [ __address__ ]
25+
action: keep
26+
regex: '.*:9404$'
27+
- action: labelmap
28+
regex: __meta_kubernetes_pod_label_(.+)
29+
- action: replace
30+
source_labels: [ __meta_kubernetes_namespace ]
31+
target_label: Namespace
32+
- source_labels: [ __meta_kubernetes_pod_name ]
33+
action: replace
34+
target_label: pod_name
35+
- action: replace
36+
source_labels: [ __meta_kubernetes_pod_container_name ]
37+
target_label: container_name
38+
- action: replace
39+
source_labels: [ __meta_kubernetes_pod_controller_kind ]
40+
target_label: pod_controller_kind
41+
- action: replace
42+
source_labels: [ __meta_kubernetes_pod_phase ]
43+
target_label: pod_controller_phase
44+
metric_relabel_configs:
45+
- source_labels: [ __name__ ]
46+
regex: 'jvm_gc_collection_seconds.*'
47+
action: drop
48+
exporters:
49+
awsprometheusremotewrite:
50+
endpoint: {{ .Values.ampurl }}
51+
aws_auth:
52+
region: {{ .Values.region }}
53+
service: "aps"
54+
logging:
55+
loglevel: info
56+
extensions:
57+
health_check:
58+
pprof:
59+
endpoint: :1888
60+
zpages:
61+
endpoint: :55679
62+
service:
63+
extensions: [pprof, zpages, health_check]
64+
pipelines:
65+
metrics:
66+
receivers: [prometheus]
67+
exporters: [logging, awsprometheusremotewrite]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ampurl: ${amp_url}
2+
region: ${region}
3+
prometheusMetricsEndpoint: ${prometheus_metrics_endpoint}
4+
prometheusMetricsPort: ${prometheus_metrics_port}
5+
scrapeInterval: ${scrape_interval}
6+
scrapeTimeout: ${scrape_timeout}
7+
scrapeSampleLimit: ${scrape_sample_limit}

0 commit comments

Comments
 (0)