Last active
September 5, 2017 21:39
-
-
Save bobfrankly/664bad7592a9bbef21067c233d71eb88 to your computer and use it in GitHub Desktop.
Example script for sending data to influx db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configure InfluxDB | |
$idbRootUrl = "http://192.168.1.1:8086" | |
$idbstring = "/write?db=MYFIRSTDB" # Change MYFIRSTDB to reflect your DB name | |
$hostname = "FakeServer1" | |
# Gather Data | |
$one = Get-Random -Minimum 1 -Maximum 100 | |
$two = Get-Random -Minimum 1 -Maximum 1000 | |
# Format Data | |
$body = ( | |
"datapoint1 value=$one" + ` | |
"`n datapointTwo, host=$hostname, data=derpNugget value=$two" # Lines past the first need a backtick "n" as a linebreak for influxDB | |
) | |
# Submit Data to InfluxDB | |
Invoke-RestMethod -uri ($idbRootUrl + $idbstring) -Method Post -body $body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment