|
| 1 | +--- |
| 2 | +title: DatadogGenericResource CRD |
| 3 | +description: Create and manage Datadog resources using the DatadogGenericResource custom resource definition with the Datadog Operator |
| 4 | +further_reading: |
| 5 | + - link: "https://github.com/DataDog/datadog-operator/blob/main/docs/datadoggenericresource/datadog_generic_resource.md" |
| 6 | + tag: "GitHub" |
| 7 | + text: "DatadogGenericResource guide" |
| 8 | + - link: "https://github.com/DataDog/datadog-operator/blob/main/docs/datadoggenericresource/datadog_generic_resource_migration.md" |
| 9 | + tag: "GitHub" |
| 10 | + text: "Migrating to DatadogGenericResource" |
| 11 | +--- |
| 12 | + |
| 13 | +To create and manage Datadog resources with the Datadog Operator, use the `DatadogGenericResource` custom resource definition (CRD). `DatadogGenericResource` uses the Datadog API JSON payload for each supported resource type in `spec.jsonSpec`. |
| 14 | + |
| 15 | +`DatadogGenericResource` is the preferred CRD for Datadog resources that are supported by both `DatadogGenericResource` and older resource-specific CRDs, such as `DatadogMonitor`, `DatadogDashboard`, and `DatadogSLO`. |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | +- [Helm][1] |
| 19 | +- [`kubectl` CLI][2] |
| 20 | +- [Datadog Operator][3] v1.12+ |
| 21 | +- Datadog API and application keys with permissions for the resources you create |
| 22 | + |
| 23 | +## Supported resources |
| 24 | + |
| 25 | +| Type | Operator version | API reference | |
| 26 | +| ---- | ---------------- | ------------- | |
| 27 | +| `notebook` | v1.12.0 | [Create a notebook][4] | |
| 28 | +| `synthetics_api_test` | v1.12.0 | [Create an API test][5] | |
| 29 | +| `synthetics_browser_test` | v1.12.0 | [Create a browser test][6] | |
| 30 | +| `monitor` | v1.13.0 | [Create a monitor][7] | |
| 31 | +| `downtime` | v1.22.0 | [Schedule a downtime][8] | |
| 32 | +| `dashboard` | v1.27.0 | [Create a dashboard][9] | |
| 33 | +| `slo` | v1.28.0 | [Create an SLO object][10] | |
| 34 | + |
| 35 | +## Setup |
| 36 | + |
| 37 | +1. Run the installation command, substituting your Datadog API and application keys: |
| 38 | + |
| 39 | + ```shell |
| 40 | + helm install datadog-operator datadog/datadog-operator \ |
| 41 | + --set apiKey=<DATADOG_API_KEY> \ |
| 42 | + --set appKey=<DATADOG_APP_KEY> \ |
| 43 | + --set datadogCRDs.crds.datadogGenericResources=true \ |
| 44 | + --set datadogGenericResource.enabled=true |
| 45 | + ``` |
| 46 | + |
| 47 | +2. Create a file with the spec of your `DatadogGenericResource` configuration. |
| 48 | + |
| 49 | + **Example**: Monitor |
| 50 | + |
| 51 | + {{< code-block lang="yaml" filename="datadog-generic-resource-monitor.yaml" collapsible="true" >}} |
| 52 | + apiVersion: datadoghq.com/v1alpha1 |
| 53 | + kind: DatadogGenericResource |
| 54 | + metadata: |
| 55 | + name: example-monitor |
| 56 | + namespace: <operator namespace> |
| 57 | + spec: |
| 58 | + type: monitor |
| 59 | + jsonSpec: |- |
| 60 | + { |
| 61 | + "name": "Example Monitor", |
| 62 | + "type": "metric alert", |
| 63 | + "query": "avg(last_10m):avg:system.cpu.user{*} > 80", |
| 64 | + "message": "CPU usage is high", |
| 65 | + "tags": [ |
| 66 | + "team:example" |
| 67 | + ], |
| 68 | + "options": { |
| 69 | + "notify_no_data": false |
| 70 | + } |
| 71 | + } |
| 72 | + {{< /code-block >}} |
| 73 | + |
| 74 | +3. Deploy your `DatadogGenericResource`: |
| 75 | + |
| 76 | + ```shell |
| 77 | + kubectl apply -f /path/to/your/datadog-generic-resource-monitor.yaml |
| 78 | + ``` |
| 79 | + |
| 80 | +## Further reading |
| 81 | + |
| 82 | +{{< partial name="whats-next/whats-next.html" >}} |
| 83 | + |
| 84 | +[1]: https://helm.sh/ |
| 85 | +[2]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ |
| 86 | +[3]: /containers/kubernetes/installation?tab=datadogoperator#installation |
| 87 | +[4]: /api/latest/notebooks/#create-a-notebook |
| 88 | +[5]: /api/latest/synthetics/#create-an-api-test |
| 89 | +[6]: /api/latest/synthetics/#create-a-browser-test |
| 90 | +[7]: /api/latest/monitors/#create-a-monitor |
| 91 | +[8]: /api/latest/downtimes/#schedule-a-downtime |
| 92 | +[9]: /api/latest/dashboards/#create-a-new-dashboard |
| 93 | +[10]: /api/latest/service-level-objectives/#create-an-slo-object |
0 commit comments