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

Synthetic Monitoring Probe and Check Resources and Data Sources #228

Merged
merged 12 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from 8 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
5 changes: 4 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ GRAFANA_VERSION ?= latest
testacc:
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m

testacc-enterprise: TESTARGS+=-tags='enterprise'
testacc-enterprise: testacc
TF_ACC=1 go test ./... -tags="enterprise" -v $(TESTARGS) -timeout 120m

testacc-cloud: TESTARGS+=-tags='cloud'
testacc-cloud: testacc

testacc-docker:
GRAFANA_VERSION=$(GRAFANA_VERSION) \
Expand Down
38 changes: 38 additions & 0 deletions docs/data-sources/synthetic_monitoring_probe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "grafana_synthetic_monitoring_probe Data Source - terraform-provider-grafana"
subcategory: ""
description: |-
Data source for retrieving a single probe by name.
---

# grafana_synthetic_monitoring_probe (Data Source)

Data source for retrieving a single probe by name.

## Example Usage

```terraform
data "grafana_synthetic_monitoring_probe" "atlanta" {
name = "Atlanta"
}
```

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

### Required

- **name** (String) Name of the probe.

### Read-Only

- **id** (String) The ID of the probe.
- **labels** (Map of String) Custom labels to be included with collected metrics and logs.
- **latitude** (Number) Latitude coordinates.
- **longitude** (Number) Longitude coordinates.
- **public** (Boolean) Public probes are run by Grafana Labs and can be used by all users. You must be an admin to set this to `true`.
- **region** (String) Region of the probe.
- **tenant_id** (Number) The tenant ID of the probe.


30 changes: 30 additions & 0 deletions docs/data-sources/synthetic_monitoring_probes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "grafana_synthetic_monitoring_probes Data Source - terraform-provider-grafana"
subcategory: ""
description: |-
Data source for retrieving all probes.
---

# grafana_synthetic_monitoring_probes (Data Source)

Data source for retrieving all probes.

## Example Usage

```terraform
data "grafana_synthetic_monitoring_probes" "main" {}
```

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

### Optional

- **id** (String) The ID of this resource.

### Read-Only

- **probes** (Map of Number) Map of probes with their names as keys and IDs as values.


48 changes: 48 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,51 @@ provider "grafana" {
- **sm_access_token** (String, Sensitive) A Synthetic Monitoring access token. May alternatively be set via the `GRAFANA_SM_ACCESS_TOKEN` environment variable.
- **tls_cert** (String) Client TLS certificate file to use to authenticate to the Grafana server. May alternatively be set via the `GRAFANA_TLS_CERT` environment variable.
- **tls_key** (String) Client TLS key file to use to authenticate to the Grafana server. May alternatively be set via the `GRAFANA_TLS_KEY` environment variable.

## Authentication

### auth

This can be a Grafana API key, basic auth `username:password`, or a
[Grafana Cloud API key](https://grafana.com/docs/grafana-cloud/cloud-portal/create-api-key/).

### sm\_access\_token

[Synthetic Monitoring](https://grafana.com/docs/grafana-cloud/synthetic-monitoring/)
endpoints require a dedicated access token. You may obtain an access token with its
[Registration API](https://github.com/grafana/synthetic-monitoring-api-go-client/blob/main/docs/API.md#registration-api).

```
curl \
-X POST \
-H 'Content-type: application/json; charset=utf-8' \
-H "Authorization: Bearer $GRAFANA_CLOUD_API_KEY" \
-d '{"stackId": <stack-id>, "metricsInstanceId": <metrics-instance-id>, "logsInstanceId": <logs-instance-id>}' \
'https://synthetic-monitoring-api.grafana.net/api/v1/register/install'
```

`GRAFANA_CLOUD_API_KEY` is an API key created on the
[Grafana Cloud Portal](https://grafana.com/docs/grafana-cloud/cloud-portal/create-api-key/).
It must have the `MetricsPublisher` role.

`stackId`, `metricsInstanceId`, and `logsInstanceId` may also be obtained on
the portal. First you need to create a Stack by clicking "Add Stack". When it's
created you will be taken to its landing page on the portal. Get your `stackId`
from the URL in your browser:

```
https://grafana.com/orgs/<org-slug>/stacks/<stack-id>
```

Next, go to "Details" for Prometheus. Again, get `metricsInstanceId` from your URL:

```
https://grafana.com/orgs/<org-slug>/hosted-metrics/<metrics-instance-id>
```

Finally, go back to your stack page, and go to "Details" for Loki to get
`logsInstanceId`.

```
https://grafana.com/orgs/<org-slug>/hosted-logs/<logs-instance-id>
```
Loading