Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insert multiple values with tags into influxdb

Tags:

influxdb

I'm trying to collect smartctl metrics and push them into influxdb. I'm having difficulty adding tags for values being pushed in so that the tags and values are in the right place.

If I do this:

curl -POST 'http://localhost:8086/write?db=test' --data-binary 'smartctl Raw_Read_Error_Rate=19243395i,Spin_Up_Time=0i,Start_Stop_Count=149i,Reallocated_Sector_Ct=25i,Seek_Error_Rate=4735843653i,Power_On_Hours=41286i,Spin_Retry_Count=0i,Power_Cycle_Count=150i,End_to_End_Error=0i,Reported_Uncorrect=0i,Command_Timeout=12885098501i,High_Fly_Writes=0i,Airflow_Temperature_Cel=29i,G_Sense_Error_Rate=0i,Power_Off_Retract_Count=145i,Load_Cycle_Count=25668i,Temperature_Celsius=29i,Hardware_ECC_Recovered=19243395i,Current_Pending_Sector=0i,Offline_Uncorrectable=0i,UDMA_CRC_Error_Count=0i 1472412282915653274'

There are no tags:

SHOW TAG KEYS FROM "smartctl" (empty result)

How do I add tags to that same curl command so that I get something like:

host=foo,disk_name="Seagate Blah"

Adding some clarification:

If I use a comma (and set a value), then they are all tags, not fields:

curl -POST 'http://localhost:8086/write?db=test' --data-binary 'smartctl,Raw_Read_Error_Rate=19243395i,Spin_Up_Time=0i,Start_Stop_Count=149i,Reallocated_Sector_Ct=25i,Seek_Error_Rate=4735843653i,Power_On_Hours=41286i,Spin_Retry_Count=0i,Power_Cycle_Count=150i,End_to_End_Error=0i,Reported_Uncorrect=0i,Command_Timeout=12885098501i,High_Fly_Writes=0i,Airflow_Temperature_Cel=29i,G_Sense_Error_Rate=0i,Power_Off_Retract_Count=145i,Load_Cycle_Count=25668i,Temperature_Celsius=29i,Hardware_ECC_Recovered=19243395i,Current_Pending_Sector=0i,Offline_Uncorrectable=0i,UDMA_CRC_Error_Count=0i value=0 1472412282915653274'

(side note: I also don't see what I would set as a value for "smartctl"?)

What I need is to set all of the above as a field, but with tags so I can determine the host they are reporting from. So I can do something like:

select Temperature_Celsius from smartctl where host=foo
like image 573
Clayton Dukes Avatar asked Nov 30 '25 03:11

Clayton Dukes


1 Answers

Put your tags just after measurement name, separated with comma, full line protocol definition is like that:

measurement,tag1=foo,tag2=bar value_a=1,value_b=2 timestamp

So in your case:

curl -POST 'http://localhost:8086/write?db=test' --data-binary 'smartctl,host=foo,disk_name="Seagate Blah" Raw_Read_Error_Rate=19243395i,Spin_Up_Time=0i,Start_Stop_Count=149i,Reallocated_Sector_Ct=25i,Seek_Error_Rate=4735843653i,Power_On_Hours=41286i,Spin_Retry_Count=0i,Power_Cycle_Count=150i,End_to_End_Error=0i,Reported_Uncorrect=0i,Command_Timeout=12885098501i,High_Fly_Writes=0i,Airflow_Temperature_Cel=29i,G_Sense_Error_Rate=0i,Power_Off_Retract_Count=145i,Load_Cycle_Count=25668i,Temperature_Celsius=29i,Hardware_ECC_Recovered=19243395i,Current_Pending_Sector=0i,Offline_Uncorrectable=0i,UDMA_CRC_Error_Count=0i 1472412282915653274'

See also: https://docs.influxdata.com/influxdb/v1.6/write_protocols/line_protocol_tutorial/

like image 117
kompas Avatar answered Dec 02 '25 05:12

kompas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!