|
| 1 | +--- |
| 2 | +layout: "heroku" |
| 3 | +page_title: "Heroku: heroku_telemetry_drain" |
| 4 | +sidebar_current: "docs-heroku-resource-telemetry-drain" |
| 5 | +description: |- |
| 6 | + Provides a Heroku Telemetry Drain resource. |
| 7 | +--- |
| 8 | + |
| 9 | +# heroku\_telemetry\_drain |
| 10 | + |
| 11 | +Provides a [Heroku Telemetry Drain](https://devcenter.heroku.com/articles/platform-api-reference#telemetry-drain) resource. |
| 12 | + |
| 13 | +A telemetry drain forwards OpenTelemetry traces, metrics, and logs from Fir generation apps and spaces to your own consumer endpoint. |
| 14 | + |
| 15 | +## Generation Compatibility |
| 16 | + |
| 17 | +Telemetry drains are **only supported for Fir generation** apps and spaces. Cedar generation apps should use the [`heroku_drain`](./drain.html) resource for log forwarding instead. |
| 18 | + |
| 19 | +If you attempt to create a telemetry drain for a Cedar generation app or space, the provider will return a clear error message directing you to use the appropriate resource type. |
| 20 | + |
| 21 | +## Example Usage |
| 22 | + |
| 23 | +### App-scoped Telemetry Drain |
| 24 | + |
| 25 | +```hcl |
| 26 | +resource "heroku_space" "fir_space" { |
| 27 | + name = "my-fir-space" |
| 28 | + organization = "my-org" |
| 29 | + region = "virginia" |
| 30 | + generation = "fir" |
| 31 | +} |
| 32 | +
|
| 33 | +resource "heroku_app" "fir_app" { |
| 34 | + name = "my-fir-app" |
| 35 | + region = "virginia" |
| 36 | + space = heroku_space.fir_space.name |
| 37 | + |
| 38 | + organization { |
| 39 | + name = "my-org" |
| 40 | + } |
| 41 | +} |
| 42 | +
|
| 43 | +resource "heroku_telemetry_drain" "app_traces" { |
| 44 | + owner_id = heroku_app.fir_app.id |
| 45 | + owner_type = "app" |
| 46 | + endpoint = "https://api.honeycomb.io/v1/traces" |
| 47 | + exporter_type = "otlphttp" |
| 48 | + signals = ["traces", "metrics"] |
| 49 | + |
| 50 | + headers = { |
| 51 | + "x-honeycomb-team" = var.honeycomb_api_key |
| 52 | + "x-honeycomb-dataset" = "my-service" |
| 53 | + } |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +### Space-scoped Telemetry Drain |
| 58 | + |
| 59 | +```hcl |
| 60 | +resource "heroku_telemetry_drain" "space_observability" { |
| 61 | + owner_id = heroku_space.fir_space.id |
| 62 | + owner_type = "space" |
| 63 | + endpoint = "otel-collector.example.com:4317" |
| 64 | + exporter_type = "otlp" |
| 65 | + signals = ["traces", "metrics", "logs"] |
| 66 | + |
| 67 | + headers = { |
| 68 | + "Authorization" = "Bearer ${var.collector_token}" |
| 69 | + } |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +### Logs-only Telemetry Drain |
| 74 | + |
| 75 | +```hcl |
| 76 | +resource "heroku_telemetry_drain" "app_logs" { |
| 77 | + owner_id = heroku_app.fir_app.id |
| 78 | + owner_type = "app" |
| 79 | + endpoint = "https://logs.datadog.com/api/v2/logs" |
| 80 | + exporter_type = "otlphttp" |
| 81 | + signals = ["logs"] |
| 82 | + |
| 83 | + headers = { |
| 84 | + "DD-API-KEY" = var.datadog_api_key |
| 85 | + } |
| 86 | +} |
| 87 | +``` |
| 88 | + |
| 89 | +## Argument Reference |
| 90 | + |
| 91 | +The following arguments are supported: |
| 92 | + |
| 93 | +* `owner_id` - (Required, ForceNew) The UUID of the app or space that owns this telemetry drain. |
| 94 | +* `owner_type` - (Required, ForceNew) The type of owner. Must be either `"app"` or `"space"`. |
| 95 | +* `endpoint` - (Required) The URI of your OpenTelemetry consumer endpoint. |
| 96 | +* `exporter_type` - (Required) The transport type for your OpenTelemetry consumer. Must be either: |
| 97 | + * `"otlphttp"` - HTTP/HTTPS endpoints (e.g., `https://api.example.com/v1/traces`) |
| 98 | + * `"otlp"` - gRPC endpoints in `host:port` format (e.g., `collector.example.com:4317`) |
| 99 | +* `signals` - (Required) A set of OpenTelemetry signals to send to the telemetry drain. Valid values are: |
| 100 | + * `"traces"` - Distributed tracing data |
| 101 | + * `"metrics"` - Application and system metrics |
| 102 | + * `"logs"` - Application and system logs |
| 103 | +* `headers` - (Required) A map of headers to send to your OpenTelemetry consumer for authentication or configuration. At least one header must be specified. |
| 104 | + |
| 105 | +## Attributes Reference |
| 106 | + |
| 107 | +The following attributes are exported: |
| 108 | + |
| 109 | +* `id` - The UUID of the telemetry drain. |
| 110 | +* `created_at` - The timestamp when the telemetry drain was created. |
| 111 | +* `updated_at` - The timestamp when the telemetry drain was last updated. |
| 112 | + |
| 113 | +## Endpoint Format Requirements |
| 114 | + |
| 115 | +The `endpoint` format depends on the `exporter_type`: |
| 116 | + |
| 117 | +* **otlphttp**: Full HTTP/HTTPS URL (e.g., `https://api.honeycomb.io/v1/traces`) |
| 118 | +* **otlp**: Host and port only (e.g., `collector.example.com:4317`) |
| 119 | + |
| 120 | +## Headers |
| 121 | + |
| 122 | +The `headers` field supports custom key-value pairs for authentication and configuration: |
| 123 | + |
| 124 | +* **Keys**: Must match the pattern `^[A-Za-z0-9\-_]{1,100}$` (alphanumeric, hyphens, underscores, max 100 chars) |
| 125 | +* **Values**: Maximum 1000 characters each |
| 126 | +* **Limit**: Maximum 20 header pairs per telemetry drain |
| 127 | + |
| 128 | +Common header patterns: |
| 129 | +* **API Keys**: `"Authorization" = "Bearer token"` or `"x-api-key" = "key"` |
| 130 | +* **Content Types**: `"Content-Type" = "application/x-protobuf"` |
| 131 | +* **Service Tags**: `"x-service" = "my-app"`, `"x-environment" = "production"` |
| 132 | + |
| 133 | +## Validation |
| 134 | + |
| 135 | +The provider performs generation-aware validation: |
| 136 | + |
| 137 | +1. **Plan-time**: Schema validation for field types, required fields, and enum values |
| 138 | +2. **Apply-time**: Generation compatibility check via Heroku API |
| 139 | + * Fetches app/space information to determine generation |
| 140 | + * Returns descriptive error if Cedar generation detected |
| 141 | + * Suggests using `heroku_drain` for Cedar apps |
| 142 | + |
| 143 | +## Import |
| 144 | + |
| 145 | +Telemetry drains can be imported using the drain `id`: |
| 146 | + |
| 147 | +``` |
| 148 | +$ terraform import heroku_telemetry_drain.example 01234567-89ab-cdef-0123-456789abcdef |
| 149 | +``` |
| 150 | + |
| 151 | +## Notes |
| 152 | + |
| 153 | +* **Immutable Owner**: The `owner_id` and `owner_type` cannot be changed after creation (ForceNew) |
| 154 | +* **Updates Supported**: `endpoint`, `exporter_type`, `signals`, and `headers` can be modified |
| 155 | +* **Generation Requirement**: Only works with Fir generation apps and spaces |
| 156 | +* **Multiple Drains**: You can create multiple telemetry drains per app or space |
| 157 | +* **Signal Filtering**: Use different drains to send different signal types to different endpoints |
0 commit comments