Correct y axis labels on Grafana graphs

Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
Matthew Stidham
2021-05-12 13:34:03 -07:00
parent e318515357
commit 3dc9fda69b
2 changed files with 22 additions and 10 deletions

View File

@@ -126,6 +126,11 @@ class UseGrafana(LFCliBase):
print("graph_groups_file: %s" % graph_groups_file)
target_csvs = open(graph_groups_file).read().split('\n')
graph_groups = self.get_graph_groups(target_csvs) # Get the list of graph groups which are in the tests we ran
unit_dict = dict()
for csv in target_csvs:
if len(csv)>1:
print(csv)
unit_dict.update(self.get_units(csv))
for scriptname in graph_groups.keys():
for graph_group in graph_groups[scriptname]:
panel = dict()
@@ -177,7 +182,7 @@ class UseGrafana(LFCliBase):
yaxis = dict()
yaxis['format'] = 'short'
yaxis['label'] = None
yaxis['label'] = unit_dict[graph_group]
yaxis['logBase'] = 1
yaxis['max'] = None
yaxis['min'] = None
@@ -246,28 +251,28 @@ class UseGrafana(LFCliBase):
input1['time'] = timedict
input1['timepicker'] = dict()
input1['timezone'] = ''
input1['title'] = title
input1['title'] = ("Testbed: %s" % title)
input1['uid'] = uid
input1['version'] = 11
return self.GR.create_dashboard_from_dict(dictionary=json.dumps(input1))
def read_csv(self, file):
csv=open(file).read().split('\n')
rows=list()
csv = open(file).read().split('\n')
rows = list()
for x in csv:
if len(x) > 0:
rows.append(x.split('\t'))
return rows
def get_values(self, csv, target):
value=csv[0].index(target)
results=[]
value = csv[0].index(target)
results = []
for row in csv[1:]:
results.append(row[value])
return results
def get_graph_groups(self,target_csvs): # Get the unique values in the Graph-Group column
dictionary=dict()
dictionary = dict()
for target_csv in target_csvs:
if len(target_csv) > 1:
csv = self.read_csv(target_csv)
@@ -280,6 +285,13 @@ class UseGrafana(LFCliBase):
print(dictionary)
return dictionary
def get_units(self, target_csv):
csv = self.read_csv(target_csv)
graph_group = self.get_values(csv, 'Graph-Group')
units = self.get_values(csv, 'Units')
return dict(zip(graph_group, units))
def main():
parser = LFCliBase.create_basic_argparse(

View File

@@ -5,11 +5,11 @@
# into influxdb. As final step, it builds a grafana dashboard for the KPI information.
# Define some common variables. This will need to be changed to match your own testbed.
MGR=192.168.1.6
MGR=10.0.0.202
INFLUX_MGR=192.168.100.201
#INFLUXTOKEN=Tdxwq5KRbj1oNbZ_ErPL5tw_HUH2wJ1VR4dwZNugJ-APz__mEFIwnqHZdoobmQpt2fa1VdWMlHQClR8XNotwbg==
INFLUXTOKEN=31N9QDhjJHBu4eMUlMBwbK3sOjXLRAhZuCzZGeO8WVCj-xvR8gZWWvRHOcuw-5RHeB7xBFnLs7ZV023k4koR1A==
TESTBED=Stidmatt-02
TESTBED=Stidmatt-01
INFLUXBUCKET=stidmatt
#GRAFANATOKEN=eyJrIjoiZTJwZkZlemhLQVNpY3hiemRjUkNBZ3k2RWc3bWpQWEkiLCJuIjoibWFzdGVyIiwiaWQiOjF9
GRAFANATOKEN=eyJrIjoiS1NGRU8xcTVBQW9lUmlTM2dNRFpqNjFqV05MZkM0dzciLCJuIjoibWF0dGhldyIsImlkIjoxfQ==
@@ -47,7 +47,7 @@ echo "run Dataplane test"
--influx_bucket ${INFLUXBUCKET} --influx_tag testbed ${TESTBED} --graph_groups lf_cv_rpt_filelocation.txt --duration 15s
# Build grafana dashboard and graphs view for the KPI in the capacity test.
./grafana_profile.py --create_custom --title 'Stidmatt-02' --influx_bucket ${INFLUXBUCKET} --mgr ${MGR} --grafana_token \
./grafana_profile.py --create_custom --title ${TESTBED} --influx_bucket ${INFLUXBUCKET} --mgr ${MGR} --grafana_token \
${GRAFANATOKEN} --grafana_host ${INFLUX_MGR} --testbed ${TESTBED} --graph_groups_file lf_cv_rpt_filelocation.txt \
--scripts Dataplane --datasource 'InfluxDB stidmatt bucket'