This commit is contained in:
Alex Kup 2023-07-05 01:59:55 +03:00 committed by GitHub
parent 1582e3d798
commit 985b4319e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3605,6 +3605,8 @@ INSERT counters,host=console,counter=CPU value=0.88 # записать данн
SELECT * FROM counters # отобразить все данные в таблице SELECT * FROM counters # отобразить все данные в таблице
SELECT * FROM counters limit 10 # отобразить 10 единиц данных SELECT * FROM counters limit 10 # отобразить 10 единиц данных
SELECT * FROM counters WHERE time > now() -2h # отобразить данные за последние 2 часа SELECT * FROM counters WHERE time > now() -2h # отобразить данные за последние 2 часа
DELETE FROM counters WHERE time > now() - 2h # удалить данные за последние 2 часа
DELETE FROM counters WHERE time < now() - 24h # удалить данные старше 24 часов
SELECT/DELETE/SHOW/CREATE/DROP/EXPLAIN/GRANT/REVOKE/ALTER/SET/KILL SELECT/DELETE/SHOW/CREATE/DROP/EXPLAIN/GRANT/REVOKE/ALTER/SET/KILL
@ -3615,6 +3617,16 @@ $PerformanceStat = "\Процессор(_Total)\% загруженности п
$Value = ((Get-Counter $PerformanceStat).CounterSamples).CookedValue $Value = ((Get-Counter $PerformanceStat).CounterSamples).CookedValue
Invoke-RestMethod -Method POST -Uri $url -Body "counters,host=$ENV:COMPUTERNAME,counter=CPU value=$value" Invoke-RestMethod -Method POST -Uri $url -Body "counters,host=$ENV:COMPUTERNAME,counter=CPU value=$value"
### Unix Time
[string]$timestamp = (New-TimeSpan -Start (Get-Date "01/01/1970") -End (Get-Date)).TotalSeconds
[string]$timestamp = ($timestamp -replace "\..+") + "000000000"
Invoke-RestMethod -Method POST -Uri $url -Body "speedtest,host=$(hostname) download=200000,upload=300000,ping=3 $timestamp"
# speedtest - Table
# host - Tag Keys
# $(hostname) - Tag Values
# temp* - Field Keys
### API GET ### API GET
curl http://192.168.3.104:8086/query --data-urlencode "q=SHOW DATABASES" # | ConvertFrom-Json curl http://192.168.3.104:8086/query --data-urlencode "q=SHOW DATABASES" # | ConvertFrom-Json
@ -3623,28 +3635,25 @@ $db = irm "http://192.168.3.104:8086/query?q=SHOW DATABASES"
$db = irm "http://192.168.3.104:8086/query?epoch=ms&u=admin&p=password&q=SHOW DATABASES" $db = irm "http://192.168.3.104:8086/query?epoch=ms&u=admin&p=password&q=SHOW DATABASES"
$db.results.series.values $db.results.series.values
$ip_port = "192.168.3.104:8086" $ip = "192.168.3.104"
$db = "win_performance" $port = "8086"
$query = 'SELECT * FROM counters' $db = "win_performance"
$url = "http://$ip_port/query?db=$db&q=$query" $table = "counters"
#$cred = Get-Credential $query = "SELECT * FROM $table"
#$user = "admin" $ipp = $ip+":"+$port
#$pass = "password" | ConvertTo-SecureString -AsPlainText -Force $url = "http://$ipp/query?db=$db&q=$query"
#$cred = [System.Management.Automation.PSCredential]::new($user,$pass) #$cred = Get-Credential
$rest = Invoke-RestMethod -Method GET -Uri $url # -Credential $cred #$user = "admin"
$name = $rest.results.series.name # имя таблицы #$pass = "password" | ConvertTo-SecureString -AsPlainText -Force
$col = $rest.results.series.columns # столбцы/ключи #$cred = [System.Management.Automation.PSCredential]::new($user,$pass)
$val = $rest.results.series.values # данные построчно $data = Invoke-RestMethod -Method GET -Uri $url # -Credential $cred
$data.results.series.name # имя таблицы
$mass = @() $data.results.series.columns # столбцы/ключи
$mass += [string]$col -replace "\s"," | " $data.results.series.values # данные построчно
foreach ($v in $val) {
$mass += [string]$v -replace "\s"," "
}
$mass
irm http://localhost:8086/api/v2/setup irm http://localhost:8086/api/v2/setup
irm http://localhost:8086/api/v2/config irm http://localhost:8086/api/v2/config
irm http://localhost:8086/api/v2/write
# WMI # WMI