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

Enhance the buffer cache hit ratio calculations for performance metrics #40022

Merged
merged 14 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Add SSL support for aerospike module {pull}38126[38126]
- Add last_terminated_timestamp metric in kubernetes module {pull}39200[39200] {issue}3802[3802]
- Add pod.status.ready_time and pod.status.reason metrics in kubernetes module {pull}39316[39316]
- Add "Buffer cache hit ratio base" to calculate "Buffer cache hit ratio" for performance metrics {pull}40022[40022]


*Metricbeat*
Expand Down
17 changes: 14 additions & 3 deletions x-pack/metricbeat/module/mssql/performance/performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
func (m *MetricSet) Fetch(reporter mb.ReporterV2) {
var err error
var rows *sql.Rows
var buffer_cache_hit_ratio, buffer_cache_hit_ratio_base int64
anil-elastic marked this conversation as resolved.
Show resolved Hide resolved
bufferCacheHitRatio := "Buffer cache hit ratio"
bufferCacheHitRatioBase := "Buffer cache hit ratio base"
rows, err = m.db.Query(`SELECT object_name,
counter_name,
instance_name,
Expand All @@ -80,6 +83,7 @@ WHERE counter_name = 'SQL Compilations/sec'
AND instance_name = '_Total' )
OR ( counter_name IN ( 'Page life expectancy',
'Buffer cache hit ratio',
'Buffer cache hit ratio base',
'Target pages', 'Database pages',
'Checkpoint pages/sec' )
AND object_name LIKE '%:Buffer Manager%' )
Expand Down Expand Up @@ -112,13 +116,20 @@ WHERE counter_name = 'SQL Compilations/sec'
row.instanceName = strings.TrimSpace(row.instanceName)
row.objectName = strings.TrimSpace(row.objectName)

if row.counterName == "Buffer cache hit ratio" {
mapStr[row.counterName] = fmt.Sprintf("%v", float64(*row.counterValue)/100)
} else {
switch row.counterName {
case bufferCacheHitRatio:
buffer_cache_hit_ratio = *row.counterValue
case bufferCacheHitRatioBase:
buffer_cache_hit_ratio_base = *row.counterValue
default:
mapStr[row.counterName] = fmt.Sprintf("%v", *row.counterValue)
}
}

if buffer_cache_hit_ratio_base != 0 {
mapStr[bufferCacheHitRatio] = fmt.Sprintf("%f", float64(buffer_cache_hit_ratio)/float64(buffer_cache_hit_ratio_base))
}

res, err := schema.Apply(mapStr)
if err != nil {
m.log.Error(fmt.Errorf("error applying schema %w", err))
Expand Down
Loading