You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Example: query the `cpu` table, limiting to 10 rows:
473
479
474
480
```console
475
-
$ influxdb3 query --database=servers "SELECT DISTINCT usage_percent, time FROM cpu LIMIT 10"
481
+
$ influxdb3 query --databaseservers "SELECT DISTINCT usage_percent, time FROM cpu LIMIT 10"
476
482
+---------------+---------------------+
477
483
| usage_percent | time |
478
484
+---------------+---------------------+
@@ -496,7 +502,10 @@ $ influxdb3 query --database=servers "SELECT DISTINCT usage_percent, time FROM c
496
502
To query using InfluxQL, enter the `influxdb3 query` subcommand and specify `influxql` in the language option--for example:
497
503
498
504
```bash
499
-
influxdb3 query --database=servers --language=influxql "SELECT DISTINCT usage_percent FROM cpu WHERE time >= now() - 1d"
505
+
influxdb3 query \
506
+
--database servers \
507
+
--language influxql \
508
+
"SELECT DISTINCT usage_percent FROM cpu WHERE time >= now() - 1d"
500
509
```
501
510
502
511
### Query using the API
@@ -607,11 +616,11 @@ The following command creates a last value cache named `cpuCache`:
607
616
608
617
```bash
609
618
influxdb3 create last_cache \
610
-
--database=servers \
611
-
--table=cpu \
612
-
--key-columns=host,application \
613
-
--value-columns=usage_percent,status \
614
-
--count=5 cpuCache
619
+
--databaseservers \
620
+
--tablecpu \
621
+
--key-columnshost,application \
622
+
--value-columnsusage_percent,status \
623
+
--count5 cpuCache
615
624
```
616
625
617
626
_You can create a last values cache per time series, but be mindful of high cardinality tables that could take excessive memory._
@@ -622,7 +631,7 @@ To use the LVC, call it using the `last_cache()` function in your query--for exa
622
631
623
632
```bash
624
633
influxdb3 query \
625
-
--database=servers \
634
+
--databaseservers \
626
635
"SELECT * FROM last_cache('cpu', 'cpuCache') WHERE host = 'Bravo';"
627
636
```
628
637
@@ -637,8 +646,8 @@ Use the `influxdb3` CLI to [delete a last values cache](/influxdb3/version/refer
637
646
638
647
```bash
639
648
influxdb3 delete last_cache \
640
-
-d <DATABASE_NAME> \
641
-
-t <TABLE> \
649
+
--database <DATABASE_NAME> \
650
+
--table <TABLE> \
642
651
--cache-name <CACHE_NAME>
643
652
```
644
653
@@ -650,8 +659,8 @@ You can use the `influxdb3` CLI to [create a distinct values cache](/influxdb3/v
650
659
651
660
```bash
652
661
influxdb3 create distinct_cache \
653
-
-d <DATABASE_NAME> \
654
-
-t <TABLE> \
662
+
--database <DATABASE_NAME> \
663
+
--table <TABLE> \
655
664
--columns <COLUMNS> \
656
665
[CACHE_NAME]
657
666
```
@@ -670,9 +679,9 @@ The following command creates a distinct values cache named `cpuDistinctCache`:
670
679
671
680
```bash
672
681
influxdb3 create distinct_cache \
673
-
--database=servers \
674
-
--table=cpu \
675
-
--columns=host,application \
682
+
--databaseservers \
683
+
--tablecpu \
684
+
--columnshost,application \
676
685
cpuDistinctCache
677
686
```
678
687
@@ -682,25 +691,23 @@ To use the distinct values cache, call it using the `distinct_cache()` function
682
691
683
692
```bash
684
693
influxdb3 query \
685
-
--database=servers \
694
+
--databaseservers \
686
695
"SELECT * FROM distinct_cache('cpu', 'cpuDistinctCache')"
687
696
```
688
697
689
698
> [!Note]
690
699
> #### Only works with SQL
691
700
>
692
-
> The Distinct cache only works with SQL, not InfluxQL; SQL is the default language.
693
-
694
-
701
+
> The distinct cache only works with SQL, not InfluxQL; SQL is the default language.
695
702
696
703
#### Delete a distinct values cache
697
704
698
705
Use the `influxdb3` CLI to [delete a distinct values cache](/influxdb3/version/reference/cli/influxdb3/delete/distinct_cache/)
699
706
700
707
```bash
701
708
influxdb3 delete distinct_cache \
702
-
-d <DATABASE_NAME> \
703
-
-t <TABLE> \
709
+
--database <DATABASE_NAME> \
710
+
--table <TABLE> \
704
711
--cache-name <CACHE_NAME>
705
712
```
706
713
@@ -726,12 +733,12 @@ InfluxDB 3 provides the following types of triggers, each with specific trigger-
726
733
727
734
- **On WAL flush**: Sends a batch of written data (for a specific table or all tables) to a plugin (by default, every second).
728
735
- **On Schedule**: Executes a plugin on a user-configured schedule (using a crontab or a duration); useful for data collection and deadman monitoring.
729
-
- **On Request**: Binds a plugin to a custom HTTP API endpoint at `/api/v3/engine/<ENDPOINT>`.
736
+
- **On Request**: Binds a plugin to a custom HTTP API endpoint at `/api/v3/engine/<ENDPOINT_PATH>`.
730
737
The plugin receives the HTTP request headers and content, and can then parse, process, and send the data into the database or to third-party services.
731
738
732
739
### Test, create, and trigger plugin code
733
740
734
-
##### Example: Python plugin for WAL flush
741
+
##### Example: Python plugin for WAL rows
735
742
736
743
```python
737
744
# This is the basic structure for Python plugin code that runs in the
@@ -817,7 +824,7 @@ To test a plugin, do the following:
817
824
818
825
1. Create a _plugin directory_--for example, `/path/to/.influxdb/plugins`
819
826
2. [Start the InfluxDB server](#start-influxdb) and include the `--plugin-dir <PATH>` option.
820
-
3. Save the [preceding example code](#example-python-plugin) to a plugin file inside of the plugin directory. If you haven't yet written data to the table in the example, comment out the lines where it queries.
827
+
3. Save the [example plugin code](#example-python-plugin-for-wal-flush) to a plugin file inside of the plugin directory. If you haven't yet written data to the table in the example, comment out the lines where it queries.
821
828
4. To run the test, enter the following command with the following options:
822
829
823
830
- `--lp` or `--file`: The line protocol to test
@@ -853,19 +860,19 @@ trigger:
853
860
# - A Python plugin file named `test.py`
854
861
# Test a plugin
855
862
influxdb3 test wal_plugin \
856
-
--lp="my_measure,tag1=asdf f1=1.0 123" \
857
-
-d mydb \
858
-
--input-arguments="arg1=hello,arg2=world" \
863
+
--lp"my_measure,tag1=asdf f1=1.0 123" \
864
+
--database mydb \
865
+
--input-arguments"arg1=hello,arg2=world" \
859
866
test.py
860
867
```
861
868
862
869
```bash
863
870
# Create a trigger that runs the plugin
864
871
influxdb3 create trigger \
865
872
-d mydb \
866
-
--plugin=test_plugin \
867
-
--trigger-spec="table:foo" \
868
-
--trigger-arguments="arg1=hello,arg2=world" \
873
+
--plugintest_plugin \
874
+
--trigger-spec"table:foo" \
875
+
--trigger-arguments"arg1=hello,arg2=world" \
869
876
trigger1
870
877
```
871
878
@@ -875,3 +882,5 @@ enable the trigger and have it run the plugin as you write data:
875
882
```bash
876
883
influxdb3 enable trigger --database mydb trigger1
877
884
```
885
+
886
+
For more information, see [Python plugins and the Processing engine](/influxdb3/version/plugins/).
0 commit comments