The Seven Year Itch.

MENU

Go 脚本往InfluxDB插入数据

June 14, 2018 • Read: 250 • Go

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://192.168.10.183:8086/write?db=xujiaqi"

    payload := strings.NewReader("xujiaqi,Ip_address=192.168.2.1,Location=信息 myfield=77")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("Authorization", "Basic amlhbmRhbjpqaWFuZGFuMTIz")
    req.Header.Add("Cache-Control", "no-cache")
    req.Header.Add("Postman-Token", "f0cfb24c-fa9a-4771-9f86-eab515514bda")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

数据流量监控

jiank

Tags: None
Archives QR Code
QR Code for this page
Tipping QR Code