Skip to content

Commit 15352bb

Browse files
authored
T-4939 Add ingestion_host to sources (#30)
1 parent 8ef1d00 commit 15352bb

File tree

10 files changed

+26
-6
lines changed

10 files changed

+26
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GOLANGCI_LINT := golangci-lint run --disable-all \
88
-E staticcheck \
99
-E typecheck \
1010
-E unused
11-
VERSION := 0.3.2
11+
VERSION := 0.3.6
1212
.PHONY: test build
1313

1414
help:

docs/data-sources/source.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This Data Source allows you to look up existing Sources using their table name.
2525
- **data_region** (String) Region where we store your data.
2626
- **id** (String) The ID of this source.
2727
- **ingesting_paused** (Boolean) This property allows you to temporarily pause data ingesting for this source (e.g., when you are reaching your plan's usage quota and you want to prioritize some sources over others).
28+
- **ingestion_host** (String) The host where the logs or metrics should be sent. See [documentation](https://betterstack.com/docs/logs/start/) for your specific source platform for details.
2829
- **live_tail_pattern** (String) Freeform text template for formatting Live tail output with columns wrapped in {column} brackets. Example: "PID: {message_json.pid} {level} {message}"
2930
- **logs_retention** (Number) Data retention for logs in days. There might be additional charges for longer retention.
3031
- **metrics_retention** (Number) Data retention for metrics in days. There might be additional charges for longer retention.

docs/resources/source.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ This resource allows you to create, modify, and delete your Sources. For more in
8585

8686
- **created_at** (String) The time when this monitor group was created.
8787
- **id** (String) The ID of this source.
88+
- **ingestion_host** (String) The host where the logs or metrics should be sent. See [documentation](https://betterstack.com/docs/logs/start/) for your specific source platform for details.
8889
- **table_name** (String) The table name generated for this source.
8990
- **token** (String) The token of this source. This token is used to identify and route the data you will send to Better Stack.
9091
- **updated_at** (String) The time when this monitor group was updated.

examples/advanced/outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
output "logtail_source_token" {
22
value = logtail_source.this.token
33
}
4+
output "logtail_ingestion_host" {
5+
value = logtail_source.this.ingestion_host
6+
}
47

58
output "default_metric_expression" {
69
value = data.logtail_metric.level.sql_expression

examples/advanced/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
logtail = {
55
source = "BetterStackHQ/logtail"
6-
version = ">= 0.3.2"
6+
version = ">= 0.3.6"
77
}
88
}
99
}

examples/basic/outputs.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
output "logtail_source_token" {
22
value = logtail_source.this.token
3-
}
3+
}
4+
output "logtail_ingestion_host" {
5+
value = logtail_source.this.ingestion_host
6+
}

examples/basic/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
logtail = {
55
source = "BetterStackHQ/logtail"
6-
version = ">= 0.1.0"
6+
version = ">= 0.3.6"
77
}
88
}
99
}

examples/scrape/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
output "logtail_source_token" {
2-
value = logtail_source.this.token
1+
output "logtail_scrape_urls" {
2+
value = logtail_source.this.scrape_urls
33
}

internal/provider/resource_source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ var sourceSchema = map[string]*schema.Schema{
117117
}
118118
},
119119
},
120+
"ingestion_host": {
121+
Description: "The host where the logs or metrics should be sent. See [documentation](https://betterstack.com/docs/logs/start/) for your specific source platform for details.",
122+
Type: schema.TypeString,
123+
Optional: false,
124+
Computed: true,
125+
},
120126
"ingesting_paused": {
121127
Description: "This property allows you to temporarily pause data ingesting for this source (e.g., when you are reaching your plan's usage quota and you want to prioritize some sources over others).",
122128
Type: schema.TypeBool,
@@ -218,6 +224,7 @@ type source struct {
218224
Token *string `json:"token,omitempty"`
219225
TableName *string `json:"table_name,omitempty"`
220226
Platform *string `json:"platform,omitempty"`
227+
IngestionHost *string `json:"ingestion_host,omitempty"`
221228
IngestingPaused *bool `json:"ingesting_paused,omitempty"`
222229
LogsRetention *int `json:"logs_retention,omitempty"`
223230
MetricsRetention *int `json:"metrics_retention,omitempty"`
@@ -252,6 +259,7 @@ func sourceRef(in *source) []struct {
252259
{k: "token", v: &in.Token},
253260
{k: "table_name", v: &in.TableName},
254261
{k: "platform", v: &in.Platform},
262+
{k: "ingestion_host", v: &in.IngestionHost},
255263
{k: "ingesting_paused", v: &in.IngestingPaused},
256264
{k: "logs_retention", v: &in.LogsRetention},
257265
{k: "metrics_retention", v: &in.MetricsRetention},

internal/provider/resource_source_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func TestResourceSource(t *testing.T) {
3434
t.Fatal(err)
3535
}
3636
body = inject(t, body, "token", "generated_by_logtail")
37+
body = inject(t, body, "ingestion_host", "in.logs.betterstack.com")
3738
body = inject(t, body, "table_name", "test_source")
3839
data.Store(body)
3940
w.WriteHeader(http.StatusCreated)
@@ -57,6 +58,7 @@ func TestResourceSource(t *testing.T) {
5758
t.Fatal(err)
5859
}
5960
patched = inject(t, patched, "token", "generated_by_logtail")
61+
patched = inject(t, patched, "ingestion_host", "in.logs.betterstack.com")
6062
patched = inject(t, patched, "table_name", "test_source")
6163
data.Store(patched)
6264
_, _ = w.Write([]byte(fmt.Sprintf(`{"data":{"id":%q,"attributes":%s}}`, id, patched)))
@@ -98,6 +100,7 @@ func TestResourceSource(t *testing.T) {
98100
resource.TestCheckResourceAttr("logtail_source.this", "name", name),
99101
resource.TestCheckResourceAttr("logtail_source.this", "platform", platform),
100102
resource.TestCheckResourceAttr("logtail_source.this", "token", "generated_by_logtail"),
103+
resource.TestCheckResourceAttr("logtail_source.this", "ingestion_host", "in.logs.betterstack.com"),
101104
resource.TestCheckResourceAttr("logtail_source.this", "data_region", "eu-hel-1-legacy"),
102105
),
103106
},
@@ -123,6 +126,7 @@ func TestResourceSource(t *testing.T) {
123126
resource.TestCheckResourceAttr("logtail_source.this", "platform", platform),
124127
resource.TestCheckResourceAttr("logtail_source.this", "ingesting_paused", "true"),
125128
resource.TestCheckResourceAttr("logtail_source.this", "token", "generated_by_logtail"),
129+
resource.TestCheckResourceAttr("logtail_source.this", "ingestion_host", "in.logs.betterstack.com"),
126130
resource.TestCheckResourceAttr("logtail_source.this", "data_region", "eu-hel-1-legacy"),
127131
),
128132
},

0 commit comments

Comments
 (0)