Skip to content

Set required URL and TOKEN env vars for agent config #572

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

Merged
merged 5 commits into from
Jul 27, 2021

Conversation

flands
Copy link
Contributor

@flands flands commented Jul 23, 2021

If you deploy Splunk OTel Connector outside of installer script then the
gateway configuration is used. If the agent configuration was desired,
it was really hard to switch:

$ > SPLUNK_ACCESS_TOKEN=1234 SPLUNK_REALM=us0 SPLUNK_CONFIG=../cmd/otelcol/config/collector/agent_config.yaml ./otelcol_darwin_amd64
2021/07/23 11:30:17 main.go:198: Set config to ../cmd/otelcol/config/collector/agent_config.yaml
2021/07/23 11:30:17 main.go:283: Set ballast to 168 MiB
2021/07/23 11:30:17 main.go:307: Set memory limit to 460 MiB
2021-07-23T11:30:17.907-0400	info	service/collector.go:283	Starting otelcol...	{"Version": "v0.29.0-43-g491b2f0", "NumCPU": 12}
2021-07-23T11:30:17.910-0400	info	service/collector.go:343	Using memory ballast	{"MiBs": 168}
2021-07-23T11:30:17.910-0400	info	service/collector.go:188	Setting up own telemetry...
2021-07-23T11:30:17.919-0400	info	service/telemetry.go:99	Serving Prometheus metrics	{"address": ":8888", "level": 0, "service.instance.id": "c928a31c-d214-4287-b7bb-d2b802138d1c"}
2021-07-23T11:30:17.919-0400	info	service/collector.go:224	Loading configuration...
2021-07-23T11:30:17.939-0400	info	service/collector.go:240	Applying configuration...
Error: cannot build extensions: cannot build builtExtensions: failed to create extension http_forwarder: 'egress.endpoint' config option cannot be empty
2021/07/23 11:30:17 main.go:94: application run finished with error: cannot build extensions: cannot build builtExtensions: failed to create extension http_forwarder: 'egress.endpoint' config option cannot be empty

To make it work:

SPLUNK_ACCESS_TOKEN=1234 SPLUNK_REALM=us0 SPLUNK_CONFIG=../cmd/otelcol/config/collector/agent_config.yaml \
  SPLUNK_API_URL=https://api.us0.signalfx.com SPLUNK_INGEST_URL=https://ingest.us0.signalfx.com \
  SPLUNK_TRACE_URL=https://ingest.us0.signalfx.com/v2/trace SPLUNK_HEC_URL=https://ingest.us0.signalfx.com/v1/log\
  ./otelcol_darwin_amd64

This is awful customer experience. The behavior is not surprising as the
agent config needs to optimize for both direct to SaaS and via gateway
data routing. The installer script mitigates this today.

The good news is that this is straightforward to address. Given
SPLUNK_REALM is required and the SaaS URLs are known and same for
SPLUNK_ACCESS_TOKEN we can set the required environment variable if
not manually specified.

@flands flands marked this pull request as ready for review July 23, 2021 17:17
@flands flands requested review from a team as code owners July 23, 2021 17:17
flands added 4 commits July 23, 2021 16:38
If you deploy Splunk OTel Connector outside of installer script then the
gateway configuration is used. If the agent configuration was desired,
it was really hard to switch:

```
$ > SPLUNK_ACCESS_TOKEN=1234 SPLUNK_REALM=us0 SPLUNK_CONFIG=../cmd/otelcol/config/collector/agent_config.yaml ./otelcol_darwin_amd64
2021/07/23 11:30:17 main.go:198: Set config to ../cmd/otelcol/config/collector/agent_config.yaml
2021/07/23 11:30:17 main.go:283: Set ballast to 168 MiB
2021/07/23 11:30:17 main.go:307: Set memory limit to 460 MiB
2021-07-23T11:30:17.907-0400	info	service/collector.go:283	Starting otelcol...	{"Version": "v0.29.0-43-g491b2f0", "NumCPU": 12}
2021-07-23T11:30:17.910-0400	info	service/collector.go:343	Using memory ballast	{"MiBs": 168}
2021-07-23T11:30:17.910-0400	info	service/collector.go:188	Setting up own telemetry...
2021-07-23T11:30:17.919-0400	info	service/telemetry.go:99	Serving Prometheus metrics	{"address": ":8888", "level": 0, "service.instance.id": "c928a31c-d214-4287-b7bb-d2b802138d1c"}
2021-07-23T11:30:17.919-0400	info	service/collector.go:224	Loading configuration...
2021-07-23T11:30:17.939-0400	info	service/collector.go:240	Applying configuration...
Error: cannot build extensions: cannot build builtExtensions: failed to create extension http_forwarder: 'egress.endpoint' config option cannot be empty
2021/07/23 11:30:17 main.go:94: application run finished with error: cannot build extensions: cannot build builtExtensions: failed to create extension http_forwarder: 'egress.endpoint' config option cannot be empty
```

To make it work:

```
SPLUNK_ACCESS_TOKEN=1234 SPLUNK_REALM=us0 SPLUNK_CONFIG=../cmd/otelcol/config/collector/agent_config.yaml \
  SPLUNK_API_URL=https://api.us0.signalfx.com SPLUNK_INGEST_URL=https://ingest.us0.signalfx.com \
  SPLUNK_TRACE_URL=https://ingest.us0.signalfx.com/v2/trace SPLUNK_HEC_URL=https://ingest.us0.signalfx.com/v1/log\
  ./otelcol_darwin_amd64
```

This is awful customer experience. The behavior is not surprising as the
agent config needs to optimize for both direct to SaaS and via gateway
data routing. The installer script mitigates this today.

The good news is that this is straightforward to address. Given
`SPLUNK_REALM` is required and the SaaS URLs are known and same for
`SPLUNK_ACCESS_TOKEN` we can set the required environment variable if
not manually specified.
@flands flands force-pushed the flands/agent-env-vars branch from 1b84b46 to de749b6 Compare July 23, 2021 20:38
@flands flands merged commit cba4c0a into main Jul 27, 2021
@delete-merged-branch delete-merged-branch bot deleted the flands/agent-env-vars branch July 27, 2021 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants