Skip to content

Commit b926a10

Browse files
Merge pull request #79 from Sharpie/SUP-2195-add-postgres-tagging
(SUP-2195) Update json2timeseriesdb to tag Postgres metrics
2 parents 778873e + b958ec8 commit b926a10

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

files/json2timeseriesdb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,35 @@ def influx_tag_parser(tag)
240240
tag.delete('broker-service')
241241
end
242242

243+
if tag.include?('postgres') && tag.include?('databases')
244+
n = tag.index('databases')
245+
db_name = tag[n + 1]
246+
tag_set = "#{tag_set}database=#{db_name},"
247+
tag.delete_at(n + 1)
248+
end
249+
250+
if tag.include?('postgres') && tag.include?('replication_slots')
251+
n = tag.index('replication_slots')
252+
slot_name = tag[n + 1]
253+
tag_set = "#{tag_set}replication_slot=#{slot_name}"
254+
tag.delete_at(n + 1)
255+
end
256+
257+
if tag.include?('postgres') && tag.include?('replication_subs')
258+
n = tag.index('replication_subs')
259+
slot_name = tag[n + 1]
260+
tag_set = "#{tag_set}replication_slot=#{slot_name}"
261+
tag.delete_at(n + 1)
262+
end
263+
264+
if tag.include?('postgres') && ['table_stats', 'index_stats', 'toast_stats'].any? {|e| tag.include?(e)}
265+
metric = ['table_stats', 'index_stats', 'toast_stats'].find {|e| tag.include?(e)}
266+
n = tag.index(metric)
267+
relation = tag[n + 1]
268+
tag_set = "#{tag_set}relation=#{relation}"
269+
tag.delete_at(n + 1)
270+
end
271+
243272
if tag.include?('Queue')
244273
n = tag.index('Queue')
245274
amq_destination_name = tag[n + 1]

0 commit comments

Comments
 (0)