Skip to content

Commit 8f2db90

Browse files
cuichenlicrobert-1sincejune
authored andcommitted
[chore][receiver/sqlserver] provide one generic configuration in readme (open-telemetry#40851)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description we now have many different configurations but the current readme does not have one generic readme that user can use directly. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> /cc @natalie-arsky --------- Co-authored-by: Curtis Robert <crobert@splunk.com> Co-authored-by: Chao Weng <19381524+sincejune@users.noreply.github.com>
1 parent 3a57531 commit 8f2db90

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

receiver/sqlserverreceiver/README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,32 @@ Make sure to run the collector as administrator in order to collect all performa
2323

2424
## Configuration
2525

26+
The following is a generic configuration that can be used for the default logs and metrics scraped
27+
by the SQL Server receiver. A basic explanation on some of the fields has also been provided. For more
28+
information, please reference the following section.
29+
30+
```yaml
31+
sqlserver:
32+
collection_interval: 10s # interval for overall collection
33+
instance_name: CustomInstance
34+
username: myusername
35+
password: mypassword
36+
server: sqlserver.address
37+
port: 1433
38+
events:
39+
db.server.query_sample:
40+
enabled: true
41+
db.server.top_query:
42+
enabled: true
43+
top_query_collection: # this collection exports the most expensive queries as logs
44+
lookback_time: 60 # which time window should we look for the top queries
45+
max_query_sample_count: 1000 # maximum number query we store in cache for top queries.
46+
top_query_count: 200 # The maximum number of active queries to report in a single run.
47+
collection_interval: 60s # collection interval for top query collection specifically
48+
query_sample_collection: # this collection exports the currently (relate to the query time) executing queries as logs
49+
max_rows_per_query: 100 # the maximum number of samples to return for one single query.
50+
```
51+
2652
The following settings are optional:
2753
- `collection_interval` (default = `10s`): The interval at which metrics should be emitted by this receiver.
2854
- `instance_name` (optional): The instance name identifies the specific SQL Server instance being monitored.
@@ -54,12 +80,9 @@ Top-Query collection specific options (only useful when top-query collection are
5480
- However, the top queries collection will only run after 60 seconds have passed since the last collection.
5581
- For instance, you have global `collection_interval` as `10s` and `top_query_collection.collection_interval` as `5s`.
5682
- In this case, `top_query_collection.collection_internal` will make no effects to the collection
57-
- `enabled`: (optional, default = `false`): Enable collection of top queries.
58-
- e.g. `sqlserver` receiver will fetch 1000 (value: `max_query_sample_count`) queries from database and report the top 200 (value: `top_query_count`) which used the most CPU time.
5983

6084
Query sample collection related options (only useful when query sample is enabled)
6185
- `max_rows_per_query`: (optional, default = `100`) use this to limit rows returned by the sampling query.
62-
- `enabled`: (optional, default = `false`): Enable collection of sample queries.
6386
Example:
6487

6588
```yaml
@@ -102,14 +125,11 @@ Top query collection enabled:
102125
server: 0.0.0.0
103126
port: 1433
104127
top_query_collection:
105-
enabled: true
106128
lookback_time: 60
107129
max_query_sample_count: 1000
108130
top_query_count: 200
109131
query_sample_collection:
110-
enabled: true
111132
max_rows_per_query: 1450
112-
113133
```
114134

115135
## Feature Gate

receiver/sqlserverreceiver/config_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package sqlserverreceiver
66
import (
77
"path/filepath"
88
"testing"
9+
"time"
910

1011
"github.com/google/go-cmp/cmp"
1112
"github.com/google/go-cmp/cmp/cmpopts"
@@ -165,7 +166,14 @@ func TestLoadConfig(t *testing.T) {
165166
},
166167
}
167168
expected.LogsBuilderConfig = metadata.LogsBuilderConfig{
168-
Events: metadata.DefaultEventsConfig(),
169+
Events: metadata.EventsConfig{
170+
DbServerQuerySample: metadata.EventConfig{
171+
Enabled: true,
172+
},
173+
DbServerTopQuery: metadata.EventConfig{
174+
Enabled: true,
175+
},
176+
},
169177
ResourceAttributes: metadata.ResourceAttributesConfig{
170178
HostName: metadata.ResourceAttributeConfig{
171179
Enabled: true,
@@ -192,6 +200,7 @@ func TestLoadConfig(t *testing.T) {
192200
expected.LookbackTime = 60
193201
expected.TopQueryCount = 200
194202
expected.MaxQuerySampleCount = 1000
203+
expected.TopQueryCollection.CollectionInterval = 80 * time.Second
195204

196205
expected.QuerySample = QuerySample{
197206
MaxRowsPerQuery: 1450,

receiver/sqlserverreceiver/testdata/config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@ sqlserver/named:
1818
lookback_time: 60
1919
max_query_sample_count: 1000
2020
top_query_count: 200
21+
collection_interval: 80s
2122
query_sample_collection:
2223
max_rows_per_query: 1450
24+
events:
25+
db.server.query_sample:
26+
enabled: true
27+
db.server.top_query:
28+
enabled: true

0 commit comments

Comments
 (0)