influxdata / influxdata/influxdb
cannot trim rows to a unqiue tag value and count them in flux
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
__Steps to reproduce:__
List the minimal actions needed to reproduce the behavior.
1. Run the proctat input plugin with telegraf pointed at influxdb
sample telegraf config
```toml
[agent]
interval="10s"
flush_interval="10s"
[[inputs.procstat]]
exe = ".*"
[[outputs.influxdb_v2]]
## The URLs of the InfluxDB cluster nodes.
##
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
## urls exp: http://127.0.0.1:9999
urls = ["http://localhost:9999"]
## Token for authentication.
token = "$INFLUX_TOKEN"
## Organization is the name of the organization you wish to write to; must exist.
organization = "rg"
## Destination bucket to write into.
bucket = "bucket1"
```
2. enter the following query and click view raw data:
```
processes = from(bucket: "bucket1")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) =>
(r["_measurement"] == "procstat"))
|> filter(fn: (r) =>
(r["_field"] == "memory_usage"))
|> keep(columns: ["process_name"])
|> unique(column: "process_name")
processes
|> count()
|> yield(name: "num processes")
processes
|> yield(name: "process names")
```
and I get:

3. Update query to make `count` use the `process_name` field:
```
processes = from(bucket: "bucket1")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) =>
(r["_measurement"] == "procstat"))
|> filter(fn: (r) =>
(r["_field"] == "memory_usage"))
|> keep(columns: ["process_name"])
|> unique(column: "process_name")
processes
|> count(column: "process_name")
|> yield(name: "num processes")
processes
|> yield(name: "process names")
```
and I get:

__Expected behavior:__
Expected to be able to count rows here.
__Actual behavior:__
Errors, as described in the above
__Environment info:__
* System info: `Darwin 18.7.0 x86_64`
* Influxd version: master(b12c3ef77b)
* Browser: FireFox 79.0
Contributor guide
Research direction
Reproduce the issue with the supplied Telegraf procstat configuration and Flux query, starting with the unique and count operations shown in the report. Trace why counting the resulting rows fails, then verify that both count() forms return the expected process count without errors.
Written by the indexing model from the issue text.
Assessment
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100