Skip to content

Commit

Permalink
Merge pull request #606 from landrushka/master
Browse files Browse the repository at this point in the history
added boolean 'labeled', 'prefix_measurement' options to Influx plugi…
  • Loading branch information
direvius committed Jun 5, 2018
2 parents 35c1035 + add40ab commit 40ca96c
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
8 changes: 7 additions & 1 deletion yandextank/plugins/Influx/config/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ grafana_dashboard:
type: string
chunk_size:
default: 500000
type: integer
type: integer
labeled:
default: false
type: boolean
prefix_measurement:
default: ""
type: string
57 changes: 57 additions & 0 deletions yandextank/plugins/Influx/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,63 @@ def decode_monitoring(self, data):
}]
return points

def decode_aggregate_labeled(self, data, stat, prefix):
timestamp = int(data["ts"])
points = []
for key, value in data["tagged"].items():
points += [{
"measurement": prefix + "overall_quantiles",
"tags": {
"tank": self.tank_tag,
"uuid": self.uuid,
"label": key
},
"time": timestamp,
"fields": { # quantiles
'q' + str(q): value / 1000.0
for q, value in zip(value["interval_real"]["q"]["q"],
value["interval_real"]["q"]["value"])
},
}, {
"measurement": prefix + "overall_meta",
"tags": {
"tank": self.tank_tag,
"uuid": self.uuid,
"label": key,
},
"time": timestamp,
"fields": {
"active_threads": stat["metrics"]["instances"],
"RPS": value["interval_real"]["len"],
"planned_requests": float(stat["metrics"]["reqps"]),
},
}, {
"measurement": prefix + "net_codes",
"tags": {
"tank": self.tank_tag,
"uuid": self.uuid,
"label": key
},
"time": timestamp,
"fields": {
str(code): int(cnt)
for code, cnt in value["net_code"]["count"].items()
},
}, {
"measurement": prefix + "proto_codes",
"tags": {
"tank": self.tank_tag,
"uuid": self.uuid,
},
"time": timestamp,
"fields": {
str(code): int(cnt)
for code, cnt in value["proto_code"]["count"].items()
},
},
]
return points

def decode_aggregate(self, data, stat):
timestamp = int(data["ts"])
points = [
Expand Down
7 changes: 6 additions & 1 deletion yandextank/plugins/Influx/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def __init__(self, core, cfg):
password=self.get_option("password"),
database=self.get_option("database"),
)
self.labeled = self.get_option("labeled")
self.prefix_measurement = self.get_option("prefix_measurement")
grafana_root = self.get_option("grafana_root")
grafana_dashboard = self.get_option("grafana_dashboard")
uuid = str(uuid4())
Expand All @@ -70,7 +72,10 @@ def prepare_test(self):

def on_aggregated_data(self, data, stats):
if self.client:
points = self.decoder.decode_aggregate(data, stats)
if self.labeled:
points = self.decoder.decode_aggregate_labeled(data, stats, self.prefix_measurement)
else:
points = self.decoder.decode_aggregate(data, stats)
self.client.write_points(points, 's')

def monitoring_data(self, data_list):
Expand Down

0 comments on commit 40ca96c

Please sign in to comment.