Hello,
I am trying to add a new field to existing measurement in influxDB but however, upon doing so, data is getting append to the current measurement instead being written to the fields next it. Data is getting misplaced. any help would be appreciated.
Code:
client_utep = InfluxDBClient('influxDBName', 8089, 'username', 'password', 'ASVNEWRELIC2')
results1 = client_utep.query("SELECT asv, qid, utep, state from utep_data")
results1 = list(results1.get_points(measurement='utep_data'))
client_summary = InfluxDBClient('influxDBName', 8089, 'username', 'password', 'ASVNEWRELIC2')
results2 = client_summary.query("SELECT KB_QID, ASV from VulSummaryProd ")
results2 = list(results2.get_points(measurement='VulSummaryProd'))
client3 = InfluxDBClient('localhost', 8086, 'devops', 'devops123', 'apache')
print("InfluxDB injection process started.")
influx_json = []
for each_value in zip(results1, results2): # filtering UTEP vaule when the conditions are matched
if ((each_value[0]['qid'] == each_value[1]['KB_QID'] and each_value[0]['state'] == 'Approved - Pending Remediation') or ( each_value[0]['qid'] == each_value[1]['KB_QID'] and each_value[0]['state'] == 'Approved Pending Renewal')):
data = {
"measurement":"summary58", ## current existing measurement with other fields
# "time" : datetime.utcnow().isoformat() + "Z",
# "tags": {
# 'ResiliencyTier':'targetResiliencyTier',
# 'lob' : 'EDML'
# },s
"fields": {
'UTEP': str(each_value[0]['utep'])
}
}
influx_json.append(data)
client3.write_points(influx_json)
print("InfluxDB injection process completed.")
Thanks