Skip to content

feat: support prometheus scrape configuration in sysdig-agent #610

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ You need the following permissions to run this module.
| <a name="input_cloud_monitoring_enabled"></a> [cloud\_monitoring\_enabled](#input\_cloud\_monitoring\_enabled) | Deploy IBM Cloud Monitoring agent | `bool` | `true` | no |
| <a name="input_cloud_monitoring_endpoint_type"></a> [cloud\_monitoring\_endpoint\_type](#input\_cloud\_monitoring\_endpoint\_type) | Specify the IBM Cloud Monitoring instance endpoint type (public or private) to use. Used to construct the ingestion endpoint. | `string` | `"private"` | no |
| <a name="input_cloud_monitoring_instance_region"></a> [cloud\_monitoring\_instance\_region](#input\_cloud\_monitoring\_instance\_region) | The IBM Cloud Monitoring instance region. Used to construct the ingestion endpoint. | `string` | `null` | no |
| <a name="input_cloud_monitoring_prometheus_scrape_configs"></a> [cloud_monitoring_prometheus_scrape_configs](#input_cloud_monitoring_prometheus_scrape_configs) | Optional multi-line YAML string to customize Prometheus scraping behavior, including relabeling, TLS settings, and target selection. Provide the full `scrape_configs` YAML block as a string. | `string` | `""` | no |
| <a name="input_cloud_monitoring_metrics_filter"></a> [cloud\_monitoring\_metrics\_filter](#input\_cloud\_monitoring\_metrics\_filter) | To filter custom metrics, specify the Cloud Monitoring metrics to include or to exclude. See https://cloud.ibm.com/docs/monitoring?topic=monitoring-change_kube_agent#change_kube_agent_inc_exc_metrics. | <pre>list(object({<br/> type = string<br/> name = string<br/> }))</pre> | `[]` | no |
| <a name="input_cloud_monitoring_secret_name"></a> [cloud\_monitoring\_secret\_name](#input\_cloud\_monitoring\_secret\_name) | The name of the secret which will store the access key. | `string` | `"sysdig-agent"` | no |
| <a name="input_cluster_config_endpoint_type"></a> [cluster\_config\_endpoint\_type](#input\_cluster\_config\_endpoint\_type) | Specify which type of endpoint to use for for cluster config access: 'default', 'private', 'vpe', 'link'. 'default' value will use the default endpoint of the cluster. | `string` | `"default"` | no |
Expand Down
5 changes: 5 additions & 0 deletions chart/sysdig-agent/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ data:
{{ $c.parameter }}: {{ $c.name }}
{{ end }}
{{- end -}}

{{- if .Values.prometheus_scrape_configs }}
prometheus.yaml: |
{{ .Values.prometheus_scrape_configs | indent 4 }}
{{- end }}
22 changes: 22 additions & 0 deletions chart/sysdig-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,25 @@ container_filter: []
# container.name: my-java-app
# - exclude:
# kubernetes.namespace.name: kube-system

# Prometheus scrape_configs override
prometheus_scrape_configs: ""
# example Prometheus scrape_configs YAML
# scrape_configs:
# - job_name: 'k8s-pods'
# tls_config:
# insecure_skip_verify: true
# kubernetes_sd_configs:
# - role: pod
# relabel_configs:
# - action: keep
# source_labels: [__meta_kubernetes_pod_host_ip]
# regex: __HOSTIPS__
# - action: keep
# source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
# regex: true
# metric_relabel_configs:
# - source_labels: [__name__]
# regex: (ClickHouseMetrics_DistributedFilesToInsert)
# action: keep

3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ resource "helm_release" "cloud_monitoring_agent" {
tolerations = var.cloud_monitoring_agent_tolerations
}), yamlencode({
container_filter = var.cloud_monitoring_container_filter
}), yamlencode({
prometheus_scrape_configs = var.cloud_monitoring_prometheus_scrape_configs
})]


provisioner "local-exec" {
command = "${path.module}/scripts/confirm-rollout-status.sh ${var.cloud_monitoring_agent_name} ${var.cloud_monitoring_agent_namespace}"
interpreter = ["/bin/bash", "-c"]
Expand Down
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ variable "cloud_monitoring_metrics_filter" {
}
}

variable "cloud_monitoring_prometheus_scrape_configs" {
description = "Optional multi-line YAML string defining Prometheus scrape_configs to be injected into the Sysdig agent's configuration ConfigMap under prometheus.yaml. This allows customization of Prometheus scraping behavior, including relabeling, TLS settings, and target selection. Provide the full scrape_configs YAML block as a string."
type = string
default = ""
}


variable "cloud_monitoring_container_filter" {
type = list(object({
type = string
Expand Down