-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add discoverybundler, initial embedded bundle.d, and enabled properties
- Loading branch information
1 parent
a809186
commit 53c15ed
Showing
29 changed files
with
999 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
## bundle.d | ||
|
||
`bundle.d` refers to the [`embed.FS`](https://pkg.go.dev/embed#hdr-File_Systems) config directory made available by the | ||
[`bundle.BundledFS`](./bundle.go). It currently consists of all `./bundle.d/extensions/*.discovery.yaml` and | ||
`./bundle.d/receivers/*.discovery.yaml` files that are generated by the `discoverybundler` cmd as used by `go:generate` | ||
directives in [bundle_gen.go](./bundle_gen.go). | ||
|
||
To construct the latest bundle.d contents before building the collector run: | ||
|
||
```bash | ||
$ make bundle.d | ||
``` | ||
|
||
### *.discovery.yaml.tmpl | ||
|
||
All discovery config component discovery.yaml files are generated from [`text/template`](https://pkg.go.dev/text/template) | ||
`discovery.yaml.tmpl` files using built-in validators and property guidance helpers: | ||
|
||
Example `redis.discovery.yaml.tmpl`: | ||
|
||
```yaml | ||
{{ receiver "redis" }}: | ||
rule: | ||
docker_observer: type == "container" and port == 6379 | ||
<...> | ||
status: | ||
<...> | ||
statements: | ||
partial: | ||
- regexp: 'ERR AUTH.*' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: >- | ||
Please ensure your redis password is correctly specified with | ||
`--set {{ configProperty "password" "<password>" }}` or | ||
`{{ configPropertyEnvVar "password" "<username>" }}` environment variable. | ||
``` | ||
After adding the required generate directive to `bundle_gen.go` and running `make bundle.d`: | ||
|
||
```go | ||
//go:generate discoverybundler -r -t bundle.d/receivers/redis.discovery.yaml.tmpl | ||
``` | ||
|
||
There is now a corresponding `bundle.d/receiver/redis.discovery.yaml`: | ||
|
||
```yaml | ||
##################################################################################### | ||
# This file is generated by the Splunk Distribution of the OpenTelemetry Collector. # | ||
##################################################################################### | ||
redis: | ||
rule: | ||
docker_observer: type == "container" and port == 6379 | ||
<...> | ||
status: | ||
<...> | ||
statements: | ||
partial: | ||
- regexp: 'ERR AUTH.*' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: >- | ||
Please ensure your redis password is correctly specified with | ||
`--set splunk.discovery.receivers.redis.config.password="<password>"` or | ||
`SPLUNK_DISCOVERY_RECEIVERS_redis_CONFIG_password="<username>"` environment variable. | ||
``` | ||
|
||
When building the collector afterward, this redis receiver discovery config is now made available to discovery mode, and | ||
it can be disabled by `--set splunk.discovery.receivers.redis.enabled=false` or | ||
`SPLUNK_DISCOVERY_RECEIVERS_redis_ENABLED=false`. |
4 changes: 4 additions & 0 deletions
4
internal/confmapprovider/discovery/bundle/bundle.d/extensions/docker-observer.discovery.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
##################################################################################### | ||
# This file is generated by the Splunk Distribution of the OpenTelemetry Collector. # | ||
##################################################################################### | ||
docker_observer: |
1 change: 1 addition & 0 deletions
1
.../confmapprovider/discovery/bundle/bundle.d/extensions/docker-observer.discovery.yaml.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ extension "docker_observer" }}: |
4 changes: 4 additions & 0 deletions
4
internal/confmapprovider/discovery/bundle/bundle.d/extensions/host-observer.discovery.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
##################################################################################### | ||
# This file is generated by the Splunk Distribution of the OpenTelemetry Collector. # | ||
##################################################################################### | ||
host_observer: |
1 change: 1 addition & 0 deletions
1
...al/confmapprovider/discovery/bundle/bundle.d/extensions/host-observer.discovery.yaml.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ extension "host_observer" }}: |
5 changes: 5 additions & 0 deletions
5
internal/confmapprovider/discovery/bundle/bundle.d/extensions/k8s-observer.discovery.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
##################################################################################### | ||
# This file is generated by the Splunk Distribution of the OpenTelemetry Collector. # | ||
##################################################################################### | ||
k8s_observer: | ||
auth_type: serviceAccount |
2 changes: 2 additions & 0 deletions
2
...nal/confmapprovider/discovery/bundle/bundle.d/extensions/k8s-observer.discovery.yaml.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{ extension "k8s_observer" }}: | ||
auth_type: serviceAccount |
49 changes: 49 additions & 0 deletions
49
.../confmapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
##################################################################################### | ||
# This file is generated by the Splunk Distribution of the OpenTelemetry Collector. # | ||
##################################################################################### | ||
smartagent/postgresql: | ||
rule: | ||
docker_observer: type == "container" and port == 5432 | ||
host_observer: type == "hostport" and command contains "pg" and port == 5432 | ||
config: | ||
default: | ||
type: postgresql | ||
connectionString: 'sslmode=disable user={{.username}} password={{.password}}' | ||
params: | ||
username: bundle.default | ||
password: bundle.default | ||
masterDBName: postgres | ||
status: | ||
metrics: | ||
successful: | ||
- strict: postgres_block_hit_ratio | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: postgresql SA receiver working! | ||
statements: | ||
failed: | ||
- regexp: '.* connect: connection refused' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: container appears to not be accepting postgres connections | ||
partial: | ||
- regexp: '.*pq: password authentication failed for user.*' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: >- | ||
Please ensure your user credentials are correctly specified with | ||
`--set splunk.discovery.receivers.smartagent/postgresql.config.params::username="<username>"` and | ||
`--set splunk.discovery.receivers.smartagent/postgresql.config.params::password="<password>"` or | ||
`SPLUNK_DISCOVERY_RECEIVERS_smartagent_x2f_postgresql_CONFIG_params_x3a__x3a_username="<username>"` and | ||
`SPLUNK_DISCOVERY_RECEIVERS_smartagent_x2f_postgresql_CONFIG_params_x3a__x3a_password="<password>"` environment variables. | ||
- regexp: '.*pq: database ".*" does not exist.*' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: >- | ||
Please ensure your target database is correctly specified with | ||
`--set splunk.discovery.receivers.smartagent/postgresql.config.masterDBName="<db>"` or | ||
`SPLUNK_DISCOVERY_RECEIVERS_smartagent_x2f_postgresql_CONFIG_masterDBName="<db>"` environment variable. |
46 changes: 46 additions & 0 deletions
46
...mapprovider/discovery/bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{{ receiver "smartagent/postgresql" }}: | ||
rule: | ||
docker_observer: type == "container" and port == 5432 | ||
host_observer: type == "hostport" and command contains "pg" and port == 5432 | ||
config: | ||
default: | ||
type: postgresql | ||
connectionString: 'sslmode=disable user={{ "{{.username}}" }} password={{ "{{.password}}" }}' | ||
params: | ||
username: bundle.default | ||
password: bundle.default | ||
masterDBName: postgres | ||
status: | ||
metrics: | ||
successful: | ||
- strict: postgres_block_hit_ratio | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: postgresql SA receiver working! | ||
statements: | ||
failed: | ||
- regexp: '.* connect: connection refused' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: container appears to not be accepting postgres connections | ||
partial: | ||
- regexp: '.*pq: password authentication failed for user.*' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: >- | ||
Please ensure your user credentials are correctly specified with | ||
`--set {{ configProperty "params" "username" "<username>" }}` and | ||
`--set {{ configProperty "params" "password" "<password>" }}` or | ||
`{{ configPropertyEnvVar "params" "username" "<username>" }}` and | ||
`{{ configPropertyEnvVar "params" "password" "<password>" }}` environment variables. | ||
- regexp: '.*pq: database ".*" does not exist.*' | ||
first_only: true | ||
log_record: | ||
severity_text: info | ||
body: >- | ||
Please ensure your target database is correctly specified with | ||
`--set {{ configProperty "masterDBName" "<db>" }}` or | ||
`{{ configPropertyEnvVar "masterDBName" "<db>" }}` environment variable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright Splunk, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package bundle | ||
|
||
import ( | ||
"embed" | ||
) | ||
|
||
// BundledFS is the in-executable filesystem that contains all bundled discovery config.d components. | ||
// | ||
// If you are bootstrapping bundle_gen.go or the `discoverybundler` cmd without any rendered files in bundle.d, | ||
// comment out the below embed directives before installing to prevent "no matching files found" | ||
// build errors. | ||
// | ||
//go:embed bundle.d/extensions/*.discovery.yaml | ||
//go:embed bundle.d/receivers/*.discovery.yaml | ||
var BundledFS embed.FS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright Splunk, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build bundle.d | ||
|
||
// These are the discovery config component generating statements. | ||
// In order to update run go generate -tags bundle.d ./... | ||
//go:generate go install github.com/signalfx/splunk-otel-collector/internal/confmapprovider/discovery/bundle/cmd/discoverybundler | ||
|
||
//go:generate discoverybundler -r -t bundle.d/receivers/smartagent-postgresql.discovery.yaml.tmpl | ||
|
||
//go:generate discoverybundler -r -t bundle.d/extensions/docker-observer.discovery.yaml.tmpl | ||
//go:generate discoverybundler -r -t bundle.d/extensions/host-observer.discovery.yaml.tmpl | ||
//go:generate discoverybundler -r -t bundle.d/extensions/k8s-observer.discovery.yaml.tmpl | ||
|
||
package bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright Splunk, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package bundle | ||
|
||
import ( | ||
"io/fs" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestBundleDir(t *testing.T) { | ||
receivers, err := fs.Glob(BundledFS, "bundle.d/receivers/*.discovery.yaml") | ||
require.NoError(t, err) | ||
require.Equal(t, []string{ | ||
"bundle.d/receivers/smartagent-postgresql.discovery.yaml", | ||
}, receivers) | ||
|
||
extensions, err := fs.Glob(BundledFS, "bundle.d/extensions/*.discovery.yaml") | ||
require.NoError(t, err) | ||
require.Equal(t, []string{ | ||
"bundle.d/extensions/docker-observer.discovery.yaml", | ||
"bundle.d/extensions/host-observer.discovery.yaml", | ||
"bundle.d/extensions/k8s-observer.discovery.yaml", | ||
}, extensions) | ||
} |
Oops, something went wrong.