forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.go
156 lines (153 loc) · 4.77 KB
/
data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package info
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{
"clients": s.Object{
"connected": c.Int("connected_clients"),
"longest_output_list": c.Int("client_longest_output_list"),
"biggest_input_buf": c.Int("client_biggest_input_buf"),
"blocked": c.Int("blocked_clients"),
},
"cluster": s.Object{
"enabled": c.Bool("cluster_enabled"),
},
"cpu": s.Object{
"used": s.Object{
"sys": c.Float("used_cpu_sys"),
"user": c.Float("used_cpu_user"),
"sys_children": c.Float("used_cpu_sys_children"),
"user_children": c.Float("used_cpu_user_children"),
},
},
"memory": s.Object{
"used": s.Object{
"value": c.Int("used_memory"), // As it is a top key, this goes into value
"rss": c.Int("used_memory_rss"),
"peak": c.Int("used_memory_peak"),
"lua": c.Int("used_memory_lua"),
},
"allocator": c.Str("mem_allocator"), // Could be moved to server as it rarely changes
},
"persistence": s.Object{
"loading": c.Bool("loading"),
"rdb": s.Object{
"last_save": s.Object{
"changes_since": c.Int("rdb_changes_since_last_save"),
"time": c.Int("rdb_last_save_time"),
},
"bgsave": s.Object{
"last_status": c.Str("rdb_last_bgsave_status"),
"in_progress": c.Bool("rdb_bgsave_in_progress"),
"last_time": s.Object{
"sec": c.Int("rdb_last_bgsave_time_sec"),
},
"current_time": s.Object{
"sec": c.Int("rdb_current_bgsave_time_sec"),
},
},
},
"aof": s.Object{
"enabled": c.Bool("aof_enabled"),
"rewrite": s.Object{
"in_progress": c.Bool("aof_rewrite_in_progress"),
"scheduled": c.Bool("aof_rewrite_scheduled"),
"last_time": s.Object{
"sec": c.Int("aof_last_rewrite_time_sec"),
},
"current_time": s.Object{
"sec": c.Int("aof_current_rewrite_time_sec"),
},
},
"bgrewrite": s.Object{
"last_status": c.Str("aof_last_bgrewrite_status"),
},
"write": s.Object{
"last_status": c.Str("aof_last_write_status"),
},
},
},
"replication": s.Object{
"role": c.Str("role"),
"connected_slaves": c.Int("connected_slaves"),
"master_offset": c.Int("master_repl_offset"),
"backlog": s.Object{
"active": c.Int("repl_backlog_active"),
"size": c.Int("repl_backlog_size"),
"first_byte_offset": c.Int("repl_backlog_first_byte_offset"),
"histlen": c.Int("repl_backlog_histlen"),
},
},
"server": s.Object{
"version": c.Str("redis_version"),
"git_sha1": c.Str("redis_git_sha1"),
"git_dirty": c.Str("redis_git_dirty"),
"build_id": c.Str("redis_build_id"),
"mode": c.Str("redis_mode"),
"os": c.Str("os"),
"arch_bits": c.Str("arch_bits"),
"multiplexing_api": c.Str("multiplexing_api"),
"gcc_version": c.Str("gcc_version"),
"process_id": c.Int("process_id"),
"run_id": c.Str("run_id"),
"tcp_port": c.Int("tcp_port"),
"uptime": c.Int("uptime_in_seconds"), // Uptime days was removed as duplicate
"hz": c.Int("hz"),
"lru_clock": c.Int("lru_clock"),
"config_file": c.Str("config_file"),
},
"stats": s.Object{
"connections": s.Object{
"received": c.Int("total_connections_received"),
"rejected": c.Int("rejected_connections"),
},
"commands_processed": c.Int("total_commands_processed"),
"net": s.Object{
"input": s.Object{
"bytes": c.Int("total_net_input_bytes"),
},
"output": s.Object{
"bytes": c.Int("total_net_output_bytes"),
},
},
"instantaneous": s.Object{
"ops_per_sec": c.Int("instantaneous_ops_per_sec"),
"input_kbps": c.Float("instantaneous_input_kbps"),
"output_kbps": c.Float("instantaneous_output_kbps"),
},
"sync": s.Object{
"full": c.Int("sync_full"),
"partial": s.Object{
"ok": c.Int("sync_partial_ok"),
"err": c.Int("sync_partial_err"),
},
},
"keys": s.Object{
"expired": c.Int("expired_keys"),
"evicted": c.Int("evicted_keys"),
},
"keyspace": s.Object{
"hits": c.Int("keyspace_hits"),
"misses": c.Int("keyspace_misses"),
},
"pubsub": s.Object{
"channels": c.Int("pubsub_channels"),
"patterns": c.Int("pubsub_patterns"),
},
"latest_fork_usec": c.Int("latest_fork_usec"),
"migrate_cached_sockets": c.Int("migrate_cached_sockets"),
},
}
)
// Map data to MapStr
func eventMapping(info map[string]string) common.MapStr {
// Full mapping from info
source := map[string]interface{}{}
for key, val := range info {
source[key] = val
}
return schema.Apply(source)
}