Skip to content

Commit

Permalink
Merge branch '2429-sqlserver-number-transform-bug' into 'dev'
Browse files Browse the repository at this point in the history
Resolve "sqlserver 采集器数据转换问题"

See merge request cloudcare-tools/datakit!3245
  • Loading branch information
谭彪 committed Oct 30, 2024
2 parents 758cf0f + 29b10eb commit 4989403
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,6 @@ internal/plugins/externals/ebpf/demo/
internal/plugins/externals/ebpf/internal/testuitls/mysqlins/mysqlins
internal/export/doc/zh/inputs/imgs/tracing.png
/git

# web cache
node_modules
10 changes: 6 additions & 4 deletions internal/plugins/inputs/sqlserver/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,22 @@ func (ipt *Input) getPerformanceCounters() {

if key == "cntr_value" {
// the raw value is a number and the key is cntr_value, store in fields
if v, err := strconv.ParseUint(raw, 10, 64); err == nil {
if v > uint64(math.MaxInt64) {
l.Warnf("%s exceed maxint64: %d > %d, ignored", key, v, int64(math.MaxInt64))
if v, err := strconv.ParseFloat(raw, 64); err == nil {
if v > math.MaxInt64 {
l.Warnf("%s exceed maxint64: %d > %d, ignored", key, v, math.MaxInt64)
continue
}
// store the counter_name and cntr_value as fields
if counterName == "buffer_cache_hit_ratio" {
fields[counterName] = float64(v)
fields[counterName] = v
} else {
fields[counterName] = int64(v)
}

// remain the original format for "cntr_value": cntr_value
fields[key] = int64(v)
} else {
l.Warnf("parse %s failed: %s", key, raw)
}
} else {
str := strings.TrimSuffix(raw, "\\")
Expand Down

0 comments on commit 4989403

Please sign in to comment.