docs/sources/as-code/infrastructure-as-code/terraform/terraform-knowledge-graph/profile-configurations.md
Profile configurations in Knowledge Graph allow you to define how continuous profiling data is queried and correlated with entities. You can specify data sources, entity matching rules, and label mappings for performance profiling.
For information about configuring profile correlation in the Knowledge Graph UI, refer to Configure profiles correlation.
Create a file named profile-configs.tf and add the following:
# Basic profile configuration for services
resource "grafana_asserts_profile_config" "production" {
provider = grafana.asserts
name = "production"
priority = 1000
default_config = false
data_source_uid = "grafanacloud-profiles"
match {
property = "asserts_entity_type"
op = "="
values = ["Service"]
}
match {
property = "deployment_environment"
op = "="
values = ["production", "staging"]
}
entity_property_to_profile_label_mapping = {
"cluster" = "k8s_cluster_name"
"namespace" = "k8s_namespace_name"
"container" = "k8s_container_name"
"otel_service" = "service_name"
"otel_namespace" = "service_namespace"
}
}
Configure profile correlation with multiple entity matching criteria:
# Development environment profile configuration
resource "grafana_asserts_profile_config" "development" {
provider = grafana.asserts
name = "development"
priority = 2000
default_config = false
data_source_uid = "pyroscope-dev"
match {
property = "asserts_entity_type"
op = "="
values = ["Service"]
}
match {
property = "deployment_environment"
op = "="
values = ["development", "testing"]
}
match {
property = "asserts_site"
op = "="
values = ["us-east-1"]
}
match {
property = "service"
op = "="
values = ["api"]
}
entity_property_to_profile_label_mapping = {
"cluster" = "k8s_cluster_name"
"namespace" = "k8s_namespace_name"
"container" = "k8s_container_name"
"otel_service" = "service_name"
"otel_namespace" = "service_namespace"
"pod" = "k8s_pod_name"
}
}
Create a minimal configuration for all entities:
# Minimal configuration for all entities
resource "grafana_asserts_profile_config" "minimal" {
provider = grafana.asserts
name = "minimal"
priority = 3000
default_config = false
data_source_uid = "pyroscope-minimal"
match {
property = "asserts_entity_type"
op = "IS NOT NULL"
values = []
}
entity_property_to_profile_label_mapping = {
"cluster" = "k8s_cluster_name"
"otel_service" = "service_name"
"otel_namespace" = "service_namespace"
}
}
Configure profiles with multiple operations and advanced match rules:
# Advanced configuration with multiple operations
resource "grafana_asserts_profile_config" "advanced" {
provider = grafana.asserts
name = "advanced"
priority = 1500
default_config = false
data_source_uid = "pyroscope-advanced"
match {
property = "service_type"
op = "CONTAINS"
values = ["web", "api"]
}
match {
property = "deployment_environment"
op = "<>"
values = ["test"]
}
match {
property = "team"
op = "IS NOT NULL"
values = []
}
match {
property = "cpu_threshold"
op = ">="
values = ["80"]
}
entity_property_to_profile_label_mapping = {
"service_type" = "service_type"
"team" = "team_owner"
"environment" = "deployment_env"
"version" = "app_version"
"region" = "cloud_region"
"node" = "k8s_node_name"
}
}
grafana_asserts_profile_configManage Knowledge Graph profile configurations through the Grafana API.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The name of the profile configuration. This field is immutable and forces recreation if changed. |
priority | number | Yes | Priority of the profile configuration. A lower number means a higher priority. |
default_config | bool | Yes | Whether this is the default configuration. Default configurations cannot be deleted. |
data_source_uid | string | Yes | DataSource UID to be queried (for example, a Pyroscope instance). |
match | list(object) | No | List of match rules for entity properties. Refer to match block for details. |
entity_property_to_profile_label_mapping | map(string) | No | Mapping of entity properties to profile labels for correlation. |
Each match block supports the following:
| Name | Type | Required | Description |
|---|---|---|---|
property | string | Yes | Entity property to match against. |
op | string | Yes | Operation to use for matching. One of: =, <>, <, >, <=, >=, IS NULL, IS NOT NULL, STARTS WITH, CONTAINS. |
values | list(string) | Yes | Values to match against. Can be empty for IS NULL and IS NOT NULL operations. |
resource "grafana_asserts_profile_config" "example" {
provider = grafana.asserts
name = "example-profiles"
priority = 1000
default_config = false
data_source_uid = "pyroscope-prod"
match {
property = "asserts_entity_type"
op = "="
values = ["Service", "Pod"]
}
match {
property = "deployment_environment"
op = "STARTS WITH"
values = ["prod"]
}
entity_property_to_profile_label_mapping = {
"service" = "service_name"
"namespace" = "k8s_namespace_name"
"environment" = "deployment_env"
"cluster" = "k8s_cluster_name"
"container" = "k8s_container_name"
}
}
Consider the following best practices when configuring profile correlation with Terraform.
<, >, <=, >=) for numeric thresholds or performance-based filteringAfter applying the Terraform configuration, verify that: