Skip to content

Instantly share code, notes, and snippets.

@bobfrankly
Last active September 5, 2017 21:39
Show Gist options
  • Save bobfrankly/664bad7592a9bbef21067c233d71eb88 to your computer and use it in GitHub Desktop.
Save bobfrankly/664bad7592a9bbef21067c233d71eb88 to your computer and use it in GitHub Desktop.
Example script for sending data to influx db
# 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