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:
483
489
484
490
```console
485
-
$ influxdb3 query --database=servers "SELECT DISTINCT usage_percent, time FROM cpu LIMIT 10"
491
+
$ influxdb3 query --databaseservers "SELECT DISTINCT usage_percent, time FROM cpu LIMIT 10"
486
492
+---------------+---------------------+
487
493
| usage_percent |time|
488
494
+---------------+---------------------+
@@ -506,7 +512,10 @@ $ influxdb3 query --database=servers "SELECT DISTINCT usage_percent, time FROM c
506
512
To query using InfluxQL, enter the `influxdb3 query` subcommand and specify `influxql`in the language option--for example:
507
513
508
514
```bash
509
-
influxdb3 query --database=servers --language=influxql "SELECT DISTINCT usage_percent FROM cpu WHERE time >= now() - 1d"
515
+
influxdb3 query \
516
+
--database servers \
517
+
--language influxql \
518
+
"SELECT DISTINCT usage_percent FROM cpu WHERE time >= now() - 1d"
510
519
```
511
520
512
521
### Query using the API
@@ -617,11 +626,11 @@ The following command creates a last value cache named `cpuCache`:
617
626
618
627
```bash
619
628
influxdb3 create last_cache \
620
-
--database=servers \
621
-
--table=cpu \
622
-
--key-columns=host,application \
623
-
--value-columns=usage_percent,status \
624
-
--count=5 cpuCache
629
+
--databaseservers \
630
+
--tablecpu \
631
+
--key-columnshost,application \
632
+
--value-columnsusage_percent,status \
633
+
--count5 cpuCache
625
634
```
626
635
627
636
_You can create a last values cache per time series, but be mindful of high cardinality tables that could take excessive memory._
@@ -632,7 +641,7 @@ To use the LVC, call it using the `last_cache()` function in your query--for exa
632
641
633
642
```bash
634
643
influxdb3 query \
635
-
--database=servers \
644
+
--databaseservers \
636
645
"SELECT * FROM last_cache('cpu', 'cpuCache') WHERE host = 'Bravo';"
637
646
```
638
647
@@ -647,8 +656,8 @@ Use the `influxdb3` CLI to [delete a last values cache](/influxdb3/version/refer
647
656
648
657
```bash
649
658
influxdb3 delete last_cache \
650
-
-d<DATABASE_NAME> \
651
-
-t<TABLE> \
659
+
--database<DATABASE_NAME> \
660
+
--table<TABLE> \
652
661
--cache-name <CACHE_NAME>
653
662
```
654
663
@@ -660,8 +669,8 @@ You can use the `influxdb3` CLI to [create a distinct values cache](/influxdb3/v
660
669
661
670
```bash
662
671
influxdb3 create distinct_cache \
663
-
-d<DATABASE_NAME> \
664
-
-t<TABLE> \
672
+
--database<DATABASE_NAME> \
673
+
--table<TABLE> \
665
674
--columns <COLUMNS> \
666
675
[CACHE_NAME]
667
676
```
@@ -680,9 +689,9 @@ The following command creates a distinct values cache named `cpuDistinctCache`:
680
689
681
690
```bash
682
691
influxdb3 create distinct_cache \
683
-
--database=servers \
684
-
--table=cpu \
685
-
--columns=host,application \
692
+
--databaseservers \
693
+
--tablecpu \
694
+
--columnshost,application \
686
695
cpuDistinctCache
687
696
```
688
697
@@ -692,25 +701,23 @@ To use the distinct values cache, call it using the `distinct_cache()` function
692
701
693
702
```bash
694
703
influxdb3 query \
695
-
--database=servers \
704
+
--databaseservers \
696
705
"SELECT * FROM distinct_cache('cpu', 'cpuDistinctCache')"
697
706
```
698
707
699
708
> [!Note]
700
709
>#### Only works with SQL
701
710
>
702
-
> The Distinct cache only works with SQL, not InfluxQL; SQL is the default language.
703
-
704
-
711
+
> The distinct cache only works with SQL, not InfluxQL; SQL is the default language.
705
712
706
713
#### Delete a distinct values cache
707
714
708
715
Use the `influxdb3` CLI to [delete a distinct values cache](/influxdb3/version/reference/cli/influxdb3/delete/distinct_cache/)
709
716
710
717
```bash
711
718
influxdb3 delete distinct_cache \
712
-
-d<DATABASE_NAME> \
713
-
-t<TABLE> \
719
+
--database<DATABASE_NAME> \
720
+
--table<TABLE> \
714
721
--cache-name <CACHE_NAME>
715
722
```
716
723
@@ -736,12 +743,12 @@ InfluxDB 3 provides the following types of triggers, each with specific trigger-
736
743
737
744
- **On WAL flush**: Sends a batch of written data (for a specific table or all tables) to a plugin (by default, every second).
738
745
- **On Schedule**: Executes a plugin on a user-configured schedule (using a crontab or a duration); useful for data collection and deadman monitoring.
739
-
- **On Request**: Binds a plugin to a custom HTTP API endpoint at `/api/v3/engine/<ENDPOINT>`.
746
+
- **On Request**: Binds a plugin to a custom HTTP API endpoint at `/api/v3/engine/<ENDPOINT_PATH>`.
740
747
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.
741
748
742
749
### Test, create, and trigger plugin code
743
750
744
-
##### Example: Python plugin for WAL flush
751
+
##### Example: Python plugin for WAL rows
745
752
746
753
```python
747
754
# This is the basic structure for Python plugin code that runs in the
@@ -827,7 +834,7 @@ To test a plugin, do the following:
827
834
828
835
1. Create a _plugin directory_--for example, `/path/to/.influxdb/plugins`
829
836
2. [Start the InfluxDB server](#start-influxdb) and include the `--plugin-dir <PATH>` option.
830
-
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.
837
+
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.
831
838
4. To run the test, enter the following command with the following options:
832
839
833
840
- `--lp` or `--file`: The line protocol to test
@@ -863,19 +870,19 @@ trigger:
863
870
# - A Python plugin file named `test.py`
864
871
# Test a plugin
865
872
influxdb3 test wal_plugin \
866
-
--lp="my_measure,tag1=asdf f1=1.0 123" \
867
-
-d mydb \
868
-
--input-arguments="arg1=hello,arg2=world" \
873
+
--lp"my_measure,tag1=asdf f1=1.0 123" \
874
+
--database mydb \
875
+
--input-arguments"arg1=hello,arg2=world" \
869
876
test.py
870
877
```
871
878
872
879
```bash
873
880
# Create a trigger that runs the plugin
874
881
influxdb3 create trigger \
875
882
-d mydb \
876
-
--plugin=test_plugin \
877
-
--trigger-spec="table:foo" \
878
-
--trigger-arguments="arg1=hello,arg2=world" \
883
+
--plugintest_plugin \
884
+
--trigger-spec"table:foo" \
885
+
--trigger-arguments"arg1=hello,arg2=world" \
879
886
trigger1
880
887
```
881
888
@@ -885,3 +892,5 @@ enable the trigger and have it run the plugin as you write data:
885
892
```bash
886
893
influxdb3 enable trigger --database mydb trigger1
887
894
```
895
+
896
+
For more information, see [Python plugins and the Processing engine](/influxdb3/version/plugins/).
0 commit comments