Skip to content

Latest commit

 

History

History
93 lines (74 loc) · 3.78 KB

File metadata and controls

93 lines (74 loc) · 3.78 KB

logzio_metrics_rollup_rules

Provides a Logz.io metrics rollup rules resource. This allows you to manage metrics rollup rules in your Logz.io account.

Example Usage

Basic metric name-based rule

resource "logzio_metrics_rollup_rules" "cpu_usage_rollup" {
  account_id                = 123456
  metric_name               = "cpu_usage"
  metric_type               = "GAUGE"
  rollup_function           = "LAST"
  labels_elimination_method = "EXCLUDE_BY"
  labels                    = ["instance_id", "process_id"]
}

Filter-based rule with advanced features

resource "logzio_metrics_rollup_rules" "frontend_metrics_rollup" {
  account_id                = 123456
  name                      = "Frontend Service Metrics"
  metric_type               = "COUNTER"
  rollup_function           = "SUM"
  labels_elimination_method = "GROUP_BY"
  labels                    = ["service", "region"]
  
  filter {
    expression {
      comparison = "EQ"
      name       = "service"
      value      = "frontend"
    }
    expression {
      comparison = "REGEX_MATCH"
      name       = "region"
      value      = "us-.*"
    }
  }
  
  new_metric_name_template = "rollup.frontend.{{metricName}}"
  drop_original_metric     = true
}

MEASUREMENT metric type with statistical aggregation

resource "logzio_metrics_rollup_rules" "response_time_rollup" {
  account_id                = 123456
  metric_name               = "http_response_time"
  metric_type               = "MEASUREMENT"
  rollup_function           = "P95"
  labels_elimination_method = "EXCLUDE_BY"
  labels                    = ["endpoint", "method"]
}

Argument Reference

The following arguments are supported:

  • account_id - (Required) The metrics account ID for the metrics rollup rule.
  • metric_name - (Optional) The name of the metric for which to create the rollup rule. Either metric_name or filter must be specified, but not both.
  • metric_type - (Required) The type of the metric. Valid values are GAUGE, COUNTER, DELTA_COUNTER, CUMULATIVE_COUNTER, and MEASUREMENT.
  • rollup_function - The aggregation function to use for rolling up the metric. Required for all metric types. For COUNTER, DELTA_COUNTER, and CUMULATIVE_COUNTER types, must be SUM. For MEASUREMENT and GAUGE metric types, any valid aggregation function is allowed. Valid values include SUM, MIN, MAX, COUNT, LAST, MEAN, MEDIAN, STDEV, SUMSQ, and percentiles (P10, P20, P25, P30, P40, P50, P60, P70, P75, P80, P90, P95, P99, P999, P9999).
  • labels_elimination_method - (Required) The method for eliminating labels. Valid values are EXCLUDE_BY and GROUP_BY.
  • labels - (Required) A list of label names to be eliminated from the metric.
  • name - (Optional) A human-readable name for the rollup rule.
  • filter - (Optional) A filter block to match metrics by label values. Either metric_name or filter must be specified, but not both.
    • expression - (Required) A list of filter expressions.
      • comparison - (Required) The comparison operator. Valid values are EQ, NOT_EQ, REGEX_MATCH, and REGEX_NO_MATCH.
      • name - (Required) The label name to match against.
      • value - (Required) The value to match.
  • new_metric_name_template - (Optional) A template for generating new metric names. Use {{metricName}} to reference the original metric name.
  • drop_original_metric - (Optional) Whether to drop the original metric after creating the rollup. Defaults to false.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The ID of the metrics rollup rule.

Import

Metrics rollup rules can be imported using their ID:

terraform import logzio_metrics_rollup_rules.my_rollup_rule "rule_id"