Skip to content
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

allow multi instance sql server #30859

Merged
merged 8 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
- Errors should be thrown as errors. Metricsets inside Metricbeat will now throw errors as the `error` log level. {pull}27804[27804]
- Avoid panicking in `add_fields` processor when input event.Fields is a nil map. {pull}28219[28219]
- Drop event batch when get HTTP status 413 from Elasticsearch to avoid infinite loop {issue}14350[14350] {pull}29368[29368]
- Allow to use metricbeat for named mssql instances. {issue}24076[24076] {pull}30859[30859]

==== Added

Expand Down
26 changes: 13 additions & 13 deletions x-pack/metricbeat/module/mssql/performance/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
"mssql": {
"performance": {
"active_temp_tables": 0,
"batch_requests_per_sec": 3355,
"batch_requests_per_sec": 7453,
"buffer": {
"cache_hit": {
"pct": 0.22
"pct": 0.55
},
"checkpoint_pages_per_sec": 295,
"database_pages": 2152,
"checkpoint_pages_per_sec": 124,
"database_pages": 2191,
"page_life_expectancy": {
"sec": 1400
"sec": 2721
},
"target_pages": 3178496
"target_pages": 1589248
},
"compilations_per_sec": 1151,
"connections_reset_per_sec": 88,
"lock_waits_per_sec": 6,
"logins_per_sec": 1105,
"logouts_per_sec": 1103,
"page_splits_per_sec": 14,
"recompilations_per_sec": 2,
"compilations_per_sec": 2503,
"connections_reset_per_sec": 61,
"lock_waits_per_sec": 4,
"logins_per_sec": 2448,
"logouts_per_sec": 2446,
"page_splits_per_sec": 15,
"recompilations_per_sec": 0,
"transactions": 0,
"user_connections": 2
}
Expand Down
43 changes: 15 additions & 28 deletions x-pack/metricbeat/module/mssql/performance/performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (

"github.com/elastic/beats/v7/libbeat/common"

"github.com/pkg/errors"

"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/metricbeat/mb"
"github.com/elastic/beats/v7/x-pack/metricbeat/module/mssql"
Expand Down Expand Up @@ -52,7 +50,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

db, err := mssql.NewConnection(base.HostData().URI)
if err != nil {
return nil, errors.Wrap(err, "could not create connection to db")
return nil, fmt.Errorf("could not create connection to db %w", err)
}

return &MetricSet{
Expand All @@ -77,34 +75,23 @@ WHERE counter_name = 'SQL Compilations/sec'
OR counter_name = 'SQL Re-Compilations/sec'
OR counter_name = 'User Connections'
OR counter_name = 'Page splits/sec'
OR ( counter_name = 'Lock Waits/sec'
AND instance_name = '_Total' )
OR counter_name = 'Page splits/sec'
OR ( object_name = 'SQLServer:Buffer Manager'
AND counter_name = 'Page life expectancy' )
OR counter_name = 'Batch Requests/sec'
OR ( counter_name = 'Buffer cache hit ratio'
AND object_name = 'SQLServer:Buffer Manager' )
OR ( counter_name = 'Target pages'
AND object_name = 'SQLServer:Buffer Manager' )
OR ( counter_name = 'Database pages'
AND object_name = 'SQLServer:Buffer Manager' )
OR ( counter_name = 'Checkpoint pages/sec'
AND object_name = 'SQLServer:Buffer Manager' )
OR ( counter_name = 'Lock Waits/sec'
AND instance_name = '_Total' )
OR ( counter_name = 'Transactions'
AND object_name = 'SQLServer:General Statistics' )
OR ( counter_name = 'Logins/sec'
AND object_name = 'SQLServer:General Statistics' )
OR ( counter_name = 'Logouts/sec'
AND object_name = 'SQLServer:General Statistics' )
OR ( counter_name = 'Connection Reset/sec'
AND object_name = 'SQLServer:General Statistics' )
OR ( counter_name = 'Active Temp Tables'
AND object_name = 'SQLServer:General Statistics' )`)
OR ( counter_name IN ( 'Page life expectancy',
'Buffer cache hit ratio',
'Target pages', 'Database pages',
'Checkpoint pages/sec' )
AND object_name LIKE '%:Buffer Manager%' )
OR ( counter_name IN ( 'Transactions',
'Logins/sec',
'Logouts/sec',
'Connection Reset/sec',
'Active Temp Tables' )
AND object_name LIKE '%:General Statistics%' )`)
if err != nil {
reporter.Error(errors.Wrapf(err, "error closing rows"))
reporter.Error(fmt.Errorf("error closing rows %w", err))
return
}
defer func() {
Expand All @@ -117,7 +104,7 @@ WHERE counter_name = 'SQL Compilations/sec'
for rows.Next() {
var row performanceCounter
if err = rows.Scan(&row.objectName, &row.counterName, &row.instanceName, &row.counterValue); err != nil {
reporter.Error(errors.Wrap(err, "error scanning rows"))
reporter.Error(fmt.Errorf("error scanning rows %w", err))
continue
}

Expand All @@ -135,7 +122,7 @@ WHERE counter_name = 'SQL Compilations/sec'

res, err := schema.Apply(mapStr)
if err != nil {
m.log.Error(errors.Wrap(err, "error applying schema"))
m.log.Error(fmt.Errorf("error applying schema %w", err))
return
}

Expand Down