Skip to content
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

docs: remove metric_condition, add composite alert examples #197

Merged
merged 6 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
65 changes: 63 additions & 2 deletions docs/resources/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Provides a [Lightstep alert](https://api-docs.lightstep.com/reference/listalerts

Visit [Lightstep's documentation](https://docs.lightstep.com/docs/about-alerts) for conceptual information about alerts and alert templates.

## Example Usage
## Example Usage (single alert)

```hcl
resource "lightstep_alert" "beemo-requests" {
project_name = var.project
name = "Frontend latency"

expression {
is_multi = true
is_multi = false
is_no_data = true
operand = "above"
thresholds {
Expand All @@ -46,6 +46,67 @@ EOT
}
```

## Example Usage (composite alert)

```hcl
resource "lightstep_alert" "high_error_rate_with_sustained_traffic" {
project_name = var.project
name = "Error rates are high for my operation with sustained traffic"
description = <<EOF
Fires when over 20% of requests are erroring, but only when requests are above 75 spans over an hour window. This prevents firing when we have very low traffic and get a few error requests.
EOF

label {
key = "team"
value = "my_team"
}
composite_alert {
alert {
name = "A"
title = "Span Error %"
expression {
operand = "above"
thresholds {
critical = 20
}
}
query {
hidden = false
query_name = "a"
query_string = "with\n\terrors = spans count | delta 1h | filter my_tag == my_value && error == true | group_by [], sum;\n\ttotal = spans count | delta 1h | filter my_tag == my_value | group_by [], sum;\njoin 100*errors / total, errors=0, total=0"
display = "line"
hidden_queries = {
"a" = false
}
}
}

alert {
name = "B"
title = "Span Count"
query {
hidden = false
query_name = "a"
query_string = "spans count | delta 1h | filter my_tag == my_value | group_by [], sum"
display = "line"
hidden_queries = {
"a" = false
}
}
expression {
operand = "above"
thresholds {
critical = 75
}
}
}
}
alerting_rule {
id = lightstep_pagerduty_destination.my_destination.id
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

Expand Down
79 changes: 0 additions & 79 deletions docs/resources/metric_condition.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,85 +12,6 @@ description: |-
Provides a Lightstep Metric Condition. Use this resource to create and manage Lightstep Metric Conditions that can contain either
metric queries or span queries.

## Example Usage (metric query)

```hcl
resource "lightstep_metric_condition" "beemo-requests" {
project_name = var.project
name = "Beemo Low Requests"

label {
key = "team"
value = "ontology"
}

label {
value = "custom-label"
}

expression {
is_multi = true
is_no_data = true
operand = "below"
thresholds {
warning = 10.0
critical = 5.0
}
}

metric_query {
metric = "requests"
query_name = "a"
timeseries_operator = "delta"
timeseries_operator_input_window_ms = 30000
hidden = false
display = "line"

include_filters = [
{
key = "kube_instance"
value = "3"
}
]

group_by {
aggregation_method = "max"
keys = ["key1", "key2"]
}
}
```

## Example Usage (span query)

```hcl
resource "lightstep_metric_condition" "beemo-requests" {
project_name = var.project
name = "Frontend latency"

expression {
is_multi = true
is_no_data = true
operand = "above"
thresholds {
warning = 5.0
critical = 10.0
}
}

metric_query {
query_name = "a"
hidden = false
display = "line"

spans {
query = "service IN (\"frontend\")"
operator = "latency"
operator_input_window_ms = 3600000
latency_percentiles = [50]
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

Expand Down
65 changes: 63 additions & 2 deletions templates/resources/alert.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Provides a [Lightstep alert](https://api-docs.lightstep.com/reference/listalerts

Visit [Lightstep's documentation](https://docs.lightstep.com/docs/about-alerts) for conceptual information about alerts and alert templates.

## Example Usage
## Example Usage (single alert)

```hcl
resource "lightstep_alert" "beemo-requests" {
project_name = var.project
name = "Frontend latency"

expression {
is_multi = true
is_multi = false
is_no_data = true
operand = "above"
thresholds {
Expand All @@ -46,4 +46,65 @@ EOT
}
```

## Example Usage (composite alert)

```hcl
resource "lightstep_alert" "high_error_rate_with_sustained_traffic" {
project_name = var.project
name = "Error rates are high for my operation with sustained traffic"
description = <<EOF
Fires when over 20% of requests are erroring, but only when requests are above 75 spans over an hour window. This prevents firing when we have very low traffic and get a few error requests.
EOF

label {
key = "team"
value = "my_team"
}
composite_alert {
alert {
name = "A"
title = "Span Error %"
expression {
operand = "above"
thresholds {
critical = 20
}
}
query {
hidden = false
query_name = "a"
query_string = "with\n\terrors = spans count | delta 1h | filter my_tag == my_value && error == true | group_by [], sum;\n\ttotal = spans count | delta 1h | filter my_tag == my_value | group_by [], sum;\njoin 100*errors / total, errors=0, total=0"
display = "line"
hidden_queries = {
"a" = false
}
}
}

alert {
name = "B"
title = "Span Count"
query {
hidden = false
query_name = "a"
query_string = "spans count | delta 1h | filter my_tag == my_value | group_by [], sum"
display = "line"
hidden_queries = {
"a" = false
}
}
expression {
operand = "above"
thresholds {
critical = 75
}
}
}
}
alerting_rule {
id = lightstep_pagerduty_destination.my_destination.id
}
}
```

{{ .SchemaMarkdown | trimspace }}
79 changes: 0 additions & 79 deletions templates/resources/metric_condition.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,83 +12,4 @@ description: |-
Provides a Lightstep Metric Condition. Use this resource to create and manage Lightstep Metric Conditions that can contain either
metric queries or span queries.

## Example Usage (metric query)

```hcl
resource "lightstep_metric_condition" "beemo-requests" {
project_name = var.project
name = "Beemo Low Requests"

label {
key = "team"
value = "ontology"
}

label {
value = "custom-label"
}

expression {
is_multi = true
is_no_data = true
operand = "below"
thresholds {
warning = 10.0
critical = 5.0
}
}

metric_query {
metric = "requests"
query_name = "a"
timeseries_operator = "delta"
timeseries_operator_input_window_ms = 30000
hidden = false
display = "line"

include_filters = [
{
key = "kube_instance"
value = "3"
}
]

group_by {
aggregation_method = "max"
keys = ["key1", "key2"]
}
}
```

## Example Usage (span query)

```hcl
resource "lightstep_metric_condition" "beemo-requests" {
project_name = var.project
name = "Frontend latency"

expression {
is_multi = true
is_no_data = true
operand = "above"
thresholds {
warning = 5.0
critical = 10.0
}
}

metric_query {
query_name = "a"
hidden = false
display = "line"

spans {
query = "service IN (\"frontend\")"
operator = "latency"
operator_input_window_ms = 3600000
latency_percentiles = [50]
}
}
```

{{ .SchemaMarkdown | trimspace }}