diff --git a/csv/query_csv.py b/csv/query_csv.py index f50c766..43355f2 100644 --- a/csv/query_csv.py +++ b/csv/query_csv.py @@ -27,7 +27,7 @@ # Write the header, writer.writerow(['name', 'timestamp', 'value'] + labelnames) -# Write the sanples. +# Write the samples. for result in results: l = [result['metric'].get('__name__', '')] + result['value'] for label in labelnames: diff --git a/jenkins_exporter/jenkins_exporter.py b/jenkins_exporter/jenkins_exporter.py index 3ab8176..2eaf234 100755 --- a/jenkins_exporter/jenkins_exporter.py +++ b/jenkins_exporter/jenkins_exporter.py @@ -50,7 +50,10 @@ def collect(self): name = job['name'] for s in statuses: # If there's a null result, we want to export zeros. - status = job[s] or {} + if s in job and job[s]: + status=job[s] + else: + status={} metrics[s]['number'].add_metric([name], status.get('number', 0)) metrics[s]['duration'].add_metric([name], status.get('duration', 0) / 1000.0) metrics[s]['timestamp'].add_metric([name], status.get('timestamp', 0) / 1000.0)