sh InfluxDB备忘单

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh InfluxDB备忘单相关的知识,希望对你有一定的参考价值。

# InfluxDB

## Login to Influx CLI

```shell
influx -ssl -unsafeSsl
    USE telegraf
```

## Launch Influx commands

```shell
influx -ssl -unsafeSsl \
    -database 'telegraf' \
    -execute "SHOW SERIES WHERE \"host\" = 'my_host'"
```

## Delete host

```sql
SHOW SERIES WHERE "host" = 'my_host'
DROP SERIES WHERE "host" = 'my_host'
SHOW SERIES WHERE "host" = 'my_host'
```

## Delete measurement in host

```sql
SHOW SERIES FROM "measurement" WHERE "host" = 'my_host'
DROP SERIES FROM "measurement" WHERE "host" = 'my_host'
SHOW SERIES WHERE "host" = 'my_host'
```

## Show measurement

```sql
SHOW MEASUREMENTS ON telegraf
```

## Delete measurement

```sql
DROP MEASUREMENT "measurement_name"
```

# Kapacitor

* List tasks: 
```shell
kapacitor -skipVerify list tasks
```
* Disable all tasks: 
```shell
kapacitor -skipVerify disable $(kapacitor -skipVerify list tasks | awk '{if (NR!=1) {print $1}}')
```
* Enable all tasks:
```shell
kapacitor -skipVerify enable $(kapacitor -skipVerify list tasks | awk '{if (NR!=1) {print $1}}')
```
* Debugging:

```
# option 1
kapacitor -skipVerify watch <task_id>

# option 2
## @TICKscript
|httpOut('id')
## @browser
http://kapacitor-host:9092/kapacitor/v1/tasks/<task_id>/<httpOut_id>

# option 3
kapacitor -skipVerify show <task_id>
```
#!/usr/bin/env bash

influx_show(){ docker exec $1 influx -ssl -unsafeSsl -database 'telegraf' -execute "SHOW SERIES WHERE \"host\" = '$2'" ;}
influx_drop(){ docker exec $1 influx -ssl -unsafeSsl -database 'telegraf' -execute "DROP SERIES WHERE \"host\" = '$2'" ;}

influx_restart(){ cd /opt/TICK-docker && docker-compose restart influxdb ;}
kapacitor_restart(){ cd /opt/TICK-docker && docker-compose restart kapacitor ;}

以上是关于sh InfluxDB备忘单的主要内容,如果未能解决你的问题,请参考以下文章

sh 备忘单

sh Linux备忘单

sh Salesforce SFDX备忘单

sh 发电机备忘单

sh Kubernetes备忘单

sh bash备忘单