Skip to content

Commit

Permalink
[discovery] Enable discovery mode for SQL Server receiver (#5109)
Browse files Browse the repository at this point in the history
* SQL Server auto discovery

* Update CHANGELOG.md

* Update cmd/otelcol/config/collector/config.d.linux/receivers/sqlserver.discovery.yaml

* Update internal/confmapprovider/discovery/README.md

Co-authored-by: jvoravong <47871238+jvoravong@users.noreply.github.com>

* Remove duplicate instructions, keep just the env variables

---------

Co-authored-by: jvoravong <47871238+jvoravong@users.noreply.github.com>
Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>
Co-authored-by: Antoine Toulme <antoine@lunar-ocean.com>
  • Loading branch information
4 people authored Jul 29, 2024
1 parent a067a16 commit 07d294a
Show file tree
Hide file tree
Showing 11 changed files with 310 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### 💡 Enhancements 💡

- (Splunk) `discovery`: Enable discovery mode for SQL Server receiver ([#5109](https://github.com/signalfx/splunk-otel-collector/pull/5109))
- (Splunk) Update bundled OpenJDK to [11.0.24_8](https://github.com/adoptium/temurin11-binaries/releases/tag/jdk-11.0.24%2B8) ([#5113](https://github.com/signalfx/splunk-otel-collector/pull/5113))

## v0.104.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#####################################################################################
# This file is generated by the Splunk Distribution of the OpenTelemetry Collector. #
# #
# It reflects the default configuration bundled in the Collector executable for use #
# in discovery mode (--discovery) and is provided for reference or customization. #
# Please note that any changes made to this file will need to be reconciled during #
# upgrades of the Collector. #
#####################################################################################
# sqlserver:
# enabled: true
# rule:
# docker_observer: type == "container" and any([name, image, command], {# matches "(?i)mssql"}) and not (command matches "splunk.discovery")
# host_observer: type == "hostport" and command matches "(?i)mssql" and not (command matches "splunk.discovery")
# k8s_observer: type == "port" and pod.name matches "(?i)mssql"
# config:
# default:
# username: splunk.discovery.default
# password: splunk.discovery.default
# server: '`host`'
# port: '`port`'
# resource_attributes:
# sqlserver.instance.name:
# enabled: true
# metrics:
# # Enable all OOTB dashboard default metrics
# sqlserver.batch.request.rate:
# enabled: true
# sqlserver.batch.sql_compilation.rate:
# enabled: true
# sqlserver.batch.sql_recompilation.rate:
# enabled: true
# sqlserver.database.count:
# enabled: true
# sqlserver.database.io:
# enabled: true
# sqlserver.database.latency:
# enabled: true
# sqlserver.database.operations:
# enabled: true
# sqlserver.lock.wait.rate:
# enabled: true
# sqlserver.page.buffer_cache.hit_ratio:
# enabled: true
# sqlserver.processes.blocked:
# enabled: true
# sqlserver.resource_pool.disk.throttled.read.rate:
# enabled: true
# sqlserver.resource_pool.disk.throttled.write.rate:
# enabled: true
# sqlserver.user.connection.count:
# enabled: true
# # Disable upstream default metrics that OOTB dashboards don't use
# sqlserver.lock.wait_time.avg:
# enabled: false
# sqlserver.page.checkpoint.flush.rate:
# enabled: false
# sqlserver.page.lazy_write.rate:
# enabled: false
# sqlserver.page.life_expectancy:
# enabled: false
# sqlserver.page.operation.rate:
# enabled: false
# sqlserver.page.split.rate:
# enabled: false
# sqlserver.transaction.rate:
# enabled: false
# sqlserver.transaction.write.rate:
# enabled: false
# sqlserver.transaction_log.flush.data.rate:
# enabled: false
# sqlserver.transaction_log.flush.rate:
# enabled: false
# sqlserver.transaction_log.flush.wait.rate:
# enabled: false
# sqlserver.transaction_log.growth.count:
# enabled: false
# sqlserver.transaction_log.shrink.count:
# enabled: false
# sqlserver.transaction_log.usage:
# enabled: false
#
# status:
# metrics:
# - status: successful
# strict: sqlserver.database.io
# message: sqlserver receiver is working!
# statements:
# - status: failed
# regexp: "connection refused"
# message: The container is not serving http connections.
# - status: failed
# regexp: "unable to open tcp connection"
# message: Unable to resolve sql server tcp endpoint
# - status: partial
# regexp: "Login failed for user"
# message: >-
# Make sure your user credentials are correctly specified using the
# `SPLUNK_DISCOVERY_RECEIVERS_sqlserver_CONFIG_username="<username>"` and
# `SPLUNK_DISCOVERY_RECEIVERS_sqlserver_CONFIG_password="<password>"` environment variables.
# - status: partial
# regexp: "The user does not have permission"
# message: >-
# Specified user does not have proper permissions. User must have view `SERVER STATE` permissions.
# This can be accomplished by: `GRANT VIEW SERVER STATE TO [username]`
1 change: 1 addition & 0 deletions internal/confmapprovider/discovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ I. Receivers
* `smartagent` with `collectd/mysql` monitor type ([Linux](./bundle/bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml))
* `smartagent` with `collectd/nginx` monitor type ([Linux](./bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml))
* `smartagent` with `postgresql` monitor type ([Linux and Windows](./bundle/bundle.d/receivers/smartagent-postgresql.discovery.yaml))
* `sqlserver` ([Linux And Windows](./bundle/bundle.d/receivers/sqlserver.discovery.yaml))

II. Extensions
* `docker_observer` ([Linux and Windows](./bundle/bundle.d/extensions/docker-observer.discovery.yaml))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#####################################################################################
# Do not edit manually! #
# All changes must be made to associated .tmpl file before running 'make bundle.d'. #
#####################################################################################
sqlserver:
enabled: true
rule:
docker_observer: type == "container" and any([name, image, command], {# matches "(?i)mssql"}) and not (command matches "splunk.discovery")
host_observer: type == "hostport" and command matches "(?i)mssql" and not (command matches "splunk.discovery")
k8s_observer: type == "port" and pod.name matches "(?i)mssql"
config:
default:
username: splunk.discovery.default
password: splunk.discovery.default
server: '`host`'
port: '`port`'
resource_attributes:
sqlserver.instance.name:
enabled: true
metrics:
# Enable all OOTB dashboard default metrics
sqlserver.batch.request.rate:
enabled: true
sqlserver.batch.sql_compilation.rate:
enabled: true
sqlserver.batch.sql_recompilation.rate:
enabled: true
sqlserver.database.count:
enabled: true
sqlserver.database.io:
enabled: true
sqlserver.database.latency:
enabled: true
sqlserver.database.operations:
enabled: true
sqlserver.lock.wait.rate:
enabled: true
sqlserver.page.buffer_cache.hit_ratio:
enabled: true
sqlserver.processes.blocked:
enabled: true
sqlserver.resource_pool.disk.throttled.read.rate:
enabled: true
sqlserver.resource_pool.disk.throttled.write.rate:
enabled: true
sqlserver.user.connection.count:
enabled: true
# Disable upstream default metrics that OOTB dashboards don't use
sqlserver.lock.wait_time.avg:
enabled: false
sqlserver.page.checkpoint.flush.rate:
enabled: false
sqlserver.page.lazy_write.rate:
enabled: false
sqlserver.page.life_expectancy:
enabled: false
sqlserver.page.operation.rate:
enabled: false
sqlserver.page.split.rate:
enabled: false
sqlserver.transaction.rate:
enabled: false
sqlserver.transaction.write.rate:
enabled: false
sqlserver.transaction_log.flush.data.rate:
enabled: false
sqlserver.transaction_log.flush.rate:
enabled: false
sqlserver.transaction_log.flush.wait.rate:
enabled: false
sqlserver.transaction_log.growth.count:
enabled: false
sqlserver.transaction_log.shrink.count:
enabled: false
sqlserver.transaction_log.usage:
enabled: false

status:
metrics:
- status: successful
strict: sqlserver.database.io
message: sqlserver receiver is working!
statements:
- status: failed
regexp: "connection refused"
message: The container is not serving http connections.
- status: failed
regexp: "unable to open tcp connection"
message: Unable to resolve sql server tcp endpoint
- status: partial
regexp: "Login failed for user"
message: >-
Make sure your user credentials are correctly specified using the
`SPLUNK_DISCOVERY_RECEIVERS_sqlserver_CONFIG_username="<username>"` and
`SPLUNK_DISCOVERY_RECEIVERS_sqlserver_CONFIG_password="<password>"` environment variables.
- status: partial
regexp: "The user does not have permission"
message: >-
Specified user does not have proper permissions. User must have view `SERVER STATE` permissions.
This can be accomplished by: `GRANT VIEW SERVER STATE TO [username]`
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{{ receiver "sqlserver" }}:
enabled: true
rule:
docker_observer: type == "container" and any([name, image, command], {# matches "(?i)mssql"}) and not (command matches "splunk.discovery")
host_observer: type == "hostport" and command matches "(?i)mssql" and not (command matches "splunk.discovery")
k8s_observer: type == "port" and pod.name matches "(?i)mssql"
config:
default:
username: {{ defaultValue }}
password: {{ defaultValue }}
server: '`host`'
port: '`port`'
resource_attributes:
sqlserver.instance.name:
enabled: true
metrics:
# Enable all OOTB dashboard default metrics
sqlserver.batch.request.rate:
enabled: true
sqlserver.batch.sql_compilation.rate:
enabled: true
sqlserver.batch.sql_recompilation.rate:
enabled: true
sqlserver.database.count:
enabled: true
sqlserver.database.io:
enabled: true
sqlserver.database.latency:
enabled: true
sqlserver.database.operations:
enabled: true
sqlserver.lock.wait.rate:
enabled: true
sqlserver.page.buffer_cache.hit_ratio:
enabled: true
sqlserver.processes.blocked:
enabled: true
sqlserver.resource_pool.disk.throttled.read.rate:
enabled: true
sqlserver.resource_pool.disk.throttled.write.rate:
enabled: true
sqlserver.user.connection.count:
enabled: true
# Disable upstream default metrics that OOTB dashboards don't use
sqlserver.lock.wait_time.avg:
enabled: false
sqlserver.page.checkpoint.flush.rate:
enabled: false
sqlserver.page.lazy_write.rate:
enabled: false
sqlserver.page.life_expectancy:
enabled: false
sqlserver.page.operation.rate:
enabled: false
sqlserver.page.split.rate:
enabled: false
sqlserver.transaction.rate:
enabled: false
sqlserver.transaction.write.rate:
enabled: false
sqlserver.transaction_log.flush.data.rate:
enabled: false
sqlserver.transaction_log.flush.rate:
enabled: false
sqlserver.transaction_log.flush.wait.rate:
enabled: false
sqlserver.transaction_log.growth.count:
enabled: false
sqlserver.transaction_log.shrink.count:
enabled: false
sqlserver.transaction_log.usage:
enabled: false

status:
metrics:
- status: successful
strict: sqlserver.database.io
message: sqlserver receiver is working!
statements:
- status: failed
regexp: "connection refused"
message: The container is not serving http connections.
- status: failed
regexp: "unable to open tcp connection"
message: Unable to resolve sql server tcp endpoint
- status: partial
regexp: "Login failed for user"
message: >-
Make sure your user credentials are correctly specified using the
`{{ configPropertyEnvVar "username" "<username>" }}` and
`{{ configPropertyEnvVar "password" "<password>" }}` environment variables.
- status: partial
regexp: "The user does not have permission"
message: >-
Specified user does not have proper permissions. User must have view `SERVER STATE` permissions.
This can be accomplished by: `GRANT VIEW SERVER STATE TO [username]`
2 changes: 2 additions & 0 deletions internal/confmapprovider/discovery/bundle/bundle_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml.tmpl
//go:generate discoverybundler -r -t bundle.d/receivers/smartagent-postgresql.discovery.yaml.tmpl
//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/smartagent-postgresql.discovery.yaml.tmpl
//go:generate discoverybundler -r -t bundle.d/receivers/sqlserver.discovery.yaml.tmpl
//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/sqlserver.discovery.yaml.tmpl

package bundle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestBundleDir(t *testing.T) {
"bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml",
"bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml",
"bundle.d/receivers/smartagent-postgresql.discovery.yaml",
"bundle.d/receivers/sqlserver.discovery.yaml",
}, receivers)

extensions, err := fs.Glob(BundledFS, "bundle.d/extensions/*.discovery.yaml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ import (
//go:embed bundle.d/receivers/smartagent-collectd-mysql.discovery.yaml
//go:embed bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml
//go:embed bundle.d/receivers/smartagent-postgresql.discovery.yaml
//go:embed bundle.d/receivers/sqlserver.discovery.yaml
var BundledFS embed.FS
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ import (
//go:embed bundle.d/receivers/postgresql.discovery.yaml
//go:embed bundle.d/receivers/redis.discovery.yaml
//go:embed bundle.d/receivers/smartagent-postgresql.discovery.yaml
//go:embed bundle.d/receivers/sqlserver.discovery.yaml
var BundledFS embed.FS
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestBundleDir(t *testing.T) {
"bundle.d/receivers/postgresql.discovery.yaml",
"bundle.d/receivers/redis.discovery.yaml",
"bundle.d/receivers/smartagent-postgresql.discovery.yaml",
"bundle.d/receivers/sqlserver.discovery.yaml",
}, receivers)

extensions, err := fs.Glob(BundledFS, "bundle.d/extensions/*.discovery.yaml")
Expand Down
2 changes: 2 additions & 0 deletions internal/confmapprovider/discovery/bundle/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var (
"smartagent-collectd-mysql",
"smartagent-collectd-nginx",
"smartagent-postgresql",
"sqlserver",
}

Components = DiscoComponents{
Expand Down Expand Up @@ -72,6 +73,7 @@ var (
"postgresql": {},
"redis": {},
"smartagent-postgresql": {},
"sqlserver": {},
}
for _, extension := range extensions {
windows[extension] = struct{}{}
Expand Down

0 comments on commit 07d294a

Please sign in to comment.