2
votes

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
2

2 Answers

10
votes

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/

0
votes

You have an space after measurement 'smartctl' instead of ','. Try:

curl -POST 'http://localhost:8086/write?db=test' --data-binary 'smartctl,Raw_Read_Error_Rate=19 value=0.64 1472412282915653274'

Documentation indicates :

The HTTP API is the primary means of putting data into InfluxDB. To write data send a POST request to the /write endpoint. The example below writes a single point to the mydb database. The data consist of the measurement cpu_load_short, the tag keys host and region with the tag values server01 and us-west, the field key value with a field value of 0.64, and the timestamp 1434055562000000000.

 curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'