Questions tagged [flux-influxdb]

Flux is designed to be usable, readable, flexible, composable, testable, contributable, and shareable. Its syntax is largely inspired by 2018’s most popular scripting language, Javascript, and takes a functional approach to data exploration and processing.

The following example illustrates querying data stored from the last hour, filtering by the cpu measurement and the cpu=cpu-total tag, windowing the data in 1 minute intervals, and calculating the average of each window:

from(bucket:"example-bucket")
  |> range(start:-1h)
  |> filter(fn:(r) =>
    r._measurement == "cpu" and
    r.cpu == "cpu-total"
  )
  |> aggregateWindow(every: 1m, fn: mean)
130 questions
2
votes
1 answer

Query last value in Flux

I'm trying to get the last value from some IoT sensors and I actually achieved an intermediary result with the following Flux query: from(bucket:"mqtt-bucket") |> range(start:-10m ) |> filter(fn: (r) => r["_measurement"] == "mqtt_consumer") |>…
Molesox
  • 21
  • 1
  • 3
2
votes
1 answer

How do I convert InfluxDB query to List?

I use the following library for queries from an InfluxDB v2.0. https://github.com/influxdata/influxdb-client-csharp I want to convert the result from the InfluxDB query into a List. I have solved this with the following code. It feels messy to me…
patrickgc
  • 49
  • 7
2
votes
1 answer

sum values grouped by timestamp

I'm new to FluxQL and was wondering if I can sum values regardless of tag value grouped by a timestamp. I have something like…
Dusan Gligoric
  • 582
  • 3
  • 21
2
votes
3 answers

Using params in flux queries with Python influxdb_client

I am trying to update all of our influxdb python queries, so that they are not vulnerable to sql injections. To do this, I have read that you can use params with the query_api() and specifically with the query_data_frame()…
2
votes
3 answers

Is there a way to fill a result of sparse data with 0 value points with Flux?

I have points spread out every 5 min, and when the value is 0 the point is just omitted. I'd like to fill the omitted data with empty values. I see with InfluxQL I could do: group by time(5m) fill(0) But I am using InfluxDB 2. I have tried this…
aa bb
  • 247
  • 3
  • 9
2
votes
1 answer

InfluxDB 2.0 | Query Data and aggregate multiple times

I have a photovolatic system and log the generated electricity in KwH at each change in an InfluxDB 2.0. Now I want to have a graph of the monthly yields in Grafana. For this I need to load the last value of the day and sum it up per month. Actually…
SeeS
  • 21
  • 1
2
votes
3 answers

InfluxDB Flux - Getting last and first values as a column

I am trying to create two new columns with the first and last values using the last() and first() functions. However the function isn’t working when I try to map the new columns. Here is the sample code below. Is this possible using…
MBasith
  • 1,407
  • 4
  • 29
  • 48
2
votes
2 answers

Unable to change legend name in Grafana using InfluxDB as Datasource and Flux as query language

Unable to change the legend name in Grafana using InfluxDB[flux as query language]. Previously I was using InfluxQL as query language and at that time, grafana provided an option to set the legend name. But after switching to flux, that option seems…
Akhil
  • 333
  • 3
  • 13
2
votes
1 answer

InfluxDB + Flux: Get most recent timestamp for a measurement via Python API

I need to get the highest (aka most recent) timestamp for a specific Measurement in InfluxDB 2.0 via the Flux query language using the Python API. I have used the below query to get a timestamp out, but I'm unsure how to ensure that the timestamp I…
mfcss
  • 1,039
  • 1
  • 9
  • 25
2
votes
2 answers

How to split a string column in two in Flux (InfluxDB)

I have a column of #datatype string which is called names and contains the following info for each row: ABV,BVA BAC,DWA ZZA,DSW ... My question is how can I split (by the comma ,) this column into two columns with names (names_1 and names_2),…
Newskooler
  • 3,973
  • 7
  • 46
  • 84
1
vote
1 answer

InfluxDB metrics is visible in frontend UI. How to restrict it?

We have installed the InfluxDB time series database and we would like to restrict users to access /metrics /debug/pprof/all and several other sensitive URLs which don't require login. Can someone please suggest a way how we can restrict them apart…
RSSAH
  • 123
  • 14
1
vote
0 answers

Influx Query Division to calculate SQL Server Signal Wait %

I am trying to convert a SQL Server query to Flux SQL Server query: SELECT CAST(100.0 * SUM(signal_wait_time_ms) / SUM (wait_time_ms) AS NUMERIC(20, 2)) AS [%signal (cpu) waits] FROM sys.dm_os_wait_stats OPTION (RECOMPILE); My version of…
Leo Torres
  • 673
  • 1
  • 6
  • 18
1
vote
0 answers

Use processed string to refer as column name in Flux

How to use refer column names using r.sourceProcessed and r.targetProcessed? The processed variables are exact same as the column name. sourceProcessed = processStatusName(status: source) targetProcessed = processStatusName(status:…
nimendra
  • 25
  • 5
1
vote
1 answer

Flux aggregate function to calculate the difference from last to first

I'm trying to learn the flux query language for InfluxDB. I'm using InfluxDB OSS 2.7. I have a time-series with power usage from my power meter. It reports an ever increasing number in KWh, and I want to show how many Wh I have used per day, by…
Allan
  • 4,562
  • 8
  • 38
  • 59
1
vote
0 answers

Influx DB: Flux Query to return only incremental values?

I've a dataset with somewhat of "forever" increasing numbers, but sometimes x >= x+1. How would you create a flux query that only return values that are incrementals if Value x < Value x+1 keep the datapoint, otherwise ditch it. Here is my base…
Sirosimo
  • 41
  • 2
1
2
3
8 9