-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Grafana Cloud Fleet Management (#1989)
- Loading branch information
1 parent
39ecb81
commit 683e6c1
Showing
53 changed files
with
3,123 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "grafana_fleet_management_collector Resource - terraform-provider-grafana" | ||
subcategory: "Fleet Management" | ||
description: |- | ||
Manages Grafana Fleet Management collectors. | ||
Official documentation https://grafana.com/docs/grafana-cloud/send-data/fleet-management/API documentation https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api/ | ||
Note: Fleet Management is in public preview https://grafana.com/docs/release-life-cycle/#public-preview and this resource is experimental. Grafana Labs offers limited support, and breaking changes might occur. | ||
Required access policy scopes: | ||
fleet-management:readfleet-management:write | ||
--- | ||
|
||
# grafana_fleet_management_collector (Resource) | ||
|
||
Manages Grafana Fleet Management collectors. | ||
|
||
* [Official documentation](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/) | ||
* [API documentation](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api/) | ||
|
||
**Note:** Fleet Management is in [public preview](https://grafana.com/docs/release-life-cycle/#public-preview) and this resource is experimental. Grafana Labs offers limited support, and breaking changes might occur. | ||
|
||
Required access policy scopes: | ||
|
||
* fleet-management:read | ||
* fleet-management:write | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "grafana_fleet_management_collector" "test" { | ||
id = "my_collector" | ||
remote_attributes = { | ||
"env" = "PROD", | ||
"owner" = "TEAM-A" | ||
} | ||
enabled = true | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `id` (String) ID of the collector | ||
|
||
### Optional | ||
|
||
- `enabled` (Boolean) Whether the collector is enabled or not | ||
- `remote_attributes` (Map of String) Remote attributes for the collector | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
terraform import grafana_fleet_management_collector.name "{{ id }}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "grafana_fleet_management_pipeline Resource - terraform-provider-grafana" | ||
subcategory: "Fleet Management" | ||
description: |- | ||
Manages Grafana Fleet Management pipelines. | ||
Official documentation https://grafana.com/docs/grafana-cloud/send-data/fleet-management/API documentation https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/pipeline-api/ | ||
Note: Fleet Management is in public preview https://grafana.com/docs/release-life-cycle/#public-preview and this resource is experimental. Grafana Labs offers limited support, and breaking changes might occur. | ||
Required access policy scopes: | ||
fleet-management:readfleet-management:write | ||
--- | ||
|
||
# grafana_fleet_management_pipeline (Resource) | ||
|
||
Manages Grafana Fleet Management pipelines. | ||
|
||
* [Official documentation](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/) | ||
* [API documentation](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/pipeline-api/) | ||
|
||
**Note:** Fleet Management is in [public preview](https://grafana.com/docs/release-life-cycle/#public-preview) and this resource is experimental. Grafana Labs offers limited support, and breaking changes might occur. | ||
|
||
Required access policy scopes: | ||
|
||
* fleet-management:read | ||
* fleet-management:write | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "grafana_fleet_management_pipeline" "test" { | ||
name = "my_pipeline" | ||
contents = file("config.alloy") | ||
matchers = [ | ||
"collector.os=~\".*\"", | ||
"env=\"PROD\"" | ||
] | ||
enabled = true | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `contents` (String) Configuration contents of the pipeline to be used by collectors | ||
- `name` (String) Name of the pipeline which is the unique identifier for the pipeline | ||
|
||
### Optional | ||
|
||
- `enabled` (Boolean) Whether the pipeline is enabled for collectors | ||
- `matchers` (List of String) Used to match against collectors and assign pipelines to them; follows the syntax of Prometheus Alertmanager matchers | ||
|
||
### Read-Only | ||
|
||
- `id` (String) Server-assigned ID of the pipeline | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
terraform import grafana_fleet_management_pipeline.name "{{ name }}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Variables | ||
variable "cloud_access_policy_token" { | ||
type = string | ||
description = "Cloud access policy token with scopes: accesspolicies:read|write|delete, stacks:read" | ||
} | ||
|
||
variable "stack_slug" { | ||
type = string | ||
description = "Subdomain that the Grafana Cloud instance is available at: https://<stack_slug>.grafana.net" | ||
} | ||
|
||
// Step 1: Retrieve stack details | ||
provider "grafana" { | ||
alias = "cloud" | ||
|
||
cloud_access_policy_token = var.cloud_access_policy_token | ||
} | ||
|
||
data "grafana_cloud_stack" "stack" { | ||
provider = grafana.cloud | ||
|
||
slug = var.stack_slug | ||
} | ||
|
||
// Step 2: Create an access policy and token for Fleet Management | ||
resource "grafana_cloud_access_policy" "policy" { | ||
provider = grafana.cloud | ||
|
||
name = "fleet-management-policy" | ||
region = data.grafana_cloud_stack.stack.region_slug | ||
|
||
scopes = [ | ||
"fleet-management:read", | ||
"fleet-management:write" | ||
] | ||
|
||
realm { | ||
type = "stack" | ||
identifier = data.grafana_cloud_stack.stack.id | ||
} | ||
} | ||
|
||
resource "grafana_cloud_access_policy_token" "token" { | ||
provider = grafana.cloud | ||
|
||
name = "fleet-management-token" | ||
region = grafana_cloud_access_policy.policy.region | ||
access_policy_id = grafana_cloud_access_policy.policy.policy_id | ||
} | ||
|
||
// Step 3: Interact with Fleet Management | ||
provider "grafana" { | ||
alias = "fm" | ||
|
||
fleet_management_auth = "${data.grafana_cloud_stack.stack.fleet_management_user_id}:${grafana_cloud_access_policy_token.token.token}" | ||
fleet_management_url = data.grafana_cloud_stack.stack.fleet_management_url | ||
} | ||
|
||
resource "grafana_fleet_management_collector" "collector" { | ||
provider = grafana.fm | ||
|
||
id = "my_collector" | ||
remote_attributes = { | ||
"env" = "PROD", | ||
"owner" = "TEAM-A" | ||
} | ||
enabled = true | ||
} | ||
|
||
resource "grafana_fleet_management_pipeline" "pipeline" { | ||
provider = grafana.fm | ||
|
||
name = "my_pipeline" | ||
contents = file("config.alloy") | ||
matchers = [ | ||
"collector.os=\"linux\"", | ||
"env=\"PROD\"" | ||
] | ||
enabled = true | ||
} |
1 change: 1 addition & 0 deletions
1
examples/resources/grafana_fleet_management_collector/import.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import grafana_fleet_management_collector.name "{{ id }}" |
8 changes: 8 additions & 0 deletions
8
examples/resources/grafana_fleet_management_collector/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "grafana_fleet_management_collector" "test" { | ||
id = "my_collector" | ||
remote_attributes = { | ||
"env" = "PROD", | ||
"owner" = "TEAM-A" | ||
} | ||
enabled = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import grafana_fleet_management_pipeline.name "{{ name }}" |
9 changes: 9 additions & 0 deletions
9
examples/resources/grafana_fleet_management_pipeline/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "grafana_fleet_management_pipeline" "test" { | ||
name = "my_pipeline" | ||
contents = file("config.alloy") | ||
matchers = [ | ||
"collector.os=~\".*\"", | ||
"env=\"PROD\"" | ||
] | ||
enabled = true | ||
} |
Oops, something went wrong.