1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
data.go 2.18 KB
一键复制 编辑 原始数据 按行查看 历史
package status
import (
"github.com/elastic/beats/libbeat/common"
s "github.com/elastic/beats/metricbeat/schema"
c "github.com/elastic/beats/metricbeat/schema/mapstrstr"
)
var (
schema = s.Schema{
"aborted": s.Object{
"clients": c.Int("Aborted_clients"),
"connects": c.Int("Aborted_connects"),
},
"binlog": s.Object{
"cache": s.Object{
"disk_use": c.Int("Binlog_cache_disk_use"),
"use": c.Int("Binlog_cache_use"),
},
},
"bytes": s.Object{
"received": c.Int("Bytes_received"),
"sent": c.Int("Bytes_sent"),
},
"threads": s.Object{
"cached": c.Int("Threads_cached"),
"created": c.Int("Threads_created"),
"connected": c.Int("Threads_connected"),
"running": c.Int("Threads_running"),
},
"connections": c.Int("Connections"),
"created": s.Object{
"tmp": s.Object{
"disk_tables": c.Int("Created_tmp_disk_tables"),
"files": c.Int("Created_tmp_files"),
"tables": c.Int("Created_tmp_tables"),
},
},
"delayed": s.Object{
"errors": c.Int("Delayed_errors"),
"insert_threads": c.Int("Delayed_insert_threads"),
"writes": c.Int("Delayed_writes"),
},
"flush_commands": c.Int("Flush_commands"),
"max_used_connections": c.Int("Max_used_connections"),
"open": s.Object{
"files": c.Int("Open_files"),
"streams": c.Int("Open_streams"),
"tables": c.Int("Open_tables"),
},
"opened_tables": c.Int("Opened_tables"),
"command": s.Object{
"delete": c.Int("Com_delete"),
"insert": c.Int("Com_insert"),
"select": c.Int("Com_select"),
"update": c.Int("Com_update"),
},
}
)
// Map data to MapStr of server stats variables: http://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html
// This is only a subset of the available values
func eventMapping(status map[string]string) common.MapStr {
source := map[string]interface{}{}
for key, val := range status {
source[key] = val
}
return schema.Apply(source)
}
func rawEventMapping(status map[string]string) common.MapStr {
source := common.MapStr{}
for key, val := range status {
// Only adds events which are not in the mapping
if schema.HasKey(key) {
continue
}
source[key] = val
}
return source
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v5.4.0

搜索帮助