Skip to content

Commit fca7d65

Browse files
authored
chore: modernize okta receiver (#181)
* modernize okta receiver * ignore sdk janitor goroutine * improve and test polling logic * Update logs.go * make tidy * fix lint * add how it works section
1 parent 7b89896 commit fca7d65

10 files changed

Lines changed: 285 additions & 362 deletions

File tree

receiver/oktareceiver/README.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Okta Receiver
2-
This receiver is capable of collecting logs from an Okta domain.
2+
This receiver collects system logs from an Okta domain.
33

44
## Minimum Agent Versions
55
- Introduced: [v1.59.0](https://github.com/observIQ/bindplane-otel-collector/releases/tag/v1.59.0)
@@ -8,33 +8,26 @@ This receiver is capable of collecting logs from an Okta domain.
88
- Logs
99

1010
## How It Works
11-
1. The user configures this receiver in a pipeline.
12-
2. The user configures a supported component to route telemetry from this receiver.
11+
1. The receiver polls the Okta [System Log API](https://developer.okta.com/docs/reference/api/system-log/) once per `poll_interval` for events published since the previous poll.
12+
2. The receiver follows pagination links to retrieve all events within the poll window.
13+
3. The receiver converts each event to an OpenTelemetry log and sends it to the collector.
14+
- Key event fields (such as UUID, event type, outcome, and actor details) are promoted to log attributes, and the Okta domain is set as a resource attribute.
1315

1416
## Prerequisites
1517
- An Okta API Token will be needed to authorize the receiver with your Okta Domain.
1618

1719
## Configuration
18-
| Field | Type | Default | Required | Description |
19-
|----------------------|-----------|------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
20-
| okta_domain | string | | `true` | The Okta domain the receiver should collect logs from (Do not include "https://"): [Find your Okta Domain](https://developer.okta.com/docs/guides/find-your-domain/main/) |
21-
| api_token | string | | `true` | An Okta API Token generated from the above Okta domain: [How to Create an Okta API Token](https://support.okta.com/help/s/article/How-to-create-an-API-token?language=en_US) |
22-
| poll_interval | string | 1m | `false` | The rate at which this receiver will poll Okta for logs. This value must be in the range [1 second - 24 hours] and must be a string readable by Golang's [time.ParseDuration](https://pkg.go.dev/time#ParseDuration). |
20+
| Field | Type | Default | Required | Description |
21+
|----------------------|-----------|------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
22+
| okta_domain | string | | `true` | The Okta domain the receiver should collect logs from (Do not include "https://"): [Find your Okta Domain](https://developer.okta.com/docs/guides/find-your-domain/main/) |
23+
| api_token | string | | `true` | An Okta API Token generated from the above Okta domain: [How to Create an Okta API Token](https://support.okta.com/help/s/article/How-to-create-an-API-token?language=en_US) |
24+
| poll_interval | string | 1m | `false` | The rate at which this receiver will poll Okta for logs. This value must be in the range [1 second - 24 hours] and must be a string readable by Golang's [time.ParseDuration](https://pkg.go.dev/time#ParseDuration). |
2325

2426
### Example Configuration
2527
```yaml
2628
receivers:
2729
okta:
2830
okta_domain: example.okta.com
29-
api_token: 11Z-XDEwgRIf4p0-RqbSFoplFh_84EOtC_ka4J7ylx
31+
api_token: myAPIToken
3032
poll_interval: 2m
31-
exporters:
32-
googlecloud:
33-
project: my-gcp-project
34-
35-
service:
36-
pipelines:
37-
logs:
38-
receivers: [okta]
39-
exporters: [googlecloud]
4033
```

receiver/oktareceiver/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import (
2323
"go.opentelemetry.io/collector/config/configopaque"
2424
)
2525

26-
var (
26+
const (
2727
defaultPollInterval = time.Minute
2828

29-
// OktaTimeFormat ISO 8601 Format
30-
OktaTimeFormat = "2006-01-02T15:04:05Z"
29+
// oktaTimeFormat ISO 8601 Format
30+
oktaTimeFormat = "2006-01-02T15:04:05Z"
3131
)
3232

3333
// Config defines the configuration for an Okta receiver

receiver/oktareceiver/factory.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// Okta://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"fmt"
2020

21+
"github.com/okta/okta-sdk-golang/v6/okta"
2122
"go.opentelemetry.io/collector/component"
2223
"go.opentelemetry.io/collector/consumer"
2324
"go.opentelemetry.io/collector/receiver"
@@ -41,16 +42,22 @@ func createLogsReceiver(
4142
consumer consumer.Logs,
4243
) (receiver.Logs, error) {
4344
cfg := rConf.(*Config)
44-
r, err := newOktaLogsReceiver(cfg, params.Logger, consumer)
45+
46+
oktaCfg, err := okta.NewConfiguration(
47+
okta.WithOrgUrl("https://"+cfg.Domain),
48+
okta.WithToken(string(cfg.APIToken)),
49+
okta.WithCache(false),
50+
)
4551
if err != nil {
46-
return nil, fmt.Errorf("unable to create an Okta log receiver instance: %w", err)
52+
return nil, fmt.Errorf("failed to create okta client configuration: %w", err)
4753
}
48-
return r, nil
54+
55+
client := okta.NewAPIClient(oktaCfg)
56+
return newOktaLogsReceiver(cfg, params.Logger, consumer, client), nil
4957
}
5058

5159
func createDefaultConfig() component.Config {
52-
c := &Config{
60+
return &Config{
5361
PollInterval: defaultPollInterval,
5462
}
55-
return c
5663
}

receiver/oktareceiver/generated_package_test.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/oktareceiver/go.mod

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/observiq/bindplane-otel-contrib/receiver/oktareceiver
33
go 1.25.7
44

55
require (
6-
github.com/okta/okta-sdk-golang/v2 v2.20.0
6+
github.com/okta/okta-sdk-golang/v6 v6.1.6
77
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.149.0
88
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.149.0
99
github.com/stretchr/testify v1.11.1
@@ -18,27 +18,35 @@ require (
1818
)
1919

2020
require (
21-
github.com/BurntSushi/toml v1.6.0 // indirect
22-
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
21+
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
2322
github.com/cespare/xxhash/v2 v2.3.0 // indirect
24-
github.com/go-jose/go-jose/v3 v3.0.5 // indirect
23+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
24+
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
2525
github.com/go-logr/logr v1.4.3 // indirect
2626
github.com/go-logr/stdr v1.2.2 // indirect
2727
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
2828
github.com/gobwas/glob v0.2.3 // indirect
29+
github.com/goccy/go-json v0.10.5 // indirect
2930
github.com/google/uuid v1.6.0 // indirect
3031
github.com/hashicorp/go-version v1.8.0 // indirect
3132
github.com/json-iterator/go v1.1.12 // indirect
3233
github.com/kelseyhightower/envconfig v1.4.0 // indirect
3334
github.com/knadh/koanf/maps v0.1.2 // indirect
3435
github.com/knadh/koanf/providers/confmap v1.0.0 // indirect
3536
github.com/knadh/koanf/v2 v2.3.4 // indirect
37+
github.com/lestrrat-go/blackmagic v1.0.4 // indirect
38+
github.com/lestrrat-go/httpcc v1.0.1 // indirect
39+
github.com/lestrrat-go/httprc/v3 v3.0.1 // indirect
40+
github.com/lestrrat-go/jwx/v3 v3.0.12 // indirect
41+
github.com/lestrrat-go/option v1.0.1 // indirect
42+
github.com/lestrrat-go/option/v2 v2.0.0 // indirect
3643
github.com/mitchellh/copystructure v1.2.0 // indirect
3744
github.com/mitchellh/reflectwalk v1.0.2 // indirect
3845
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3946
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
4047
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.149.0 // indirect
4148
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
49+
github.com/segmentio/asm v1.2.1 // indirect
4250
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
4351
go.opentelemetry.io/collector/consumer/consumererror v0.149.0 // indirect
4452
go.opentelemetry.io/collector/consumer/xconsumer v0.149.0 // indirect
@@ -56,6 +64,7 @@ require (
5664
go.uber.org/multierr v1.11.0 // indirect
5765
go.yaml.in/yaml/v3 v3.0.4 // indirect
5866
golang.org/x/crypto v0.48.0 // indirect
67+
golang.org/x/oauth2 v0.34.0 // indirect
5968
golang.org/x/sys v0.42.0 // indirect
6069
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 // indirect
6170
google.golang.org/grpc v1.79.3 // indirect

0 commit comments

Comments
 (0)