-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e0d20b
commit 8b0fc58
Showing
9 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
docs/data-sources/connections_metrics_endpoint_scrape_job.md
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,35 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "grafana_connections_metrics_endpoint_scrape_job Data Source - terraform-provider-grafana" | ||
subcategory: "Connections" | ||
description: |- | ||
--- | ||
|
||
# grafana_connections_metrics_endpoint_scrape_job (Data Source) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `authentication_method` (String) Method to pass authentication credentials: basic or bearer. | ||
- `name` (String) The name of the Metrics Endpoint Scrape Job. Part of the Terraform Resource ID. | ||
- `stack_id` (String) The Stack ID of the Grafana Cloud instance. Part of the Terraform Resource ID. | ||
- `url` (String) The url to scrape metrics. | ||
|
||
### Optional | ||
|
||
- `authentication_basic_password` (String, Sensitive) Password for basic authentication. | ||
- `authentication_basic_username` (String) Username for basic authentication. | ||
- `authentication_bearer_token` (String, Sensitive) Token for authentication bearer. | ||
|
||
### Read-Only | ||
|
||
- `enabled` (Boolean) Whether the Metrics Endpoint Scrape Job is enabled or not. | ||
- `id` (String) The Terraform Resource ID. This has the format "{{ stack_id }}:{{ name }}". | ||
- `scrape_interval_seconds` (Number) Frequency for scraping the metrics endpoint: 30, 60, or 120 seconds. |
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,54 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "grafana_connections_metrics_endpoint_scrape_job Resource - terraform-provider-grafana" | ||
subcategory: "Connections" | ||
description: |- | ||
--- | ||
|
||
# grafana_connections_metrics_endpoint_scrape_job (Resource) | ||
|
||
|
||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "grafana_connections_metrics_endpoint_scrape_job" "test" { | ||
stack_id = "test-stack-id" | ||
name = "my-scrape-job" | ||
authentication_method = "basic" | ||
authentication_basic_username = "my_username" | ||
authentication_basic_password = "my_password" | ||
url = "https://dev.my-metrics-endpoint-url.com:9000/metrics" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `authentication_method` (String) Method to pass authentication credentials: basic or bearer. | ||
- `name` (String) The name of the Metrics Endpoint Scrape Job. Part of the Terraform Resource ID. | ||
- `stack_id` (String) The Stack ID of the Grafana Cloud instance. Part of the Terraform Resource ID. | ||
- `url` (String) The url to scrape metrics; a valid HTTPs URL is required. | ||
|
||
### Optional | ||
|
||
- `authentication_basic_password` (String, Sensitive) Password for basic authentication. | ||
- `authentication_basic_username` (String) Username for basic authentication. | ||
- `authentication_bearer_token` (String, Sensitive) Token for authentication bearer. | ||
- `enabled` (Boolean) Whether the Metrics Endpoint Scrape Job is enabled or not. | ||
- `scrape_interval_seconds` (Number) Frequency for scraping the metrics endpoint: 30, 60, or 120 seconds. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The Terraform Resource ID. This has the format "{{ stack_id }}:{{ name }}". | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
terraform import grafana_connections_metrics_endpoint_scrape_job.name "{{ stack_id }}:{{ name }}" | ||
``` |
1 change: 1 addition & 0 deletions
1
examples/data-sources/grafana_connections_metrics_endpoint_scrape_job/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 @@ | ||
data "grafana_connections_metrics_endpoint_scrape_job" "test" {} |
1 change: 1 addition & 0 deletions
1
examples/resources/grafana_connections_metrics_endpoint_scrape_job/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_connections_metrics_endpoint_scrape_job.name "{{ stack_id }}:{{ name }}" |
8 changes: 8 additions & 0 deletions
8
examples/resources/grafana_connections_metrics_endpoint_scrape_job/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_connections_metrics_endpoint_scrape_job" "test" { | ||
stack_id = "test-stack-id" | ||
name = "my-scrape-job" | ||
authentication_method = "basic" | ||
authentication_basic_username = "my_username" | ||
authentication_basic_password = "my_password" | ||
url = "https://dev.my-metrics-endpoint-url.com:9000/metrics" | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/resources/grafana_connections_metrics_endpoint_scrape_job/resource_update.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_connections_metrics_endpoint_scrape_job" "test" { | ||
stack_id = "test-stack-id" | ||
name = "modified-scrape-job" | ||
enabled = "false" | ||
authentication_method = "bearer" | ||
authentication_bearer_token = "test-token" | ||
url = "https://www.modified-url.com:9000/metrics" | ||
scrape_interval_seconds = "120" | ||
} |
48 changes: 48 additions & 0 deletions
48
internal/resources/connections/data_source_metrics_endpoint_scrape_job_test.go
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,48 @@ | ||
package connections_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/grafana/terraform-provider-grafana/v3/internal/testutils" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAcc_DataSourceMetricsEndpointScrapeJob(t *testing.T) { | ||
// Run this test by removing t.Skip and set env variables TF_ACC=1;GRAFANA_CONNECTIONS_ACCESS_TOKEN=whatever | ||
// in order to test the resource code "scaffolding". | ||
// Expected result: test fails and the error message should be "failed to create metrics endpoint scrape job: failed to do request" | ||
// because the Connections API is not yet available. | ||
|
||
// t.Skip("will be enabled after Connections API is available in prod") | ||
|
||
// testutils.CheckCloudInstanceTestsEnabled(t) // TODO: enable after Connections API is available | ||
resource.ParallelTest(t, resource.TestCase{ | ||
ProtoV5ProviderFactories: testutils.ProtoV5ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
// Create this resource | ||
Config: testutils.TestAccExample(t, "resources/grafana_connections_metrics_endpoint_scrape_job/resource.tf"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("grafana_connections_metrics_endpoint_scrape_job.test", "stack_id", "test-stack-id"), | ||
resource.TestCheckResourceAttr("grafana_connections_metrics_endpoint_scrape_job.test", "name", "my-scrape-job"), | ||
resource.TestCheckResourceAttr("grafana_connections_metrics_endpoint_scrape_job.test", "enabled", "true"), | ||
resource.TestCheckResourceAttr("grafana_connections_metrics_endpoint_scrape_job.test", "authentication_method", "basic"), | ||
resource.TestCheckResourceAttr("grafana_connections_metrics_endpoint_scrape_job.test", "authentication_basic_username", "my_username"), | ||
resource.TestCheckResourceAttr("grafana_connections_metrics_endpoint_scrape_job.test", "authentication_basic_password", "my_password"), | ||
resource.TestCheckResourceAttr("grafana_connections_metrics_endpoint_scrape_job.test", "url", "https://dev.my-metrics-endpoint-url.com:9000/metrics"), | ||
resource.TestCheckResourceAttr("grafana_connections_metrics_endpoint_scrape_job.test", "scrape_interval_seconds", "60"), | ||
testutils.CheckLister("grafana_connections_metrics_endpoint_scrape_job.test"), | ||
), | ||
}, | ||
{ | ||
// Verifies that the created SLO Resource is read by the Datasource Read Method | ||
// TODO: work on after other Test Step passes | ||
// Config: testutils.TestAccExample(t, "data-sources/grafana_connections_metrics_endpoint_scrape_job/resource.tf"), | ||
// RefreshState: true, | ||
// Check: resource.ComposeTestCheckFunc( | ||
// resource.TestCheckResourceAttrSet("data.grafana_connections_metrics_endpoint_scrape_job.test", "test.0.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