From 909980c765620674875db73167789388c0672e2f Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 23 Jun 2022 16:21:58 -0600 Subject: [PATCH] Auto-generated Flux docs (#4158) * WIP testing autogen * WIP autogen docs, added contributors parital * updated stdlib * WIP autogen * Inject Flux stdlib frontmatter script (#4157) * added frontmatter injection script and frontmatter data file * regenerated stdlib * finalize frontmatter injection script * add frontmatter injection to CI build * remove debug line from frontmatter script * fresh docs generate * fresh generate --- .circleci/config.yml | 5 +- assets/js/content-interactions.js | 2 +- content/flux/v0.x/stdlib/_index.md | 1 + content/flux/v0.x/stdlib/all-functions.md | 2 +- content/flux/v0.x/stdlib/array/_index.md | 44 +- content/flux/v0.x/stdlib/array/from.md | 81 +- .../stdlib/contrib/RohanSreerama5/_index.md | 36 + .../naiveBayesClassifier/_index.md | 49 + .../naiveBayesClassifier/naivebayes.md | 72 + content/flux/v0.x/stdlib/contrib/_index.md | 40 +- .../v0.x/stdlib/contrib/anaisdg/_index.md | 36 + .../anaisdg/anomalydetection/_index.md | 41 + .../contrib/anaisdg/anomalydetection/mad.md | 131 + .../contrib/anaisdg/statsmodels/_index.md | 41 + .../anaisdg/statsmodels/linearregression.md | 89 + .../v0.x/stdlib/contrib/bonitoo-io/_index.md | 42 +- .../contrib/bonitoo-io/alerta/_index.md | 49 +- .../stdlib/contrib/bonitoo-io/alerta/alert.md | 188 +- .../contrib/bonitoo-io/alerta/endpoint.md | 147 +- .../stdlib/contrib/bonitoo-io/hex/_index.md | 47 +- .../stdlib/contrib/bonitoo-io/hex/bytes.md | 56 +- .../v0.x/stdlib/contrib/bonitoo-io/hex/int.md | 122 +- .../stdlib/contrib/bonitoo-io/hex/string.md | 198 +- .../stdlib/contrib/bonitoo-io/hex/uint.md | 125 +- .../contrib/bonitoo-io/servicenow/_index.md | 36 +- .../contrib/bonitoo-io/servicenow/endpoint.md | 124 +- .../contrib/bonitoo-io/servicenow/event.md | 128 +- .../contrib/bonitoo-io/tickscript/_index.md | 48 +- .../contrib/bonitoo-io/tickscript/alert.md | 197 +- .../contrib/bonitoo-io/tickscript/compute.md | 94 +- .../contrib/bonitoo-io/tickscript/deadman.md | 170 +- .../bonitoo-io/tickscript/definecheck.md | 119 +- .../contrib/bonitoo-io/tickscript/groupby.md | 105 +- .../contrib/bonitoo-io/tickscript/join.md | 160 +- .../contrib/bonitoo-io/tickscript/select.md | 275 +- .../bonitoo-io/tickscript/selectwindow.md | 174 +- .../contrib/bonitoo-io/victorops/_index.md | 47 +- .../contrib/bonitoo-io/victorops/alert.md | 124 +- .../contrib/bonitoo-io/victorops/endpoint.md | 121 +- .../contrib/bonitoo-io/zenoss/_index.md | 40 +- .../contrib/bonitoo-io/zenoss/endpoint.md | 159 +- .../stdlib/contrib/bonitoo-io/zenoss/event.md | 157 +- .../flux/v0.x/stdlib/contrib/chobbs/_index.md | 41 +- .../stdlib/contrib/chobbs/discord/_index.md | 58 +- .../stdlib/contrib/chobbs/discord/endpoint.md | 97 +- .../stdlib/contrib/chobbs/discord/send.md | 93 +- .../v0.x/stdlib/contrib/jsternberg/_index.md | 41 +- .../contrib/jsternberg/aggregate/_index.md | 51 + .../contrib/jsternberg/aggregate/count.md | 63 + .../contrib/jsternberg/aggregate/define.md | 91 + .../contrib/jsternberg/aggregate/max.md | 63 + .../contrib/jsternberg/aggregate/mean.md | 63 + .../contrib/jsternberg/aggregate/min.md | 63 + .../contrib/jsternberg/aggregate/sum.md | 63 + .../contrib/jsternberg/aggregate/table.md | 125 + .../contrib/jsternberg/aggregate/window.md | 84 + .../contrib/jsternberg/influxdb/_index.md | 45 +- .../contrib/jsternberg/influxdb/from.md | 137 + .../contrib/jsternberg/influxdb/select.md | 181 +- .../stdlib/contrib/jsternberg/math/_index.md | 41 + .../stdlib/contrib/jsternberg/math/max.md | 48 + .../contrib/jsternberg/math/maxindex.md | 48 + .../stdlib/contrib/jsternberg/math/min.md | 48 + .../contrib/jsternberg/math/minindex.md | 48 + .../stdlib/contrib/jsternberg/math/sum.md | 48 + .../flux/v0.x/stdlib/contrib/rhajek/_index.md | 42 +- .../stdlib/contrib/rhajek/bigpanda/_index.md | 76 +- .../contrib/rhajek/bigpanda/endpoint.md | 106 +- .../contrib/rhajek/bigpanda/sendalert.md | 84 +- .../rhajek/bigpanda/statusfromlevel.md | 99 +- .../flux/v0.x/stdlib/contrib/sranka/_index.md | 43 +- .../stdlib/contrib/sranka/opsgenie/_index.md | 52 +- .../contrib/sranka/opsgenie/endpoint.md | 131 +- .../sranka/opsgenie/responderstojson.md | 62 +- .../contrib/sranka/opsgenie/sendalert.md | 154 +- .../stdlib/contrib/sranka/sensu/_index.md | 55 +- .../stdlib/contrib/sranka/sensu/endpoint.md | 122 +- .../v0.x/stdlib/contrib/sranka/sensu/event.md | 125 +- .../contrib/sranka/sensu/tosensuname.md | 59 +- .../stdlib/contrib/sranka/teams/_index.md | 57 +- .../stdlib/contrib/sranka/teams/endpoint.md | 84 +- .../stdlib/contrib/sranka/teams/message.md | 73 +- .../stdlib/contrib/sranka/telegram/_index.md | 115 +- .../contrib/sranka/telegram/endpoint.md | 124 +- .../stdlib/contrib/sranka/telegram/message.md | 109 +- .../contrib/sranka/webexteams/_index.md | 38 +- .../contrib/sranka/webexteams/endpoint.md | 96 +- .../contrib/sranka/webexteams/message.md | 85 +- .../stdlib/contrib/tomhollingworth/_index.md | 43 +- .../contrib/tomhollingworth/events/_index.md | 44 +- .../tomhollingworth/events/duration.md | 244 +- content/flux/v0.x/stdlib/csv/_index.md | 44 +- content/flux/v0.x/stdlib/csv/from.md | 160 +- content/flux/v0.x/stdlib/date/_index.md | 110 +- content/flux/v0.x/stdlib/date/add.md | 88 +- content/flux/v0.x/stdlib/date/hour.md | 75 +- content/flux/v0.x/stdlib/date/microsecond.md | 70 +- content/flux/v0.x/stdlib/date/millisecond.md | 68 +- content/flux/v0.x/stdlib/date/minute.md | 75 +- content/flux/v0.x/stdlib/date/month.md | 76 +- content/flux/v0.x/stdlib/date/monthday.md | 77 +- content/flux/v0.x/stdlib/date/nanosecond.md | 66 +- content/flux/v0.x/stdlib/date/quarter.md | 75 +- content/flux/v0.x/stdlib/date/scale.md | 63 +- content/flux/v0.x/stdlib/date/second.md | 68 +- content/flux/v0.x/stdlib/date/sub.md | 92 +- content/flux/v0.x/stdlib/date/truncate.md | 111 +- content/flux/v0.x/stdlib/date/week.md | 77 +- content/flux/v0.x/stdlib/date/weekday.md | 78 +- content/flux/v0.x/stdlib/date/year.md | 73 +- content/flux/v0.x/stdlib/date/yearday.md | 77 +- content/flux/v0.x/stdlib/dict/_index.md | 46 +- content/flux/v0.x/stdlib/dict/fromlist.md | 60 +- content/flux/v0.x/stdlib/dict/get.md | 76 +- content/flux/v0.x/stdlib/dict/insert.md | 97 +- content/flux/v0.x/stdlib/dict/remove.md | 69 +- .../flux/v0.x/stdlib/experimental/_index.md | 59 +- .../v0.x/stdlib/experimental/addduration.md | 99 +- .../stdlib/experimental/aggregate/_index.md | 41 +- .../stdlib/experimental/aggregate/rate.md | 154 +- .../v0.x/stdlib/experimental/aligntime.md | 142 +- .../v0.x/stdlib/experimental/array/_index.md | 45 +- .../v0.x/stdlib/experimental/array/concat.md | 75 +- .../v0.x/stdlib/experimental/array/filter.md | 97 +- .../v0.x/stdlib/experimental/array/from.md | 98 + .../v0.x/stdlib/experimental/array/map.md | 107 +- .../stdlib/experimental/bigtable/_index.md | 42 +- .../v0.x/stdlib/experimental/bigtable/from.md | 93 +- .../stdlib/experimental/bitwise/_index.md | 41 +- .../v0.x/stdlib/experimental/bitwise/sand.md | 125 +- .../stdlib/experimental/bitwise/sclear.md | 127 +- .../stdlib/experimental/bitwise/slshift.md | 127 +- .../v0.x/stdlib/experimental/bitwise/snot.md | 118 +- .../v0.x/stdlib/experimental/bitwise/sor.md | 125 +- .../stdlib/experimental/bitwise/srshift.md | 127 +- .../v0.x/stdlib/experimental/bitwise/sxor.md | 125 +- .../v0.x/stdlib/experimental/bitwise/uand.md | 125 +- .../stdlib/experimental/bitwise/uclear.md | 125 +- .../stdlib/experimental/bitwise/ulshift.md | 127 +- .../v0.x/stdlib/experimental/bitwise/unot.md | 118 +- .../v0.x/stdlib/experimental/bitwise/uor.md | 125 +- .../stdlib/experimental/bitwise/urshift.md | 127 +- .../v0.x/stdlib/experimental/bitwise/uxor.md | 125 +- .../flux/v0.x/stdlib/experimental/chain.md | 87 +- .../flux/v0.x/stdlib/experimental/count.md | 115 +- .../v0.x/stdlib/experimental/csv/_index.md | 43 +- .../flux/v0.x/stdlib/experimental/csv/from.md | 63 +- .../flux/v0.x/stdlib/experimental/distinct.md | 133 +- content/flux/v0.x/stdlib/experimental/fill.md | 223 +- .../flux/v0.x/stdlib/experimental/first.md | 116 +- .../v0.x/stdlib/experimental/geo/_index.md | 157 +- .../v0.x/stdlib/experimental/geo/astracks.md | 135 +- .../stdlib/experimental/geo/filterrows.md | 213 +- .../v0.x/stdlib/experimental/geo/getgrid.md | 87 + .../v0.x/stdlib/experimental/geo/getlevel.md | 61 + .../stdlib/experimental/geo/gridfilter.md | 222 +- .../stdlib/experimental/geo/groupbyarea.md | 137 +- .../stdlib/experimental/geo/s2cellidtoken.md | 163 +- .../stdlib/experimental/geo/s2celllatlon.md | 66 +- .../v0.x/stdlib/experimental/geo/shapedata.md | 133 +- .../stdlib/experimental/geo/st_contains.md | 91 +- .../stdlib/experimental/geo/st_distance.md | 89 +- .../stdlib/experimental/geo/st_dwithin.md | 97 +- .../stdlib/experimental/geo/st_intersects.md | 84 +- .../v0.x/stdlib/experimental/geo/st_length.md | 78 +- .../stdlib/experimental/geo/st_linestring.md | 98 +- .../stdlib/experimental/geo/stcontains.md | 62 + .../stdlib/experimental/geo/stdistance.md | 62 + .../v0.x/stdlib/experimental/geo/stlength.md | 59 + .../stdlib/experimental/geo/strictfilter.md | 152 +- .../v0.x/stdlib/experimental/geo/torows.md | 93 +- .../flux/v0.x/stdlib/experimental/group.md | 125 +- .../v0.x/stdlib/experimental/histogram.md | 195 +- .../stdlib/experimental/histogramquantile.md | 122 +- .../v0.x/stdlib/experimental/http/_index.md | 48 +- .../flux/v0.x/stdlib/experimental/http/get.md | 148 +- .../experimental/http/requests/_index.md | 100 +- .../stdlib/experimental/http/requests/do.md | 217 +- .../stdlib/experimental/http/requests/get.md | 136 +- .../stdlib/experimental/http/requests/peek.md | 105 +- .../stdlib/experimental/http/requests/post.md | 163 +- .../stdlib/experimental/influxdb/_index.md | 39 +- .../v0.x/stdlib/experimental/influxdb/api.md | 179 +- .../flux/v0.x/stdlib/experimental/integral.md | 179 +- .../v0.x/stdlib/experimental/iox/_index.md | 36 +- .../flux/v0.x/stdlib/experimental/iox/from.md | 58 +- content/flux/v0.x/stdlib/experimental/join.md | 186 +- .../v0.x/stdlib/experimental/json/_index.md | 42 +- .../v0.x/stdlib/experimental/json/parse.md | 187 +- .../v0.x/stdlib/experimental/kaufmansama.md | 114 +- content/flux/v0.x/stdlib/experimental/last.md | 116 +- content/flux/v0.x/stdlib/experimental/max.md | 115 +- content/flux/v0.x/stdlib/experimental/mean.md | 97 +- content/flux/v0.x/stdlib/experimental/min.md | 115 +- content/flux/v0.x/stdlib/experimental/mode.md | 126 +- .../v0.x/stdlib/experimental/mqtt/_index.md | 41 +- .../v0.x/stdlib/experimental/mqtt/publish.md | 161 +- .../flux/v0.x/stdlib/experimental/mqtt/to.md | 184 +- .../v0.x/stdlib/experimental/objectkeys.md | 57 +- .../v0.x/stdlib/experimental/oee/_index.md | 40 +- .../flux/v0.x/stdlib/experimental/oee/apq.md | 128 +- .../stdlib/experimental/oee/computeapq.md | 156 +- .../flux/v0.x/stdlib/experimental/preview.md | 57 +- .../stdlib/experimental/prometheus/_index.md | 43 +- .../prometheus/histogramquantile.md | 80 +- .../stdlib/experimental/prometheus/scrape.md | 66 +- .../flux/v0.x/stdlib/experimental/quantile.md | 228 +- .../v0.x/stdlib/experimental/query/_index.md | 59 +- .../stdlib/experimental/query/filterfields.md | 61 +- .../experimental/query/filtermeasurement.md | 61 +- .../stdlib/experimental/query/fromrange.md | 95 +- .../stdlib/experimental/query/inbucket.md | 140 +- .../v0.x/stdlib/experimental/record/_index.md | 69 +- .../v0.x/stdlib/experimental/record/get.md | 76 +- content/flux/v0.x/stdlib/experimental/set.md | 99 +- content/flux/v0.x/stdlib/experimental/skew.md | 97 +- .../flux/v0.x/stdlib/experimental/spread.md | 100 +- .../flux/v0.x/stdlib/experimental/stddev.md | 121 +- .../v0.x/stdlib/experimental/subduration.md | 99 +- content/flux/v0.x/stdlib/experimental/sum.md | 99 +- .../v0.x/stdlib/experimental/table/_index.md | 37 +- .../v0.x/stdlib/experimental/table/fill.md | 125 +- content/flux/v0.x/stdlib/experimental/to.md | 177 +- .../flux/v0.x/stdlib/experimental/unique.md | 136 +- .../stdlib/experimental/universe/_index.md | 46 + .../stdlib/experimental/universe/columns.md | 76 + .../v0.x/stdlib/experimental/universe/fill.md | 191 + .../v0.x/stdlib/experimental/universe/mean.md | 107 + .../v0.x/stdlib/experimental/usage/_index.md | 45 +- .../v0.x/stdlib/experimental/usage/from.md | 197 +- .../v0.x/stdlib/experimental/usage/limits.md | 157 +- .../flux/v0.x/stdlib/experimental/window.md | 229 +- content/flux/v0.x/stdlib/generate/_index.md | 37 +- content/flux/v0.x/stdlib/generate/from.md | 82 +- content/flux/v0.x/stdlib/http/_index.md | 42 +- content/flux/v0.x/stdlib/http/basicauth.md | 68 +- content/flux/v0.x/stdlib/http/endpoint.md | 87 +- content/flux/v0.x/stdlib/http/pathescape.md | 117 +- content/flux/v0.x/stdlib/http/post.md | 90 +- content/flux/v0.x/stdlib/influxdata/_index.md | 34 +- .../v0.x/stdlib/influxdata/influxdb/_index.md | 44 +- .../stdlib/influxdata/influxdb/buckets.md | 90 + .../stdlib/influxdata/influxdb/cardinality.md | 183 +- .../v0.x/stdlib/influxdata/influxdb/from.md | 275 +- .../influxdata/influxdb/monitor/_index.md | 82 +- .../influxdata/influxdb/monitor/check.md | 174 +- .../influxdata/influxdb/monitor/deadman.md | 134 +- .../influxdata/influxdb/monitor/from.md | 89 +- .../stdlib/influxdata/influxdb/monitor/log.md | 48 + .../influxdata/influxdb/monitor/logs.md | 86 +- .../influxdata/influxdb/monitor/notify.md | 130 +- .../influxdb/monitor/statechanges.md | 124 +- .../influxdb/monitor/statechangesonly.md | 112 +- .../influxdata/influxdb/monitor/write.md | 48 + .../influxdata/influxdb/sample/_index.md | 44 +- .../influxdata/influxdb/sample/aligntonow.md | 75 +- .../stdlib/influxdata/influxdb/sample/data.md | 152 +- .../stdlib/influxdata/influxdb/sample/list.md | 53 +- .../influxdata/influxdb/schema/_index.md | 46 +- .../influxdata/influxdb/schema/fieldkeys.md | 120 +- .../influxdb/schema/fieldsascols.md | 107 +- .../influxdb/schema/measurementfieldkeys.md | 102 +- .../influxdb/schema/measurements.md | 108 +- .../influxdb/schema/measurementtagkeys.md | 101 +- .../influxdb/schema/measurementtagvalues.md | 119 +- .../influxdata/influxdb/schema/tagkeys.md | 117 +- .../influxdata/influxdb/schema/tagvalues.md | 126 +- .../influxdata/influxdb/secrets/_index.md | 44 +- .../stdlib/influxdata/influxdb/secrets/get.md | 68 +- .../influxdata/influxdb/tasks/_index.md | 61 +- .../influxdata/influxdb/tasks/lastsuccess.md | 72 +- .../v0.x/stdlib/influxdata/influxdb/to.md | 347 +- .../stdlib/influxdata/influxdb/v1/_index.md | 80 +- .../influxdata/influxdb/v1/databases.md | 94 +- .../influxdata/influxdb/v1/fieldkeys.md | 122 +- .../influxdata/influxdb/v1/fieldsascols.md | 110 +- .../stdlib/influxdata/influxdb/v1/json.md | 127 + .../influxdb/v1/measurementfieldkeys.md | 89 +- .../influxdata/influxdb/v1/measurements.md | 77 +- .../influxdb/v1/measurementtagkeys.md | 85 +- .../influxdb/v1/measurementtagvalues.md | 97 +- .../stdlib/influxdata/influxdb/v1/tagkeys.md | 104 +- .../influxdata/influxdb/v1/tagvalues.md | 111 +- content/flux/v0.x/stdlib/internal/_index.md | 36 + .../v0.x/stdlib/internal/boolean/_index.md | 40 + .../flux/v0.x/stdlib/internal/debug/_index.md | 53 + .../v0.x/stdlib/internal/debug/feature.md | 48 + .../v0.x/stdlib/internal/debug/getoption.md | 54 + .../flux/v0.x/stdlib/internal/debug/opaque.md | 52 + .../flux/v0.x/stdlib/internal/debug/pass.md | 50 + .../flux/v0.x/stdlib/internal/debug/sink.md | 48 + .../flux/v0.x/stdlib/internal/debug/slurp.md | 52 + .../v0.x/stdlib/internal/debug/unpivot.md | 52 + .../flux/v0.x/stdlib/internal/gen/_index.md | 41 + .../flux/v0.x/stdlib/internal/gen/tables.md | 71 + .../v0.x/stdlib/internal/influxql/_index.md | 42 + .../v0.x/stdlib/internal/location/_index.md | 44 + .../v0.x/stdlib/internal/promql/_index.md | 41 + .../v0.x/stdlib/internal/promql/changes.md | 50 + .../v0.x/stdlib/internal/promql/emptytable.md | 44 + .../internal/promql/extrapolatedrate.md | 76 + .../stdlib/internal/promql/holtwinters.md | 66 + .../stdlib/internal/promql/instantrate.md | 60 + .../flux/v0.x/stdlib/internal/promql/join.md | 64 + .../stdlib/internal/promql/labelreplace.md | 80 + .../internal/promql/linearregression.md | 67 + .../internal/promql/promhistogramquantile.md | 80 + .../internal/promql/promqldayofmonth.md | 50 + .../stdlib/internal/promql/promqldayofweek.md | 50 + .../internal/promql/promqldaysinmonth.md | 50 + .../v0.x/stdlib/internal/promql/promqlhour.md | 50 + .../stdlib/internal/promql/promqlminute.md | 50 + .../stdlib/internal/promql/promqlmonth.md | 50 + .../v0.x/stdlib/internal/promql/promqlyear.md | 50 + .../v0.x/stdlib/internal/promql/quantile.md | 64 + .../v0.x/stdlib/internal/promql/resets.md | 50 + .../v0.x/stdlib/internal/promql/timestamp.md | 50 + .../v0.x/stdlib/internal/testutil/_index.md | 41 + .../v0.x/stdlib/internal/testutil/fail.md | 40 + .../v0.x/stdlib/internal/testutil/makeany.md | 48 + .../stdlib/internal/testutil/makerecord.md | 48 + .../v0.x/stdlib/internal/testutil/yield.md | 48 + .../flux/v0.x/stdlib/interpolate/_index.md | 46 +- .../flux/v0.x/stdlib/interpolate/linear.md | 118 +- content/flux/v0.x/stdlib/join/_index.md | 41 + content/flux/v0.x/stdlib/join/join.md | 78 + content/flux/v0.x/stdlib/json/_index.md | 42 +- content/flux/v0.x/stdlib/json/encode.md | 78 +- content/flux/v0.x/stdlib/kafka/_index.md | 44 + content/flux/v0.x/stdlib/kafka/to.md | 133 + content/flux/v0.x/stdlib/math/_index.md | 100 +- content/flux/v0.x/stdlib/math/abs.md | 116 +- content/flux/v0.x/stdlib/math/acos.md | 118 +- content/flux/v0.x/stdlib/math/acosh.md | 117 +- content/flux/v0.x/stdlib/math/asin.md | 119 +- content/flux/v0.x/stdlib/math/asinh.md | 118 +- content/flux/v0.x/stdlib/math/atan.md | 117 +- content/flux/v0.x/stdlib/math/atan2.md | 76 +- content/flux/v0.x/stdlib/math/atanh.md | 123 +- content/flux/v0.x/stdlib/math/cbrt.md | 118 +- content/flux/v0.x/stdlib/math/ceil.md | 118 +- content/flux/v0.x/stdlib/math/copysign.md | 102 +- content/flux/v0.x/stdlib/math/cos.md | 62 +- content/flux/v0.x/stdlib/math/cosh.md | 63 +- content/flux/v0.x/stdlib/math/dim.md | 107 +- content/flux/v0.x/stdlib/math/erf.md | 118 +- content/flux/v0.x/stdlib/math/erfc.md | 118 +- content/flux/v0.x/stdlib/math/erfcinv.md | 122 +- content/flux/v0.x/stdlib/math/erfinv.md | 122 +- content/flux/v0.x/stdlib/math/exp.md | 117 +- content/flux/v0.x/stdlib/math/exp2.md | 117 +- content/flux/v0.x/stdlib/math/expm1.md | 118 +- content/flux/v0.x/stdlib/math/float64bits.md | 119 +- .../flux/v0.x/stdlib/math/float64frombits.md | 123 + content/flux/v0.x/stdlib/math/floor.md | 118 +- content/flux/v0.x/stdlib/math/frexp.md | 128 +- content/flux/v0.x/stdlib/math/gamma.md | 121 +- content/flux/v0.x/stdlib/math/hypot.md | 110 +- content/flux/v0.x/stdlib/math/ilogb.md | 118 +- content/flux/v0.x/stdlib/math/isinf.md | 128 +- content/flux/v0.x/stdlib/math/isnan.md | 117 +- content/flux/v0.x/stdlib/math/j0.md | 118 +- content/flux/v0.x/stdlib/math/j1.md | 117 +- content/flux/v0.x/stdlib/math/jn.md | 126 +- content/flux/v0.x/stdlib/math/ldexp.md | 127 +- content/flux/v0.x/stdlib/math/lgamma.md | 126 +- content/flux/v0.x/stdlib/math/log.md | 73 +- content/flux/v0.x/stdlib/math/log10.md | 73 +- content/flux/v0.x/stdlib/math/log1p.md | 124 +- content/flux/v0.x/stdlib/math/log2.md | 119 +- content/flux/v0.x/stdlib/math/logb.md | 118 +- content/flux/v0.x/stdlib/math/minf.md | 120 +- content/flux/v0.x/stdlib/math/mmax.md | 113 +- content/flux/v0.x/stdlib/math/mmin.md | 112 +- content/flux/v0.x/stdlib/math/mod.md | 115 +- content/flux/v0.x/stdlib/math/modf.md | 119 +- content/flux/v0.x/stdlib/math/nan.md | 47 +- content/flux/v0.x/stdlib/math/nextafter.md | 108 +- content/flux/v0.x/stdlib/math/pow.md | 126 +- content/flux/v0.x/stdlib/math/pow10.md | 117 +- content/flux/v0.x/stdlib/math/remainder.md | 110 +- content/flux/v0.x/stdlib/math/round.md | 118 +- content/flux/v0.x/stdlib/math/roundtoeven.md | 121 +- content/flux/v0.x/stdlib/math/signbit.md | 116 +- content/flux/v0.x/stdlib/math/sin.md | 118 +- content/flux/v0.x/stdlib/math/sincos.md | 121 +- content/flux/v0.x/stdlib/math/sinh.md | 118 +- content/flux/v0.x/stdlib/math/sqrt.md | 119 +- content/flux/v0.x/stdlib/math/tan.md | 118 +- content/flux/v0.x/stdlib/math/tanh.md | 118 +- content/flux/v0.x/stdlib/math/trunc.md | 118 +- content/flux/v0.x/stdlib/math/y0.md | 119 +- content/flux/v0.x/stdlib/math/y1.md | 119 +- content/flux/v0.x/stdlib/math/yn.md | 108 +- content/flux/v0.x/stdlib/pagerduty/_index.md | 55 +- .../v0.x/stdlib/pagerduty/actionfromlevel.md | 61 + .../stdlib/pagerduty/actionfromseverity.md | 61 +- .../flux/v0.x/stdlib/pagerduty/dedupkey.md | 120 +- .../flux/v0.x/stdlib/pagerduty/endpoint.md | 130 +- .../flux/v0.x/stdlib/pagerduty/sendevent.md | 210 +- .../stdlib/pagerduty/severityfromlevel.md | 72 +- content/flux/v0.x/stdlib/planner/_index.md | 52 + content/flux/v0.x/stdlib/profiler/_index.md | 66 +- content/flux/v0.x/stdlib/pushbullet/_index.md | 54 +- .../flux/v0.x/stdlib/pushbullet/endpoint.md | 83 +- .../flux/v0.x/stdlib/pushbullet/pushdata.md | 97 +- .../flux/v0.x/stdlib/pushbullet/pushnote.md | 90 +- content/flux/v0.x/stdlib/regexp/_index.md | 45 +- content/flux/v0.x/stdlib/regexp/compile.md | 65 +- content/flux/v0.x/stdlib/regexp/findstring.md | 134 +- .../v0.x/stdlib/regexp/findstringindex.md | 78 +- content/flux/v0.x/stdlib/regexp/getstring.md | 56 +- .../v0.x/stdlib/regexp/matchregexpstring.md | 79 +- content/flux/v0.x/stdlib/regexp/quotemeta.md | 56 +- .../v0.x/stdlib/regexp/replaceallstring.md | 141 +- .../flux/v0.x/stdlib/regexp/splitregexp.md | 81 +- content/flux/v0.x/stdlib/runtime/_index.md | 41 +- content/flux/v0.x/stdlib/runtime/version.md | 59 +- content/flux/v0.x/stdlib/sampledata/_index.md | 40 +- content/flux/v0.x/stdlib/sampledata/bool.md | 77 +- content/flux/v0.x/stdlib/sampledata/float.md | 77 +- content/flux/v0.x/stdlib/sampledata/int.md | 77 +- .../v0.x/stdlib/sampledata/numericbool.md | 77 +- content/flux/v0.x/stdlib/sampledata/string.md | 77 +- content/flux/v0.x/stdlib/sampledata/uint.md | 78 +- content/flux/v0.x/stdlib/slack/_index.md | 53 +- content/flux/v0.x/stdlib/slack/endpoint.md | 99 +- content/flux/v0.x/stdlib/slack/message.md | 136 +- .../v0.x/stdlib/slack/validatecolorstring.md | 59 + content/flux/v0.x/stdlib/socket/_index.md | 44 + content/flux/v0.x/stdlib/socket/from.md | 85 + content/flux/v0.x/stdlib/sql/_index.md | 161 +- content/flux/v0.x/stdlib/sql/from.md | 105 +- content/flux/v0.x/stdlib/sql/to.md | 120 +- content/flux/v0.x/stdlib/strings/_index.md | 42 +- content/flux/v0.x/stdlib/strings/compare.md | 94 +- .../flux/v0.x/stdlib/strings/containsany.md | 106 +- .../flux/v0.x/stdlib/strings/containsstr.md | 105 +- content/flux/v0.x/stdlib/strings/countstr.md | 117 +- content/flux/v0.x/stdlib/strings/equalfold.md | 94 +- content/flux/v0.x/stdlib/strings/hasprefix.md | 105 +- content/flux/v0.x/stdlib/strings/hassuffix.md | 107 +- content/flux/v0.x/stdlib/strings/index-fn.md | 115 + .../flux/v0.x/stdlib/strings/index-func.md | 51 - content/flux/v0.x/stdlib/strings/indexany.md | 113 +- content/flux/v0.x/stdlib/strings/isdigit.md | 96 +- content/flux/v0.x/stdlib/strings/isletter.md | 100 +- content/flux/v0.x/stdlib/strings/islower.md | 95 +- content/flux/v0.x/stdlib/strings/isupper.md | 95 +- content/flux/v0.x/stdlib/strings/joinstr.md | 64 +- content/flux/v0.x/stdlib/strings/lastindex.md | 118 +- .../flux/v0.x/stdlib/strings/lastindexany.md | 116 +- content/flux/v0.x/stdlib/strings/repeat.md | 113 +- content/flux/v0.x/stdlib/strings/replace.md | 128 +- .../flux/v0.x/stdlib/strings/replaceall.md | 121 +- content/flux/v0.x/stdlib/strings/split.md | 69 +- .../flux/v0.x/stdlib/strings/splitafter.md | 70 +- .../flux/v0.x/stdlib/strings/splitaftern.md | 78 +- content/flux/v0.x/stdlib/strings/splitn.md | 75 +- content/flux/v0.x/stdlib/strings/strlen.md | 148 +- content/flux/v0.x/stdlib/strings/substring.md | 124 +- content/flux/v0.x/stdlib/strings/title.md | 108 +- content/flux/v0.x/stdlib/strings/tolower.md | 108 +- content/flux/v0.x/stdlib/strings/totitle.md | 86 +- content/flux/v0.x/stdlib/strings/toupper.md | 132 +- content/flux/v0.x/stdlib/strings/trim.md | 114 +- content/flux/v0.x/stdlib/strings/trimleft.md | 114 +- .../flux/v0.x/stdlib/strings/trimprefix.md | 118 +- content/flux/v0.x/stdlib/strings/trimright.md | 115 +- content/flux/v0.x/stdlib/strings/trimspace.md | 105 +- .../flux/v0.x/stdlib/strings/trimsuffix.md | 113 +- content/flux/v0.x/stdlib/system/_index.md | 42 +- content/flux/v0.x/stdlib/system/time.md | 61 +- content/flux/v0.x/stdlib/testing/_index.md | 93 +- .../flux/v0.x/stdlib/testing/assertempty.md | 66 +- .../flux/v0.x/stdlib/testing/assertequals.md | 96 +- .../v0.x/stdlib/testing/assertequalvalues.md | 79 + content/flux/v0.x/stdlib/testing/benchmark.md | 76 +- content/flux/v0.x/stdlib/testing/diff.md | 146 +- .../flux/v0.x/stdlib/testing/expect/_index.md | 47 + .../v0.x/stdlib/testing/expect/planner.md | 52 + content/flux/v0.x/stdlib/testing/inspect.md | 86 +- content/flux/v0.x/stdlib/testing/load.md | 88 +- content/flux/v0.x/stdlib/testing/loadmem.md | 48 - .../flux/v0.x/stdlib/testing/loadstorage.md | 56 - content/flux/v0.x/stdlib/testing/run.md | 65 +- content/flux/v0.x/stdlib/timezone/_index.md | 47 +- content/flux/v0.x/stdlib/timezone/fixed.md | 92 +- content/flux/v0.x/stdlib/timezone/location.md | 68 +- content/flux/v0.x/stdlib/types/_index.md | 38 +- content/flux/v0.x/stdlib/types/istype.md | 222 +- content/flux/v0.x/stdlib/universe/_index.md | 70 +- .../v0.x/stdlib/universe/aggregatewindow.md | 412 +- content/flux/v0.x/stdlib/universe/bool.md | 174 +- content/flux/v0.x/stdlib/universe/bottom.md | 124 +- content/flux/v0.x/stdlib/universe/buckets.md | 24 - content/flux/v0.x/stdlib/universe/bytes.md | 55 +- .../universe/chandemomentumoscillator.md | 117 +- content/flux/v0.x/stdlib/universe/columns.md | 102 +- content/flux/v0.x/stdlib/universe/contains.md | 155 +- content/flux/v0.x/stdlib/universe/count.md | 106 +- content/flux/v0.x/stdlib/universe/cov.md | 124 +- .../flux/v0.x/stdlib/universe/covariance.md | 122 +- .../v0.x/stdlib/universe/cumulativesum.md | 128 +- .../flux/v0.x/stdlib/universe/derivative.md | 277 +- content/flux/v0.x/stdlib/universe/die.md | 59 + .../flux/v0.x/stdlib/universe/difference.md | 397 +- content/flux/v0.x/stdlib/universe/display.md | 113 +- content/flux/v0.x/stdlib/universe/distinct.md | 249 +- .../flux/v0.x/stdlib/universe/doubleema.md | 126 +- content/flux/v0.x/stdlib/universe/drop.md | 206 +- .../flux/v0.x/stdlib/universe/duplicate.md | 128 +- content/flux/v0.x/stdlib/universe/duration.md | 135 +- content/flux/v0.x/stdlib/universe/elapsed.md | 146 +- .../universe/exponentialmovingaverage.md | 190 +- content/flux/v0.x/stdlib/universe/fill.md | 223 +- content/flux/v0.x/stdlib/universe/filter.md | 240 +- .../flux/v0.x/stdlib/universe/findcolumn.md | 83 +- .../flux/v0.x/stdlib/universe/findrecord.md | 85 +- content/flux/v0.x/stdlib/universe/first.md | 110 +- content/flux/v0.x/stdlib/universe/float.md | 182 +- .../flux/v0.x/stdlib/universe/getcolumn.md | 71 +- .../flux/v0.x/stdlib/universe/getrecord.md | 69 +- content/flux/v0.x/stdlib/universe/group.md | 374 +- .../v0.x/stdlib/universe/highestaverage.md | 124 +- .../v0.x/stdlib/universe/highestcurrent.md | 124 +- .../flux/v0.x/stdlib/universe/highestmax.md | 123 +- .../flux/v0.x/stdlib/universe/histogram.md | 237 +- .../v0.x/stdlib/universe/histogramquantile.md | 193 +- .../flux/v0.x/stdlib/universe/holtwinters.md | 372 +- .../v0.x/stdlib/universe/hourselection.md | 147 +- content/flux/v0.x/stdlib/universe/increase.md | 131 +- content/flux/v0.x/stdlib/universe/int.md | 199 +- content/flux/v0.x/stdlib/universe/integral.md | 201 +- .../flux/v0.x/stdlib/universe/intervals.md | 154 - content/flux/v0.x/stdlib/universe/join.md | 265 +- .../flux/v0.x/stdlib/universe/kaufmansama.md | 129 +- .../flux/v0.x/stdlib/universe/kaufmanser.md | 120 +- content/flux/v0.x/stdlib/universe/keep.md | 202 +- content/flux/v0.x/stdlib/universe/keys.md | 239 +- .../flux/v0.x/stdlib/universe/keyvalues.md | 249 +- content/flux/v0.x/stdlib/universe/last.md | 116 +- content/flux/v0.x/stdlib/universe/length.md | 53 +- content/flux/v0.x/stdlib/universe/limit.md | 155 +- .../flux/v0.x/stdlib/universe/linearbins.md | 84 +- .../v0.x/stdlib/universe/logarithmicbins.md | 90 +- .../v0.x/stdlib/universe/lowestaverage.md | 124 +- .../v0.x/stdlib/universe/lowestcurrent.md | 124 +- .../flux/v0.x/stdlib/universe/lowestmin.md | 123 +- content/flux/v0.x/stdlib/universe/map.md | 460 +-- content/flux/v0.x/stdlib/universe/max.md | 113 +- content/flux/v0.x/stdlib/universe/mean.md | 111 +- content/flux/v0.x/stdlib/universe/median.md | 216 +- content/flux/v0.x/stdlib/universe/min.md | 113 +- content/flux/v0.x/stdlib/universe/mode.md | 128 +- .../v0.x/stdlib/universe/movingaverage.md | 196 +- content/flux/v0.x/stdlib/universe/now.md | 73 +- content/flux/v0.x/stdlib/universe/pearsonr.md | 118 +- content/flux/v0.x/stdlib/universe/pivot.md | 260 +- content/flux/v0.x/stdlib/universe/quantile.md | 223 +- content/flux/v0.x/stdlib/universe/range.md | 114 +- content/flux/v0.x/stdlib/universe/reduce.md | 362 +- .../stdlib/universe/relativestrengthindex.md | 146 +- content/flux/v0.x/stdlib/universe/rename.md | 209 +- content/flux/v0.x/stdlib/universe/sample.md | 131 +- content/flux/v0.x/stdlib/universe/set.md | 130 +- content/flux/v0.x/stdlib/universe/skew.md | 107 +- content/flux/v0.x/stdlib/universe/sleep.md | 50 - content/flux/v0.x/stdlib/universe/sort.md | 225 +- content/flux/v0.x/stdlib/universe/spread.md | 112 +- .../flux/v0.x/stdlib/universe/statecount.md | 148 +- .../v0.x/stdlib/universe/stateduration.md | 169 +- .../v0.x/stdlib/universe/statetracking.md | 263 ++ content/flux/v0.x/stdlib/universe/stddev.md | 121 +- content/flux/v0.x/stdlib/universe/string.md | 171 +- content/flux/v0.x/stdlib/universe/sum.md | 110 +- .../flux/v0.x/stdlib/universe/tablefind.md | 82 +- content/flux/v0.x/stdlib/universe/tail.md | 181 +- content/flux/v0.x/stdlib/universe/time.md | 169 +- .../stdlib/universe/timedmovingaverage.md | 207 +- .../flux/v0.x/stdlib/universe/timeshift.md | 202 +- .../v0.x/stdlib/universe/timeweightedavg.md | 116 +- content/flux/v0.x/stdlib/universe/tobool.md | 126 +- content/flux/v0.x/stdlib/universe/today.md | 58 +- .../flux/v0.x/stdlib/universe/toduration.md | 39 - content/flux/v0.x/stdlib/universe/tofloat.md | 201 +- content/flux/v0.x/stdlib/universe/toint.md | 280 +- content/flux/v0.x/stdlib/universe/top.md | 124 +- content/flux/v0.x/stdlib/universe/tostring.md | 130 +- content/flux/v0.x/stdlib/universe/totime.md | 151 +- content/flux/v0.x/stdlib/universe/touint.md | 250 +- .../flux/v0.x/stdlib/universe/tripleema.md | 132 +- .../universe/tripleexponentialderivative.md | 120 +- .../stdlib/universe/truncatetimecolumn.md | 151 +- content/flux/v0.x/stdlib/universe/uint.md | 189 +- content/flux/v0.x/stdlib/universe/union.md | 287 +- content/flux/v0.x/stdlib/universe/unique.md | 127 +- content/flux/v0.x/stdlib/universe/window.md | 411 +- content/flux/v0.x/stdlib/universe/yield.md | 78 +- data/flux_stdlib_frontmatter.yml | 3453 +++++++++++++++++ inject-flux-stdlib-frontmatter.js | 46 + layouts/partials/article.html | 1 + layouts/partials/article/contributors.html | 11 + layouts/partials/article/flux-contrib.html | 4 +- .../partials/article/flux-experimental.html | 6 +- package.json | 3 +- yarn.lock | 12 + 607 files changed, 46443 insertions(+), 21120 deletions(-) create mode 100644 content/flux/v0.x/stdlib/contrib/RohanSreerama5/_index.md create mode 100644 content/flux/v0.x/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/_index.md create mode 100644 content/flux/v0.x/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/naivebayes.md create mode 100644 content/flux/v0.x/stdlib/contrib/anaisdg/_index.md create mode 100644 content/flux/v0.x/stdlib/contrib/anaisdg/anomalydetection/_index.md create mode 100644 content/flux/v0.x/stdlib/contrib/anaisdg/anomalydetection/mad.md create mode 100644 content/flux/v0.x/stdlib/contrib/anaisdg/statsmodels/_index.md create mode 100644 content/flux/v0.x/stdlib/contrib/anaisdg/statsmodels/linearregression.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/_index.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/count.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/define.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/max.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/mean.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/min.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/sum.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/table.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/window.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/from.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/math/_index.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/math/max.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/math/maxindex.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/math/min.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/math/minindex.md create mode 100644 content/flux/v0.x/stdlib/contrib/jsternberg/math/sum.md create mode 100644 content/flux/v0.x/stdlib/experimental/array/from.md create mode 100644 content/flux/v0.x/stdlib/experimental/geo/getgrid.md create mode 100644 content/flux/v0.x/stdlib/experimental/geo/getlevel.md create mode 100644 content/flux/v0.x/stdlib/experimental/geo/stcontains.md create mode 100644 content/flux/v0.x/stdlib/experimental/geo/stdistance.md create mode 100644 content/flux/v0.x/stdlib/experimental/geo/stlength.md create mode 100644 content/flux/v0.x/stdlib/experimental/universe/_index.md create mode 100644 content/flux/v0.x/stdlib/experimental/universe/columns.md create mode 100644 content/flux/v0.x/stdlib/experimental/universe/fill.md create mode 100644 content/flux/v0.x/stdlib/experimental/universe/mean.md create mode 100644 content/flux/v0.x/stdlib/influxdata/influxdb/buckets.md create mode 100644 content/flux/v0.x/stdlib/influxdata/influxdb/monitor/log.md create mode 100644 content/flux/v0.x/stdlib/influxdata/influxdb/monitor/write.md create mode 100644 content/flux/v0.x/stdlib/influxdata/influxdb/v1/json.md create mode 100644 content/flux/v0.x/stdlib/internal/_index.md create mode 100644 content/flux/v0.x/stdlib/internal/boolean/_index.md create mode 100644 content/flux/v0.x/stdlib/internal/debug/_index.md create mode 100644 content/flux/v0.x/stdlib/internal/debug/feature.md create mode 100644 content/flux/v0.x/stdlib/internal/debug/getoption.md create mode 100644 content/flux/v0.x/stdlib/internal/debug/opaque.md create mode 100644 content/flux/v0.x/stdlib/internal/debug/pass.md create mode 100644 content/flux/v0.x/stdlib/internal/debug/sink.md create mode 100644 content/flux/v0.x/stdlib/internal/debug/slurp.md create mode 100644 content/flux/v0.x/stdlib/internal/debug/unpivot.md create mode 100644 content/flux/v0.x/stdlib/internal/gen/_index.md create mode 100644 content/flux/v0.x/stdlib/internal/gen/tables.md create mode 100644 content/flux/v0.x/stdlib/internal/influxql/_index.md create mode 100644 content/flux/v0.x/stdlib/internal/location/_index.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/_index.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/changes.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/emptytable.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/extrapolatedrate.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/holtwinters.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/instantrate.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/join.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/labelreplace.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/linearregression.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/promhistogramquantile.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/promqldayofmonth.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/promqldayofweek.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/promqldaysinmonth.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/promqlhour.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/promqlminute.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/promqlmonth.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/promqlyear.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/quantile.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/resets.md create mode 100644 content/flux/v0.x/stdlib/internal/promql/timestamp.md create mode 100644 content/flux/v0.x/stdlib/internal/testutil/_index.md create mode 100644 content/flux/v0.x/stdlib/internal/testutil/fail.md create mode 100644 content/flux/v0.x/stdlib/internal/testutil/makeany.md create mode 100644 content/flux/v0.x/stdlib/internal/testutil/makerecord.md create mode 100644 content/flux/v0.x/stdlib/internal/testutil/yield.md create mode 100644 content/flux/v0.x/stdlib/join/_index.md create mode 100644 content/flux/v0.x/stdlib/join/join.md create mode 100644 content/flux/v0.x/stdlib/kafka/_index.md create mode 100644 content/flux/v0.x/stdlib/kafka/to.md create mode 100644 content/flux/v0.x/stdlib/math/float64frombits.md create mode 100644 content/flux/v0.x/stdlib/pagerduty/actionfromlevel.md create mode 100644 content/flux/v0.x/stdlib/planner/_index.md create mode 100644 content/flux/v0.x/stdlib/slack/validatecolorstring.md create mode 100644 content/flux/v0.x/stdlib/socket/_index.md create mode 100644 content/flux/v0.x/stdlib/socket/from.md create mode 100644 content/flux/v0.x/stdlib/strings/index-fn.md delete mode 100644 content/flux/v0.x/stdlib/strings/index-func.md create mode 100644 content/flux/v0.x/stdlib/testing/assertequalvalues.md create mode 100644 content/flux/v0.x/stdlib/testing/expect/_index.md create mode 100644 content/flux/v0.x/stdlib/testing/expect/planner.md delete mode 100644 content/flux/v0.x/stdlib/testing/loadmem.md delete mode 100644 content/flux/v0.x/stdlib/testing/loadstorage.md delete mode 100644 content/flux/v0.x/stdlib/universe/buckets.md create mode 100644 content/flux/v0.x/stdlib/universe/die.md delete mode 100644 content/flux/v0.x/stdlib/universe/intervals.md delete mode 100644 content/flux/v0.x/stdlib/universe/sleep.md create mode 100644 content/flux/v0.x/stdlib/universe/statetracking.md delete mode 100644 content/flux/v0.x/stdlib/universe/toduration.md create mode 100644 data/flux_stdlib_frontmatter.yml create mode 100644 inject-flux-stdlib-frontmatter.js create mode 100644 layouts/partials/article/contributors.html diff --git a/.circleci/config.yml b/.circleci/config.yml index c0841eee3..53616fd4b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,7 +29,10 @@ jobs: command: cd api-docs && yarn install - run: name: Generate API documentation - command: cd api-docs && bash generate-api-docs.sh + command: cd api-docs && bash generate-api-docs.sh + - run: + name: Inject Flux stdlib frontmatter + command: node ./inject-flux-stdlib-frontmatter.js - save_cache: key: install-{{ .Environment.CACHE_VERSION }}-{{ checksum ".circleci/config.yml" }} paths: diff --git a/assets/js/content-interactions.js b/assets/js/content-interactions.js index fac870e37..8398af98d 100644 --- a/assets/js/content-interactions.js +++ b/assets/js/content-interactions.js @@ -204,7 +204,7 @@ $('.tooltip').each( function(){ $('.article--content table').each(function() { var table = $(this); - var timeColumns = ['_time', '_start', '_stop']; + var timeColumns = ['_time', '*_time', '_start', '*_start', '_stop', '*_stop']; let header = []; let timeColumnIndexes = []; diff --git a/content/flux/v0.x/stdlib/_index.md b/content/flux/v0.x/stdlib/_index.md index d9e7c03e1..c8a4a4278 100644 --- a/content/flux/v0.x/stdlib/_index.md +++ b/content/flux/v0.x/stdlib/_index.md @@ -15,6 +15,7 @@ flux/v0.x/tags: [flux, functions, package] menu: flux_0_x_ref: name: Standard library + identifier: stdlib weight: 1 --- diff --git a/content/flux/v0.x/stdlib/all-functions.md b/content/flux/v0.x/stdlib/all-functions.md index a1552df74..2f71f3f64 100644 --- a/content/flux/v0.x/stdlib/all-functions.md +++ b/content/flux/v0.x/stdlib/all-functions.md @@ -8,7 +8,7 @@ aliases: menu: flux_0_x_ref: name: View all functions - parent: Standard library + parent: stdlib weight: 9 --- diff --git a/content/flux/v0.x/stdlib/array/_index.md b/content/flux/v0.x/stdlib/array/_index.md index 67664fe54..915b31405 100644 --- a/content/flux/v0.x/stdlib/array/_index.md +++ b/content/flux/v0.x/stdlib/array/_index.md @@ -1,32 +1,44 @@ --- -title: Flux array package -list_title: array package +title: array package description: > - The Flux `array` package provides functions for building tables from Flux arrays. - Import the `array` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/array/ - - /influxdb/cloud/reference/flux/stdlib/experimental/array/ - - /influxdb/v2.0/reference/flux/stdlib/array/ - - /influxdb/cloud/reference/flux/stdlib/array/ + The `array` package provides functions for building tables from Flux arrays. menu: flux_0_x_ref: - name: array - parent: Standard library + name: array + parent: stdlib + identifier: array weight: 11 -flux/v0.x/tags: [functions, array, package, table] cascade: - related: - - /flux/v0.x/data-types/composite/array/ -introduced: 0.103.0 + flux/v0.x/tags: [array, tables] + introduced: 0.103.0 --- -Flux `array` functions provide tools for building tables from Flux arrays. + + +The `array` package provides functions for building tables from Flux arrays. Import the `array` package: ```js import "array" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/array/from.md b/content/flux/v0.x/stdlib/array/from.md index 8d87e4bb9..c9ca87a68 100644 --- a/content/flux/v0.x/stdlib/array/from.md +++ b/content/flux/v0.x/stdlib/array/from.md @@ -1,47 +1,61 @@ --- title: array.from() function description: > - The experimental `array.from()` function constructs a table from an array of records. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/array/from/ - - /influxdb/cloud/reference/flux/stdlib/array/from/ - - /influxdb/v2.0/reference/flux/stdlib/experimental/array/from/ - - /influxdb/cloud/reference/flux/stdlib/experimental/array/from/ - - /flux/v0.x/stdlib/experimental/array/from/ + `array.from()` constructs a table from an array of records. menu: flux_0_x_ref: name: array.from parent: array -weight: 401 + identifier: array/from +weight: 101 flux/v0.x/tags: [inputs] -introduced: 0.103.0 --- -The `array.from()` function constructs a table from an array of records. -Each record in the array is converted into an output row or record. -All records must have the same keys and data types. + + +`array.from()` constructs a table from an array of records. + +Each record in the array is converted into an output row or record. All +records must have the same keys and data types. + +##### Function type signature -{{< keep-url >}} ```js -import "array" - -array.from( - rows: [ - {_time: 2020-01-01T00:00:00Z, _field: "exampleField", _value: 3, foo: "bar"}, - {_time: 2020-01-01T00:01:00Z, _field: "exampleField", _value: 4, foo: "bar"}, - {_time: 2020-01-01T00:02:00Z, _field: "exampleField", _value: 1, foo: "bar"}, - ], -) +(rows: [A]) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### rows {data-type="array"} +### rows +({{< req >}}) Array of records to construct a table with. + + + ## Examples -##### Build an arbitrary table +- [Build an arbitrary table](#build-an-arbitrary-table) +- [Union custom rows with query results](#union-custom-rows-with-query-results) + +### Build an arbitrary table + ```js import "array" @@ -50,14 +64,29 @@ rows = [{foo: "bar", baz: 21.2}, {foo: "bar", baz: 23.8}] array.from(rows: rows) ``` -##### Union custom rows with query results +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| foo | baz | +| ---- | ---- | +| bar | 21.2 | +| bar | 23.8 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Union custom rows with query results + ```js import "influxdata/influxdb/v1" import "array" tags = v1.tagValues(bucket: "example-bucket", tag: "host") + wildcard_tag = array.from(rows: [{_value: "*"}]) union(tables: [tags, wildcard_tag]) - ``` + diff --git a/content/flux/v0.x/stdlib/contrib/RohanSreerama5/_index.md b/content/flux/v0.x/stdlib/contrib/RohanSreerama5/_index.md new file mode 100644 index 000000000..220390c54 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/RohanSreerama5/_index.md @@ -0,0 +1,36 @@ +--- +title: RohanSreerama5 package +description: > + The `RohanSreerama5` package contains packages and functions contributed by [@RohanSreerama5](https://github.com/RohanSreerama5). +menu: + flux_0_x_ref: + name: RohanSreerama5 + parent: contrib + identifier: contrib/RohanSreerama5 +weight: 21 +--- + + + +The `RohanSreerama5` package contains packages and functions contributed by [@RohanSreerama5](https://github.com/RohanSreerama5). + + + + +## Packages + +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/_index.md b/content/flux/v0.x/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/_index.md new file mode 100644 index 000000000..5195ddb27 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/_index.md @@ -0,0 +1,49 @@ +--- +title: naiveBayesClassifier package +description: > + The `naiveBayesClassifier` package provides an implementation of + a naive Bayes classifier. +menu: + flux_0_x_ref: + name: naiveBayesClassifier + parent: contrib/RohanSreerama5 + identifier: contrib/RohanSreerama5/naiveBayesClassifier +weight: 31 +cascade: + + introduced: v0.86.0 +--- + + + +The `naiveBayesClassifier` package provides an implementation of +a naive Bayes classifier. +Import the `contrib/RohanSreerama5/naiveBayesClassifier` package: + +```js +import "contrib/RohanSreerama5/naiveBayesClassifier" +``` + +Currently supports single field classification and binary data sets. + +For information about demonstrating functions in this package, see the +[package README on GitHub](https://github.com/influxdata/flux/blob/master/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/README.md). + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/naivebayes.md b/content/flux/v0.x/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/naivebayes.md new file mode 100644 index 000000000..a8670b35d --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/naivebayes.md @@ -0,0 +1,72 @@ +--- +title: naiveBayesClassifier.naiveBayes() function +description: > + `naiveBayesClassifier.naiveBayes()` performs a naive Bayes classification. +menu: + flux_0_x_ref: + name: naiveBayesClassifier.naiveBayes + parent: contrib/RohanSreerama5/naiveBayesClassifier + identifier: contrib/RohanSreerama5/naiveBayesClassifier/naiveBayes +weight: 301 +flux/v0.x/tags: [transformations] +--- + + + +`naiveBayesClassifier.naiveBayes()` performs a naive Bayes classification. + + + +##### Function type signature + +```js +( + <-tables: stream[{C with _time: time, _measurement: E, _field: D}], + myClass: string, + myField: A, + myMeasurement: B, +) => stream[F] where A: Equatable, B: Equatable, D: Equatable, E: Equatable, F: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### myMeasurement +({{< req >}}) +Measurement to use as training data. + + + +### myField +({{< req >}}) +Field to use as training data. + + + +### myClass +({{< req >}}) +Class to classify against. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + diff --git a/content/flux/v0.x/stdlib/contrib/_index.md b/content/flux/v0.x/stdlib/contrib/_index.md index 2411d206c..bcee58ca0 100644 --- a/content/flux/v0.x/stdlib/contrib/_index.md +++ b/content/flux/v0.x/stdlib/contrib/_index.md @@ -1,22 +1,33 @@ --- -title: Flux contrib package (user-contributed) -list_title: contrib package (user-contributed) +title: contrib package description: > - The Flux `contrib` package contains packages and functions that are contributed - and maintained by members of the Flux and InfluxDB communities. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/ - - /influxdb/cloud/reference/flux/stdlib/contrib/ + The `contrib` package contains packages and functions contributed and maintained by members of the Flux and InfluxDB communities. menu: flux_0_x_ref: - name: contrib - parent: Standard library + name: contrib + parent: stdlib + identifier: contrib weight: 11 -flux/v0.x/tags: [contributed, functions, package] --- -The Flux `contrib` package contains packages and functions that are contributed -and maintained by members of the Flux and InfluxDB communities. + + +The `contrib` package contains packages and functions contributed and maintained by members of the Flux and InfluxDB communities. + InfluxData supports user-contributed Flux packages and functions. We also recognize the importance of original contributors reviewing updates to their packages and functions. @@ -27,4 +38,7 @@ original authors on all proposed changes to contributed packages and functions. For information about adding a new Flux package or future plans regarding Flux contributions, see [Contribute Third Party Flux Packages](https://github.com/influxdata/flux/blob/master/stdlib/contrib/README.md). -{{< children >}} + +## Packages + +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/contrib/anaisdg/_index.md b/content/flux/v0.x/stdlib/contrib/anaisdg/_index.md new file mode 100644 index 000000000..b43b8cfde --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/anaisdg/_index.md @@ -0,0 +1,36 @@ +--- +title: anaisdg package +description: > + The `anaisdg` package contains packages and functions contributed by [@anaisdg](https://github.com/anaisdg). +menu: + flux_0_x_ref: + name: anaisdg + parent: contrib + identifier: contrib/anaisdg +weight: 21 +--- + + + +The `anaisdg` package contains packages and functions contributed by [@anaisdg](https://github.com/anaisdg). + + + + +## Packages + +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/contrib/anaisdg/anomalydetection/_index.md b/content/flux/v0.x/stdlib/contrib/anaisdg/anomalydetection/_index.md new file mode 100644 index 000000000..168cc4dd0 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/anaisdg/anomalydetection/_index.md @@ -0,0 +1,41 @@ +--- +title: anomalydetection package +description: > + The `anomalydetection` package detects anomalies in time series data. +menu: + flux_0_x_ref: + name: anomalydetection + parent: contrib/anaisdg + identifier: contrib/anaisdg/anomalydetection +weight: 31 +--- + + + +The `anomalydetection` package detects anomalies in time series data. +Import the `contrib/anaisdg/anomalydetection` package: + +```js +import "contrib/anaisdg/anomalydetection" +``` + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/anaisdg/anomalydetection/mad.md b/content/flux/v0.x/stdlib/contrib/anaisdg/anomalydetection/mad.md new file mode 100644 index 000000000..1e1a5d988 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/anaisdg/anomalydetection/mad.md @@ -0,0 +1,131 @@ +--- +title: anomalydetection.mad() function +description: > + `anomalydetection.mad()` uses the median absolute deviation (MAD) algorithm to detect anomalies in a data set. +menu: + flux_0_x_ref: + name: anomalydetection.mad + parent: contrib/anaisdg/anomalydetection + identifier: contrib/anaisdg/anomalydetection/mad +weight: 301 +--- + + + +`anomalydetection.mad()` uses the median absolute deviation (MAD) algorithm to detect anomalies in a data set. + +Input data requires `_time` and `_value` columns. +Output data is grouped by `_time` and includes the following columns of interest: + +- **\_value**: difference between of the original `_value` from the computed MAD + divided by the median difference. +- **MAD**: median absolute deviation of the group. +- **level**: anomaly indicator set to either `anomaly` or `normal`. + +##### Function type signature + +```js +(<-table: stream[B], ?threshold: A) => stream[{C with level: string, _value_diff_med: D, _value_diff: D, _value: D}] where A: Comparable + Equatable, B: Record, D: Comparable + Divisible + Equatable +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### threshold + +Deviation threshold for anomalies. + + + +### table + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +### Use the MAD algorithm to detect anomalies + +```js +import "contrib/anaisdg/anomalydetection" +import "sampledata" + +sampledata.float() + |> anomalydetection.mad(threshold: 1.0) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag | +| --------- | -------------------- | ------- | ------------ | ---------------- | ------- | ---- | +| 16.330839 | 2021-01-01T00:00:00Z | 1 | 11.015 | 11.015 | anomaly | t1 | +| 16.330839 | 2021-01-01T00:00:00Z | 1 | 11.015 | 11.015 | anomaly | t2 | + +| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag | +| -------- | -------------------- | ------------------ | ------------------ | ---------------- | ------- | ---- | +| 4.410735 | 2021-01-01T00:00:10Z | 0.9999999999999999 | 2.9749999999999996 | 2.975 | normal | t1 | +| 4.410735 | 2021-01-01T00:00:10Z | 1.0000000000000002 | 2.9750000000000005 | 2.975 | anomaly | t2 | + +| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag | +| ------- | -------------------- | ------- | ------------ | ---------------- | ------- | ---- | +| 8.22843 | 2021-01-01T00:00:20Z | 1 | 5.55 | 5.55 | anomaly | t1 | +| 8.22843 | 2021-01-01T00:00:20Z | 1 | 5.55 | 5.55 | anomaly | t2 | + +| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag | +| ------------------ | -------------------- | ------------------ | ------------------ | ------------------ | ------- | ---- | +| 1.6605119999999987 | 2021-01-01T00:00:30Z | 0.9999999999999984 | 1.1199999999999974 | 1.1199999999999992 | normal | t1 | +| 1.6605119999999987 | 2021-01-01T00:00:30Z | 1.0000000000000016 | 1.120000000000001 | 1.1199999999999992 | anomaly | t2 | + +| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag | +| ------------------ | -------------------- | ------- | ------------------ | ------------------ | ------- | ---- | +| 1.0155810000000007 | 2021-01-01T00:00:40Z | 1 | 0.6850000000000005 | 0.6850000000000005 | anomaly | t1 | +| 1.0155810000000007 | 2021-01-01T00:00:40Z | 1 | 0.6850000000000005 | 0.6850000000000005 | anomaly | t2 | + +| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag | +| ------------------ | -------------------- | ------------------ | ------------------ | ------------------ | ------- | ---- | +| 1.9051409999999995 | 2021-01-01T00:00:50Z | 1 | 1.2849999999999997 | 1.2849999999999997 | anomaly | t1 | +| 1.9051409999999995 | 2021-01-01T00:00:50Z | 1.0000000000000002 | 1.285 | 1.2849999999999997 | anomaly | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/anaisdg/statsmodels/_index.md b/content/flux/v0.x/stdlib/contrib/anaisdg/statsmodels/_index.md new file mode 100644 index 000000000..5aff8fdde --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/anaisdg/statsmodels/_index.md @@ -0,0 +1,41 @@ +--- +title: statsmodels package +description: > + The `statsmodels` package provides functions for calculating statistical models. +menu: + flux_0_x_ref: + name: statsmodels + parent: contrib/anaisdg + identifier: contrib/anaisdg/statsmodels +weight: 31 +--- + + + +The `statsmodels` package provides functions for calculating statistical models. +Import the `contrib/anaisdg/statsmodels` package: + +```js +import "contrib/anaisdg/statsmodels" +``` + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/anaisdg/statsmodels/linearregression.md b/content/flux/v0.x/stdlib/contrib/anaisdg/statsmodels/linearregression.md new file mode 100644 index 000000000..410c61907 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/anaisdg/statsmodels/linearregression.md @@ -0,0 +1,89 @@ +--- +title: statsmodels.linearRegression() function +description: > + `statsmodels.linearRegression()` performs a linear regression. +menu: + flux_0_x_ref: + name: statsmodels.linearRegression + parent: contrib/anaisdg/statsmodels + identifier: contrib/anaisdg/statsmodels/linearRegression +weight: 301 +--- + + + +`statsmodels.linearRegression()` performs a linear regression. + +It calculates and returns [*ŷ*](https://en.wikipedia.org/wiki/Hat_operator#Estimated_value) (`y_hat`), +and [residual sum of errors](https://en.wikipedia.org/wiki/Residual_sum_of_squares) (`rse`). +Output data includes the following columns: + +- **N**: Number of points in the calculation. +- **slope**: Slope of the calculated regression. +- **sx**: Sum of x. +- **sxx**: Sum of x squared. +- **sxy**: Sum of x*y. +- **sy**: Sum of y. +- **errors**: Residual sum of squares. + Defined by `(r.y - r.y_hat) ^ 2` in this context +- **x**: An index [1,2,3,4...n], with the assumption that the timestamps are regularly spaced. +- **y**: Field value +- **y\_hat**: Linear regression values + +##### Function type signature + +```js +( + <-tables: stream[A], +) => stream[{ + B with + y_hat: float, + y: float, + x: float, + sy: H, + sxy: G, + sxx: F, + sx: E, + slope: D, + errors: float, + N: C, +}] where A: Record, D: Divisible + Subtractable +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +### Perform a linear regression on a dataset + +```js +import "contrib/anaisdg/statsmodels" +import "sampledata" + +sampledata.float() + |> statsmodels.linearRegression() +``` + diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/_index.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/_index.md index 0cad9140f..b5fb79026 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/_index.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/_index.md @@ -1,26 +1,36 @@ --- -title: Packages contributed by bonitoo-io -list_title: bonitoo-io package +title: bonitoo-io package description: > - The `bonitoo-io` package contains functions and packages contributed by - [@bonitoo-io](https://github.com/bonitoo-io). + The `bonitoo-io` package contains packages and functions contributed by [@bonitoo-io](https://github.com/bonitoo-io). menu: flux_0_x_ref: - name: bonitoo-io + name: bonitoo-io parent: contrib -weight: 101 -cascade: - append: - block: note - content: | - #### Package author and maintainer - **Github:** [@alespour](https://github.com/alespour), [@bonitoo-io](https://github.com/bonitoo-io) - **InfluxDB Slack:** [@Ales Pour](https://influxdata.com/slack) + identifier: contrib/bonitoo-io +weight: 21 --- -The `bonitoo-io` package contains functions and packages contributed by -[@bonitoo-io](https://github.com/bonitoo-io). + + +The `bonitoo-io` package contains packages and functions contributed by [@bonitoo-io](https://github.com/bonitoo-io). + + + ## Packages -{{< children >}} \ No newline at end of file +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/_index.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/_index.md index fa217722d..6611eb33c 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/_index.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/_index.md @@ -1,35 +1,44 @@ --- -title: Flux alerta package -list_title: alerta package +title: alerta package description: > - The Flux `alerta` package provides functions that send alerts to - [Alerta](https://alerta.io/). + The `alerta` package provides functions that send alerts to [Alerta](https://alerta.io/). menu: flux_0_x_ref: - name: alerta - parent: bonitoo-io -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/alerta/ - - /influxdb/cloud/reference/flux/stdlib/contrib/alerta/ -flux/v0.x/tags: [functions, alerta, package] -introduced: 0.115.0 + name: alerta + parent: contrib/bonitoo-io + identifier: contrib/bonitoo-io/alerta +weight: 31 cascade: - append: - block: note - content: | - #### Package author and maintainer - **Github:** [@alespour](https://github.com/alespour), [@bonitoo-io](https://github.com/bonitoo-io) - **InfluxDB Slack:** [@Ales Pour](https://influxdata.com/slack) + + introduced: 0.115.0 --- -The Flux `alerta` package provides functions that send alerts to -[Alerta](https://alerta.io/). + + +The `alerta` package provides functions that send alerts to [Alerta](https://alerta.io/). Import the `contrib/bonitoo-io/alerta` package: ```js import "contrib/bonitoo-io/alerta" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/alert.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/alert.md index 45132337f..c6f524702 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/alert.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/alert.md @@ -1,114 +1,157 @@ --- title: alerta.alert() function description: > - The `alerta.alert()` function sends an alert to Alerta. + `alerta.alert()` sends an alert to [Alerta](https://alerta.io/). menu: flux_0_x_ref: name: alerta.alert - parent: alerta -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/alerta/alert/ - - /influxdb/cloud/reference/flux/stdlib/contrib/alerta/alert/ -introduced: 0.115.0 + parent: contrib/bonitoo-io/alerta + identifier: contrib/bonitoo-io/alerta/alert +weight: 301 +flux/v0.x/tags: [single notification] --- -The `alerta.alert()` function sends an alert to [Alerta](https://www.alerta.io/). + + +`alerta.alert()` sends an alert to [Alerta](https://alerta.io/). + + + +##### Function type signature ```js -import "contrib/bonitoo-io/alerta" - -alerta.alert( - url: "https://alerta.io:8080/alert", - apiKey: "0Xx00xxXx00Xxx0x0X", - resource: "example-resource", - event: "Example event", - environment: "", - severity: "critical", - service: [], - group: "", - value: "", - text: "", - tags: [], - attributes: {}, - origin: "InfluxDB", - type: "", - timestamp: now(), -) +( + apiKey: string, + attributes: A, + event: B, + resource: C, + severity: D, + url: string, + ?environment: E, + ?group: F, + ?origin: G, + ?service: H, + ?tags: I, + ?text: J, + ?timestamp: t10, + ?type: t11, + ?value: t12, +) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url ({{< req >}}) -Alerta URL. +(Required) Alerta URL. -### apiKey {data-type="string"} + + +### apiKey ({{< req >}}) -Alerta API key. +(Required) Alerta API key. -### resource {data-type="string"} + + +### resource ({{< req >}}) -Resource associated with the alert. +(Required) Resource associated with the alert. -### event {data-type="string"} + + +### event ({{< req >}}) -Event name. +(Required) Event name. -### environment {data-type="string"} -Alert environment. -Default is `""`. -**Valid values:** -- `""` -- `"Production"` -- `"Development"` +### environment -### severity {data-type="string"} +Alerta environment. Valid values: "Production", "Development" or empty string (default). + + + +### severity ({{< req >}}) -Event severity. -See [Alerta severities](https://docs.alerta.io/en/latest/api/alert.html#alert-severities). +(Required) Event severity. See [Alerta severities](https://docs.alerta.io/en/latest/api/alert.html#alert-severities). -### service {data-type="array of strings"} -List of affected services. -Default is `[]`. -### group {data-type="string"} -Alerta event group. -Default is `""`. -### value {data-type="string"} -Event value. -Default is `""`. +### service -### text {data-type="string"} -Alert text description. -Default is `""`. +List of affected services. Default is `[]`. -### tags {data-type="array of strings"} -List of event tags. -Default is `[]`. -### attributes {data-type="record"} + +### group + +Alerta event group. Default is `""`. + + + +### value + +Event value. Default is `""`. + + + +### text + +Alerta text description. Default is `""`. + + + +### tags + +List of event tags. Default is `[]`. + + + +### attributes ({{< req >}}) -Alert attributes. +(Required) Alert attributes. + + + +### origin + +monitoring component. + + + +### type + +Event type. Default is `""`. + + + +### timestamp + +time alert was generated. Default is `now()`. -### origin {data-type="string"} -Alert origin. -Default is `"InfluxDB"`. -### type {data-type="string"} -Event type. -Default is `""`. -### timestamp {data-type="time"} -time alert was generated. -Default is `now()`. ## Examples -##### Send the last reported value and status to Alerta +### Send the last reported value and status to Alerta + ```js import "contrib/bonitoo-io/alerta" import "influxdata/influxdb/secrets" @@ -142,3 +185,4 @@ alerta.alert( timestamp: now(), ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/endpoint.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/endpoint.md index 01ec85e8e..836d7f4ae 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/endpoint.md @@ -1,116 +1,89 @@ --- title: alerta.endpoint() function description: > - The `alerta.endpoint()` function sends alerts to Alerta using data from input rows. + `alerta.endpoint()` sends alerts to Alerta using data from input rows. menu: flux_0_x_ref: name: alerta.endpoint - parent: alerta -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/alerta/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/alerta/endpoint/ -flux/v0.x/tags: [notification endpoints] -introduced: 0.115.0 + parent: contrib/bonitoo-io/alerta + identifier: contrib/bonitoo-io/alerta/endpoint +weight: 301 --- -The `alerta.endpoint()` function sends alerts to [Alerta](https://alerta.io/) -using data from input rows. + + +`alerta.endpoint()` sends alerts to Alerta using data from input rows. + + + +##### Function type signature ```js -import "contrib/bonitoo-io/alerta" - -alerta.endpoint( - url: "https://alerta.io:8080/alert", - apiKey: "0Xx00xxXx00Xxx0x0X", - environment: "", - origin: "InfluxDB" -) +( + apiKey: string, + url: string, + ?environment: A, + ?origin: B, +) => ( + mapFn: ( + r: C, + ) => { + D with + value: t14, + type: t13, + timestamp: t12, + text: t11, + tags: t10, + severity: J, + service: I, + resource: H, + group: G, + event: F, + attributes: E, + }, +) => (<-tables: stream[C]) => stream[{C with _sent: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url ({{< req >}}) -Alerta URL. +(Required) Alerta URL. -### apiKey {data-type="string"} + + +### apiKey ({{< req >}}) -Alerta API key. +(Required) Alerta API key. -### environment {data-type="string"} -Alert environment. -Default is `""`. -**Valid values:** -- `""` -- `"Production"` -- `"Development"` +### environment -### origin {data-type="string"} -Alert origin. -Default is `"InfluxDB"`. +Alert environment. Default is `""`. +Valid values: "Production", "Development" or empty string (default). -## Usage -`alerta.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. -### mapFn {data-type="function"} -A function that builds the object used to generate the POST request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns an object that must include the -following fields: +### origin -- `resource` -- `event` -- `severity` -- `service` -- `group` -- `value` -- `text` -- `tags` -- `attributes` -- `type` -- `timestamp` +Alert origin. Default is `"InfluxDB"`. -_For more information, see [`alerta.alert()` parameters](/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/alert/#parameters)._ -## Examples -##### Send critical alerts to Alerta -```js -import "contrib/bonitoo-io/alerta" -import "influxdata/influxdb/secrets" - -apiKey = secrets.get(key: "ALERTA_API_KEY") -endpoint = - alerta.endpoint(url: "https://alerta.io:8080/alert", apiKey: apiKey, environment: "Production", origin: "InfluxDB") - -crit_events = - from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") - -crit_events - |> endpoint( - mapFn: (r) => { - return {r with - resource: "example-resource", - event: "example-event", - severity: "critical", - service: r.service, - group: "example-group", - value: r.status, - text: "Status is critical.", - tags: ["ex1", "ex2"], - attributes: {}, - type: "exampleAlertType", - timestamp: now(), - } - }, - )() -``` diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/_index.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/_index.md index 7ac141bcc..9294ba566 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/_index.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/_index.md @@ -1,31 +1,46 @@ --- -title: Flux hex package -list_title: hex package +title: hex package description: > - The Flux `hex` package provides functions that convert hexadecimal strings into Flux data types. - Import the `contrib/bonitoo-io/hex` package. + The `hex` package provides functions that perform hexadecimal conversion + of `int`, `uint` or `bytes` values to and from `string` values. menu: flux_0_x_ref: - name: hex - parent: bonitoo-io -weight: 202 -flux/v0.x/tags: [functions, hex, package] + name: hex + parent: contrib/bonitoo-io + identifier: contrib/bonitoo-io/hex +weight: 31 cascade: + introduced: 0.131.0 - append: - block: note - content: | - #### Package author and maintainer - **Github:** [@bonitoo-io](https://github.com/bonitoo-io), [@sranka](https://github.com/sranka) - **InfluxDB Slack:** [@sranka](https://influxdata.com/slack) --- -The Flux `hex` package provides functions that convert hexadecimal strings into Flux data types. -Import the `contrib/bonitoo-io/hex` package. + + +The `hex` package provides functions that perform hexadecimal conversion +of `int`, `uint` or `bytes` values to and from `string` values. +Import the `contrib/bonitoo-io/hex` package: ```js import "contrib/bonitoo-io/hex" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/bytes.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/bytes.md index b54c37ae8..caa7df9af 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/bytes.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/bytes.md @@ -5,35 +5,57 @@ description: > menu: flux_0_x_ref: name: hex.bytes - parent: hex -weight: 302 -related: - - /flux/v0.x/data-types/basic/bytes/ -flux/v0.x/tags: [type-conversions] + parent: contrib/bonitoo-io/hex + identifier: contrib/bonitoo-io/hex/bytes +weight: 301 + --- -`hex.bytes()` decodes a hexadecimal string and converts the decoded value to bytes. + + +`hex.bytes()` converts a hexadecimal string to bytes. + + + +##### Function type signature ```js -import "contrib/bonitoo-io/hex" - -hex.bytes(v: "6869") - -// Returns [104 105] (the bytes representation of "hi") +(v: string) => bytes ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -Value to convert. +### v +({{< req >}}) +String to convert. + + + ## Examples -#### Convert a hexadecimal string to bytes +### Convert a hexadecimal string into bytes + ```js import "contrib/bonitoo-io/hex" -hex.bytes(v: "FF5733") +hex.bytes(v: "FF5733")// Returns [255 87 51] (bytes) + +``` -// Returns [255 87 51] (bytes) -``` \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/int.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/int.md index 0e82f9a03..0f6741816 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/int.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/int.md @@ -1,109 +1,61 @@ --- title: hex.int() function description: > - `hex.int()` converts a hexadecimal string representation of a number to an integer. + `hex.int()` converts a hexadecimal string to an integer. menu: flux_0_x_ref: name: hex.int - parent: hex -weight: 302 -related: - - /flux/v0.x/data-types/basic/int/ -flux/v0.x/tags: [type-conversions] + parent: contrib/bonitoo-io/hex + identifier: contrib/bonitoo-io/hex/int +weight: 301 + --- -`hex.int()` converts a hexadecimal string representation of a number to an integer. + + +`hex.int()` converts a hexadecimal string to an integer. + + + +##### Function type signature ```js -import "contrib/bonitoo-io/hex" - -hex.int(v: "4d2") - -// Returns 1234 +(v: string) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -Value to convert. +### v +({{< req >}}) +String to convert. + + + ## Examples -- [Convert a hexadecimal string to an integer](#convert-a-hexadecimal-string-to-an-integer) -- [Convert all hexadecimal string values in a column to integers](#convert-all-hexadecimal-string-values-in-a-column-to-integers) +### Convert hexadecimal string to integer -#### Convert a hexadecimal string to an integer ```js import "contrib/bonitoo-io/hex" -hex.int(v: "-d431") +hex.int(v: "4d2")// Returns 1234 -// Returns -54321 ``` -#### Convert all hexadecimal string values in a column to integers - -1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows. -2. Use `hex.int()` to update the value of a column. - -_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._ - -```js -import "sampledata" - -data = - sampledata.int() - |> map(fn: (r) => ({r with _value: hex.string(v: r._value)})) - -data - |> map(fn: (r) => ({r with _value: hex.int(v: r._value)})) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | tag | _value _(string)_ | -| :------------------- | :-- | -------------------------------------------------: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | a | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 11 | -| 2021-01-01T00:00:40Z | t1 | f | -| 2021-01-01T00:00:50Z | t1 | 4 | - -| _time | tag | _value _(string)_ | -| :------------------- | :-- | -------------------------------------------------: | -| 2021-01-01T00:00:00Z | t2 | 13 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 13 | -| 2021-01-01T00:00:40Z | t2 | d | -| 2021-01-01T00:00:50Z | t2 | 1 | - -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| tag | _time | _value _(int)_ | -| :-- | :------------------- | ----------------------------------------------: | -| t1 | 2021-01-01T00:00:00Z | -2 | -| t1 | 2021-01-01T00:00:10Z | 10 | -| t1 | 2021-01-01T00:00:20Z | 7 | -| t1 | 2021-01-01T00:00:30Z | 17 | -| t1 | 2021-01-01T00:00:40Z | 15 | -| t1 | 2021-01-01T00:00:50Z | 4 | - -| tag | _time | _value _(int)_ | -| :-- | :------------------- | ----------------------------------------------: | -| t2 | 2021-01-01T00:00:00Z | 19 | -| t2 | 2021-01-01T00:00:10Z | 4 | -| t2 | 2021-01-01T00:00:20Z | -3 | -| t2 | 2021-01-01T00:00:30Z | 19 | -| t2 | 2021-01-01T00:00:40Z | 13 | -| t2 | 2021-01-01T00:00:50Z | 1 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/string.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/string.md index 5a265d8c2..bfab1547e 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/string.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/string.md @@ -1,36 +1,57 @@ --- title: hex.string() function description: > - `hex.string()` converts a [Flux basic type](/flux/v0.x/data-types/basic/) to a hexadecimal string. + `hex.string()` converts a Flux basic type to a hexadecimal string. menu: flux_0_x_ref: name: hex.string - parent: hex -weight: 302 -related: - - /flux/v0.x/stdlib/universe/string/ -flux/v0.x/tags: [type-conversions] + parent: contrib/bonitoo-io/hex + identifier: contrib/bonitoo-io/hex/string +weight: 301 + --- -`hex.string()` converts a [Flux basic type](/flux/v0.x/data-types/basic/) to a hexadecimal string. -The function is similar to [string()](/flux/v0.x/stdlib/universe/string/), -but encodes **int, uint, and bytes types** to hexadecimal lowercase characters. + + +`hex.string()` converts a Flux basic type to a hexadecimal string. + +The function is similar to `string()`, but encodes int, uint, and bytes +types to hexadecimal lowercase characters. + +##### Function type signature ```js -import "contrib/bonitoo-io/hex" - -hex.string(v: 1234) - -// Returns 4d2 +(v: A) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="bool, int, uint, float, duration, time, bytes"} +### v +({{< req >}}) Value to convert. + + + ## Examples +- [Convert integer to hexadecimal string](#convert-integer-to-hexadecimal-string) - [Convert a boolean to a hexadecimal string value](#convert-a-boolean-to-a-hexadecimal-string-value) - [Convert a duration to a hexadecimal string value](#convert-a-duration-to-a-hexadecimal-string-value) - [Convert a time to a hexadecimal string value](#convert-a-time-to-a-hexadecimal-string-value) @@ -40,75 +61,91 @@ Value to convert. - [Convert bytes to a hexadecimal string value](#convert-bytes-to-a-hexadecimal-string-value) - [Convert all values in a column to hexadecimal string values](#convert-all-values-in-a-column-to-hexadecimal-string-values) -#### Convert a boolean to a hexadecimal string value +### Convert integer to hexadecimal string + ```js import "contrib/bonitoo-io/hex" -hex.string(v: true) +hex.string(v: 1234)// Returns 4d2 -// Returns "true" ``` -#### Convert a duration to a hexadecimal string value + +### Convert a boolean to a hexadecimal string value + ```js import "contrib/bonitoo-io/hex" -hex.string(v: 1m) +hex.string(v: true)// Returns "true" -// Returns "1m" ``` -#### Convert a time to a hexadecimal string value + +### Convert a duration to a hexadecimal string value + ```js import "contrib/bonitoo-io/hex" -hex.string(v: 2021-01-01T00:00:00Z) +hex.string(v: 1m)// Returns "1m" -// Returns "2021-01-01T00:00:00Z" ``` -#### Convert an integer to a hexadecimal string value + +### Convert a time to a hexadecimal string value + ```js import "contrib/bonitoo-io/hex" -hex.string(v: 1234) +hex.string(v: 2021-01-01T00:00:00Z)// Returns "2021-01-01T00:00:00Z" -// Returns "4d2" ``` -#### Convert a uinteger to a hexadecimal string value + +### Convert an integer to a hexadecimal string value + ```js import "contrib/bonitoo-io/hex" -hex.string(v: uint(v: 5678)) +hex.string(v: 1234)// Returns "4d2" -// Returns "162e" ``` -#### Convert a float to a hexadecimal string value + +### Convert a uinteger to a hexadecimal string value + ```js import "contrib/bonitoo-io/hex" -hex.string(v: 10.12) +hex.string(v: uint(v: 5678))// Returns "162e" -// Returns "10.12" ``` -#### Convert bytes to a hexadecimal string value + +### Convert a float to a hexadecimal string value + ```js import "contrib/bonitoo-io/hex" -hex.string(v: bytes(v: "Hello world!")) +hex.string(v: 10.12)// Returns "10.12" -// Returns "48656c6c6f20776f726c6421" ``` -#### Convert all values in a column to hexadecimal string values -1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows. -2. Use `hex.string()` to update the value of a column. +### Convert bytes to a hexadecimal string value -_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._ +```js +import "contrib/bonitoo-io/hex" + +hex.string(v: bytes(v: "Hello world!"))// Returns "48656c6c6f20776f726c6421" + +``` + + +### Convert all values in a column to hexadecimal string values + +Use `map()` to iterate over and update all input rows. +Use `hex.string()` to update the value of a column. +The following example uses data provided by the sampledata package. ```js import "sampledata" @@ -123,49 +160,48 @@ data ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -| tag | _time | _value _(int)_ | -| :-- | :------------------- | -------------------------------------------: | -| t1 | 2021-01-01T00:00:00Z | -2000 | -| t1 | 2021-01-01T00:00:10Z | 10000 | -| t1 | 2021-01-01T00:00:20Z | 7000 | -| t1 | 2021-01-01T00:00:30Z | 17000 | -| t1 | 2021-01-01T00:00:40Z | 15000 | -| t1 | 2021-01-01T00:00:50Z | 4000 | +{{% expand "View example input and ouput" %}} -| tag | _time | _value _(int)_ | -| :-- | :------------------- | -------------------------------------------: | -| t2 | 2021-01-01T00:00:00Z | 19000 | -| t2 | 2021-01-01T00:00:10Z | 4000 | -| t2 | 2021-01-01T00:00:20Z | -3000 | -| t2 | 2021-01-01T00:00:30Z | 19000 | -| t2 | 2021-01-01T00:00:40Z | 13000 | -| t2 | 2021-01-01T00:00:50Z | 1000 | +#### Input data -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | tag | _value _(string)_ | -| :------------------- | :-- | ----------------------------------------------: | -| 2021-01-01T00:00:00Z | t1 | -7d0 | -| 2021-01-01T00:00:10Z | t1 | 2710 | -| 2021-01-01T00:00:20Z | t1 | 1b58 | -| 2021-01-01T00:00:30Z | t1 | 4268 | -| 2021-01-01T00:00:40Z | t1 | 3a98 | -| 2021-01-01T00:00:50Z | t1 | fa0 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2000 | t1 | +| 2021-01-01T00:00:10Z | 10000 | t1 | +| 2021-01-01T00:00:20Z | 7000 | t1 | +| 2021-01-01T00:00:30Z | 17000 | t1 | +| 2021-01-01T00:00:40Z | 15000 | t1 | +| 2021-01-01T00:00:50Z | 4000 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19000 | t2 | +| 2021-01-01T00:00:10Z | 4000 | t2 | +| 2021-01-01T00:00:20Z | -3000 | t2 | +| 2021-01-01T00:00:30Z | 19000 | t2 | +| 2021-01-01T00:00:40Z | 13000 | t2 | +| 2021-01-01T00:00:50Z | 1000 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | | t2 | +| 2021-01-01T00:00:20Z | | t2 | +| 2021-01-01T00:00:30Z | | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | | t2 | -| _time | tag | _value _(string)_ | -| :------------------- | :-- | ----------------------------------------------: | -| 2021-01-01T00:00:00Z | t2 | 4a38 | -| 2021-01-01T00:00:10Z | t2 | fa0 | -| 2021-01-01T00:00:20Z | t2 | -bb8 | -| 2021-01-01T00:00:30Z | t2 | 4a38 | -| 2021-01-01T00:00:40Z | t2 | 32c8 | -| 2021-01-01T00:00:50Z | t2 | 3e8 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/uint.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/uint.md index 135f44530..d9c033853 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/uint.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/hex/uint.md @@ -1,112 +1,61 @@ --- title: hex.uint() function description: > - `hex.uint()` converts a hexadecimal string representation of a number to an unsigned integer. + `hex.uint()` converts a hexadecimal string to an unsigned integer. menu: flux_0_x_ref: name: hex.uint - parent: hex -weight: 302 -related: - - /flux/v0.x/data-types/basic/uint/ -flux/v0.x/tags: [type-conversions] + parent: contrib/bonitoo-io/hex + identifier: contrib/bonitoo-io/hex/uint +weight: 301 + --- -`hex.uint()` converts a hexadecimal string representation of a number to an unsigned integer. + + +`hex.uint()` converts a hexadecimal string to an unsigned integer. + + + +##### Function type signature ```js -import "contrib/bonitoo-io/hex" - -hex.uint(v: "4d2") - -// Returns 1234 +(v: string) => uint ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -Value to convert. +### v +({{< req >}}) +String to convert. + + + ## Examples -- [Convert a hexadecimal string to an unsigned integer](#convert-a-hexadecimal-string-to-an-unsigned-integer) -- [Convert all hexadecimal string values in a column to unsigned integers](#convert-all-hexadecimal-string-values-in-a-column-to-unsigned-integers) - -#### Convert a hexadecimal string to an unsigned integer -```js -import "contrib/bonitoo-io/hex" - -hex.uint(v: "-d431") - -// Returns -54321 -``` - -#### Convert all hexadecimal string values in a column to unsigned integers - -1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows. -2. Use `hex.uint()` to update the value of a column. - -_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._ +### Convert a hexadecimal string to an unsigned integer ```js import "contrib/bonitoo-io/hex" -import "sampledata" -data = - sampledata.uint() - |> map(fn: (r) => ({r with _value: hex.string(v: r._value)})) +hex.uint(v: "4d2")// Returns 1234 -data - |> map(fn: (r) => ({r with _value: hex.uint(v: r._value)})) ``` -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | tag | _value _(string)_ | -| :------------------- | :-- | -------------------------------------------------: | -| 2021-01-01T00:00:00Z | t1 | fffffffffffffffe | -| 2021-01-01T00:00:10Z | t1 | a | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 11 | -| 2021-01-01T00:00:40Z | t1 | f | -| 2021-01-01T00:00:50Z | t1 | 4 | - -| _time | tag | _value _(string)_ | -| :------------------- | :-- | -------------------------------------------------: | -| 2021-01-01T00:00:00Z | t2 | 13 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | fffffffffffffffd | -| 2021-01-01T00:00:30Z | t2 | 13 | -| 2021-01-01T00:00:40Z | t2 | d | -| 2021-01-01T00:00:50Z | t2 | 1 | - -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| tag | _time | _value _(uint)_ | -| :-- | :------------------- | -----------------------------------------------: | -| t1 | 2021-01-01T00:00:00Z | 18446744073709551614 | -| t1 | 2021-01-01T00:00:10Z | 10 | -| t1 | 2021-01-01T00:00:20Z | 7 | -| t1 | 2021-01-01T00:00:30Z | 17 | -| t1 | 2021-01-01T00:00:40Z | 15 | -| t1 | 2021-01-01T00:00:50Z | 4 | - -| tag | _time | _value _(uint)_ | -| :-- | :------------------- | -----------------------------------------------: | -| t2 | 2021-01-01T00:00:00Z | 19 | -| t2 | 2021-01-01T00:00:10Z | 4 | -| t2 | 2021-01-01T00:00:20Z | 18446744073709551613 | -| t2 | 2021-01-01T00:00:30Z | 19 | -| t2 | 2021-01-01T00:00:40Z | 13 | -| t2 | 2021-01-01T00:00:50Z | 1 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} - - diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/_index.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/_index.md index 856077776..e15d59ad7 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/_index.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/_index.md @@ -1,28 +1,44 @@ --- -title: Flux servicenow package -list_title: servicenow package +title: servicenow package description: > - The Flux `servicenow` package provides functions that send events to - [ServiceNow](https://servicenow.com). + The `servicenow` package provides functions for sending events to [ServiceNow](https://www.servicenow.com/). menu: flux_0_x_ref: - name: servicenow - parent: bonitoo-io -weight: 202 -flux/v0.x/tags: [functions, servicenow, package] + name: servicenow + parent: contrib/bonitoo-io + identifier: contrib/bonitoo-io/servicenow +weight: 31 cascade: + introduced: 0.136.0 --- -The Flux `servicenow` package provides functions that send events to -[ServiceNow](https://servicenow.com). + + +The `servicenow` package provides functions for sending events to [ServiceNow](https://www.servicenow.com/). Import the `contrib/bonitoo-io/servicenow` package: ```js import "contrib/bonitoo-io/servicenow" ``` + + + ## Functions {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/endpoint.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/endpoint.md index 46ca80942..4193b36b2 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/endpoint.md @@ -1,98 +1,84 @@ --- title: servicenow.endpoint() function description: > - The `servicenow.endpoint()` function sends events to [ServiceNow](https://servicenow.com) - using data from input rows. + `servicenow.endpoint()` sends events to [ServiceNow](https://servicenow.com/) using data from input rows. menu: flux_0_x_ref: name: servicenow.endpoint - parent: servicenow -weight: 202 -flux/v0.x/tags: [notification endpoints] + parent: contrib/bonitoo-io/servicenow + identifier: contrib/bonitoo-io/servicenow/endpoint +weight: 301 --- -The `servicenow.endpoint()` function sends events to [ServiceNow](https://servicenow.com) -using data from input rows. + + +`servicenow.endpoint()` sends events to [ServiceNow](https://servicenow.com/) using data from input rows. + + + +##### Function type signature ```js -import "contrib/bonitoo-io/servicenow" - -servicenow.endpoint( - url: "https://example-tenant.service-now.com/api/global/em/jsonv2", - username: "example-username", - password: "example-password" -) +( + password: string, + url: string, + username: string, + ?source: A, +) => ( + mapFn: ( + r: B, + ) => { + C with + severity: J, + resource: I, + node: H, + metricType: G, + metricName: F, + messageKey: E, + description: D, + }, +) => (<-tables: stream[B]) => stream[{B with _sent: string}] where J: Equatable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url ({{< req >}}) ServiceNow web service URL. -### username {data-type=" string"} + + +### username ({{< req >}}) ServiceNow username to use for HTTP BASIC authentication. -### password {data-type="string"} + + +### password ({{< req >}}) ServiceNow password to use for HTTP BASIC authentication. -## Usage -`servicenow.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. -### mapFn {data-type="function"} -A function that builds the object used to generate the ServiceNow API request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns an object that must include the -following properties: +### source -- `description` -- `severity` -- `source` -- `node` -- `metricType` -- `resource` -- `metricName` -- `messageKey` -- `additionalInfo` +Source name. Default is `"Flux"`. -_For more information, see [`servicenow.event()` parameters](/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/event/#parameters)._ -## Examples -##### Send critical events to ServiceNow -```js -import "contrib/bonitoo-io/servicenow" -import "influxdata/influxdb/secrets" - -username = secrets.get(key: "SERVICENOW_USERNAME") -password = secrets.get(key: "SERVICENOW_PASSWORD") - -endpoint = - servicenow.endpoint( - url: "https://example-tenant.service-now.com/api/global/em/jsonv2", - username: username, - password: password, - ) - -crit_events = - from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") - -crit_events - |> endpoint( - mapFn: (r) => - ({ - node: r.host, - metricType: r._measurement, - resource: r.instance, - metricName: r._field, - severity: "critical", - additionalInfo: {"devId": r.dev_id}, - }), - )() -``` diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/event.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/event.md index 60cd242c8..b62204d2f 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/event.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/event.md @@ -1,62 +1,89 @@ --- title: servicenow.event() function description: > - The `servicenow.event()` function sends an event to ServiceNow. + `servicenow.event()` sends an event to [ServiceNow](https://servicenow.com/). menu: flux_0_x_ref: name: servicenow.event - parent: servicenow -weight: 202 + parent: contrib/bonitoo-io/servicenow + identifier: contrib/bonitoo-io/servicenow/event +weight: 301 flux/v0.x/tags: [single notification] --- -The `servicenow.event()` function sends an event to [ServiceNow](https://servicenow.com). + + +`servicenow.event()` sends an event to [ServiceNow](https://servicenow.com/). + +ServiceNow Event API fields are described in +[ServiceNow Create Event documentation](https://docs.servicenow.com/bundle/paris-it-operations-management/page/product/event-management/task/t_EMCreateEventManually.html). + +##### Function type signature ```js -import "contrib/bonitoo-io/servicenow" - -servicenow.event( - url: "https://example-tenant.service-now.com/api/global/em/jsonv2", - username: "example-username", - password: "example-password", - description: "Example event description.", - severity: "minor", - source: "", - node: "", - metricType: "", - resource: "", - metricName: "", - messageKey: "", - additionalInfo: {}, -) +( + description: A, + password: string, + severity: B, + url: string, + username: string, + ?additionalInfo: C, + ?messageKey: D, + ?metricName: E, + ?metricType: F, + ?node: G, + ?resource: H, + ?source: I, +) => int where B: Equatable, C: Equatable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -_ServiceNow Event API fields are described in [ServiceNow Create Event documentation](https://docs.servicenow.com/bundle/paris-it-operations-management/page/product/event-management/task/t_EMCreateEventManually.html)._ - -### url {data-type="string"} +### url ({{< req >}}) ServiceNow web service URL. -### username {data-type=" string"} + + +### username ({{< req >}}) ServiceNow username to use for HTTP BASIC authentication. -### password {data-type="string"} + + +### password ({{< req >}}) ServiceNow password to use for HTTP BASIC authentication. -### description {data-type="string"} + + +### description ({{< req >}}) Event description. -### severity {data-type="string"} + + +### severity ({{< req >}}) Severity of the event. -**Supported values:** - +Supported values: - `critical` - `major` - `minor` @@ -64,37 +91,59 @@ Severity of the event. - `info` - `clear` -### source {data-type="string"} -Source name. -Default is `"Flux"`. +### source + +Source name. Default is `"Flux"`. + + + +### node -### node {data-type="string"} Node name or IP address related to the event. Default is an empty string (`""`). -### metricType {data-type="string"} + + +### metricType + Metric type related to the event (for example, `CPU`). Default is an empty string (`""`). -### resource {data-type="string"} + + +### resource + Resource related to the event (for example, `CPU-1`). Default is an empty string (`""`). -### metricName {data-type="string"} + + +### metricName + Metric name related to the event (for example, `usage_idle`). Default is an empty string (`""`). -### messageKey {data-type="string"} + + +### messageKey + Unique identifier of the event (for example, the InfluxDB alert ID). Default is an empty string (`""`). If an empty string, ServiceNow generates a value. -### additionalInfo {data-type="record"} + + +### additionalInfo + Additional information to include with the event. + + + ## Examples -##### Send the last reported value and incident type to ServiceNow +### Send the last reported value and incident type to ServiceNow + ```js import "contrib/bonitoo-io/servicenow" import "influxdata/influxdb/secrets" @@ -127,3 +176,4 @@ servicenow.event( additionalInfo: {"devId": r.dev_id}, ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/_index.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/_index.md index a0d433154..c0a07f4e4 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/_index.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/_index.md @@ -1,34 +1,46 @@ --- -title: Flux tickscript package -list_title: tickscript package +title: tickscript package description: > - The Flux `tickscript` package provides functions to help migrate Kapacitor TICKscripts to Flux tasks. - Import the `contrib/bonitoo-io/tickscript` package. + The `tickscript` package provides functions to help migrate + Kapacitor [TICKscripts](https://docs.influxdata.com/kapacitor/latest/tick/) to Flux tasks. menu: flux_0_x_ref: - name: tickscript - parent: bonitoo-io -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/ - - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/ -flux/v0.x/tags: [functions, tickscript, package] + name: tickscript + parent: contrib/bonitoo-io + identifier: contrib/bonitoo-io/tickscript +weight: 31 cascade: + introduced: 0.111.0 - append: - block: note - content: | - #### Package author and maintainer - **Github:** [@bonitoo-io](https://github.com/bonitoo-io), [@alespour](https://github.com/alespour) - **InfluxDB Slack:** [@Ales Pour](https://influxdata.com/slack) --- -The Flux `tickscript` package provides functions to help migrate Kapacitor TICKscripts to Flux tasks. + + +The `tickscript` package provides functions to help migrate +Kapacitor [TICKscripts](https://docs.influxdata.com/kapacitor/latest/tick/) to Flux tasks. Import the `contrib/bonitoo-io/tickscript` package: ```js import "contrib/bonitoo-io/tickscript" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/alert.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/alert.md index 370afa650..498a3850d 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/alert.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/alert.md @@ -1,97 +1,158 @@ --- title: tickscript.alert() function description: > - The `tickscript.alert()` function identifies events of varying severity levels - and writes them to the `statuses` measurement in the InfluxDB - `_monitoring` system bucket. + `tickscript.alert()` identifies events of varying severity levels + and writes them to the `statuses` measurement in the InfluxDB `_monitoring` + system bucket. menu: flux_0_x_ref: name: tickscript.alert - parent: tickscript -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/alert/ - - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/alert/ -related: - - /{{< latest "kapacitor" >}}/nodes/alert_node/, Kapacitor AlertNode -flux/v0.x/tags: [transformations] -introduced: 0.111.0 + parent: contrib/bonitoo-io/tickscript + identifier: contrib/bonitoo-io/tickscript/alert +weight: 301 +flux/v0.x/tags: [transformations, outputs] --- -The `tickscript.alert()` function identifies events of varying severity levels -and writes them to the `statuses` measurement in the InfluxDB -[`_monitoring` system bucket](/{{< latest "influxdb" >}}/reference/internals/system-buckets/). + + +`tickscript.alert()` identifies events of varying severity levels +and writes them to the `statuses` measurement in the InfluxDB `_monitoring` +system bucket. + +This function is comparable to +TICKscript [`alert()`](https://docs.influxdata.com/kapacitor/v1.6/nodes/alert_node/). + +##### Function type signature ```js -import "contrib/bonitoo-io/tickscript" - -tickscript.alert( - check: {id: "000000000000", name: "Example check name", type: "threshold", tags: {}}, - id: (r) => "000000000000", - details: (r) => "", - message: (r) => "Threshold Check: ${r._check_name} is: ${r._level}", - crit: (r) => false, - warn: (r) => false, - info: (r) => false, - ok: (r) => true, - topic: "", -) +( + <-tables: stream[t12], + check: {A with tags: E, _type: D, _check_name: C, _check_id: B}, + ?crit: (r: {F with _time: H, _measurement: G}) => bool, + ?details: (r: {I with id: J, _check_name: C, _check_id: B}) => t10, + ?id: (r: {I with _check_name: C, _check_id: B}) => J, + ?info: (r: {F with _time: H, _measurement: G}) => bool, + ?message: ( + r: { + F with + _type: D, + _time: H, + _time: time, + _source_timestamp: int, + _source_measurement: G, + _measurement: G, + _measurement: string, + _level: string, + _check_name: C, + _check_id: B, + }, + ) => t11, + ?ok: (r: {F with _time: H, _measurement: G}) => bool, + ?topic: string, + ?warn: (r: {F with _time: H, _measurement: G}) => bool, +) => stream[{ + F with + _type: D, + _time: H, + _time: time, + _source_timestamp: int, + _source_measurement: G, + _message: t11, + _measurement: G, + _measurement: string, + _level: string, + _check_name: C, + _check_id: B, +}] where E: Record, I: Record, t12: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### check {data-type="record"} +### check ({{< req >}}) InfluxDB check data. -_See [`tickscript.defineCheck()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/definecheck/)._ +See `tickscript.defineCheck()`. -### id {data-type="function"} -Function that returns the InfluxDB check ID provided by the [`check` record](#check). + + +### id + +Function that returns the InfluxDB check ID provided by the check record. Default is `(r) => "${r._check_id}"`. -### details {data-type="function"} + + +### details + Function to return the InfluxDB check details using data from input rows. Default is `(r) => ""`. -### message {data-type="function"} + + +### message + Function to return the InfluxDB check message using data from input rows. Default is `(r) => "Threshold Check: ${r._check_name} is: ${r._level}"`. -### crit {data-type="function"} -Predicate function to determine `crit` status. -Default is `(r) => false`. -### warn {data-type="function"} -Predicate function to determine `warn` status. -Default is `(r) => false`. -### info {data-type="function"} -Predicate function to determine `info` status. -Default is `(r) => false`. +### crit + +Predicate function to determine `crit` status. Default is `(r) => false`. + + + +### warn + +Predicate function to determine `warn` status. Default is `(r) => false`. + + + +### info + +Predicate function to determine `info` status. Default is `(r) => false`. + + + +### ok + +Predicate function to determine `ok` status. Default is `(r) => true`. + + + +### topic + +Check topic. Default is `""`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -### ok {data-type="function"} -Predicate function to determine `ok` status. -Default is `(r) => true`. -### topic {data-type="string"} -Check topic. -Default is `""`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -##### Store alert statuses for error counts -{{< code-tabs-wrapper >}} -{{% code-tabs %}} -[Flux](#) -[TICKscript](#) -{{% /code-tabs %}} -{{% code-tab-content %}} +### Store alert statuses for error counts + ```js import "contrib/bonitoo-io/tickscript" @@ -111,20 +172,4 @@ from(bucket: "example-bucket") info: (r) => r._value > 10, ) ``` -{{% /code-tab-content %}} -{{% code-tab-content %}} -```javascript -data = batch - |query('SELECT count(value) from errors') - .every(1m) -data - |alert() - .id('kapacitor/{{ index .Tags "service" }}') - .message('{{ .ID }} is {{ .Level }} value:{{ index .Fields "value" }}') - .info(lambda: "value" > 10) - .warn(lambda: "value" > 20) - .crit(lambda: "value" > 30) -``` -{{% /code-tab-content %}} -{{< /code-tabs-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/compute.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/compute.md index 4635209c5..323cc957d 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/compute.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/compute.md @@ -1,67 +1,69 @@ --- title: tickscript.compute() function description: > - The `tickscript.compute()` function is an alias for `tickscript.select()` that - changes a column's name and optionally applies an aggregate or selector function - to values in the column. + `tickscript.compute()` is an alias for `tickscript.select()` that changes a column’s name and + optionally applies an aggregate or selector function. menu: flux_0_x_ref: name: tickscript.compute - parent: tickscript -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/compute/ - - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/compute/ -related: - - /flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/ - - /{{< latest "kapacitor" >}}/nodes/query_node/ + parent: contrib/bonitoo-io/tickscript + identifier: contrib/bonitoo-io/tickscript/compute +weight: 301 flux/v0.x/tags: [transformations] --- -The `tickscript.compute()` function is an **alias for -[`tickscript.select()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/)** -that changes a column's name and optionally applies an aggregate or selector function. + + +`tickscript.compute()` is an alias for `tickscript.select()` that changes a column’s name and +optionally applies an aggregate or selector function. + + + +##### Function type signature ```js -import "contrib/bonitoo-io/tickscript" - -tickscript.compute( - column: "_value", - fn: sum, - as: "example-name", -) +(<-tables: B, as: string, ?column: A, ?fn: (<-: B, column: A) => stream[C]) => stream[D] where A: Equatable, C: Record, D: Record ``` -#### TICKscript helper function -`tickscript.select()` is a helper function meant to replicate TICKscript operations -like the following: - -```js -// Rename -query("SELECT x AS y") - -// Aggregate and rename -query("SELECT f(x) AS y") -``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -Column to operate on. -Default is `_value`. - -### fn {data-type="function"} -[Aggregate](/flux/v0.x/function-types/#aggregates) or [selector](/flux/v0.x/function-types/#selectors) -function to apply. - -### as {data-type="string"} +### as ({{< req >}}) New column name. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Examples -For examples, see [`tickscript.select()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/#examples). +### column + +Column to operate on. Default is `_value`. + + + +### fn + +Aggregate or selector function to apply. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/deadman.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/deadman.md index d0547910e..b67254a35 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/deadman.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/deadman.md @@ -1,85 +1,138 @@ --- title: tickscript.deadman() function description: > - The `tickscript.deadman()` function detects low data throughput and writes a point - with a critical status to the InfluxDB `_monitoring` system bucket. + `tickscript.deadman()` detects low data throughput and writes a point with a critical status to + the InfluxDB `_monitoring` system bucket. menu: flux_0_x_ref: name: tickscript.deadman - parent: tickscript -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/deadman/ - - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/deadman/ -related: - - /{{< latest "kapacitor" >}}/nodes/batch_node/#deadman, Kapacitor BatchNode – Deadman + parent: contrib/bonitoo-io/tickscript + identifier: contrib/bonitoo-io/tickscript/deadman +weight: 301 flux/v0.x/tags: [transformations] -introduced: 0.111.0 --- -The `tickscript.deadman()` function detects low data throughput and writes a point -with a critical status to the InfluxDB [`_monitoring` system bucket](/{{< latest "influxdb" >}}/reference/internals/system-buckets/). -For each input table containing a number of rows less than or equal to the specified -[threshold](#threshold), the function assigns a `crit` value to the `_level` column. + + +`tickscript.deadman()` detects low data throughput and writes a point with a critical status to +the InfluxDB `_monitoring` system bucket. + +For each input table containing a number of rows less than or equal to the specified threshold, +the function assigns a `crit` value to the` _level` column. + +This function is comparable to [Kapacitor AlertNode deadman](https://docs.influxdata.com/kapacitor/latest/nodes/stream_node/#deadman). + +##### Function type signature ```js -import "contrib/bonitoo-io/tickscript" - -tickscript.deadman( - check: {}, - measurement: "example-measurement", - threshold: 0, - id: (r) => "${r._check_id}", - message: (r) => "Deadman Check: ${r._check_name} is: " + (if r.dead then "dead" else "alive"), - topic: "", -) +( + <-tables: stream[t12], + check: {A with tags: E, _type: D, _check_name: C, _check_id: B}, + measurement: string, + ?id: (r: {F with _check_name: C, _check_id: B}) => G, + ?message: ( + r: { + H with + dead: bool, + _type: D, + _time: J, + _time: time, + _source_timestamp: int, + _source_measurement: I, + _measurement: I, + _measurement: string, + _level: string, + _check_name: C, + _check_id: B, + }, + ) => t10, + ?threshold: t11, + ?topic: string, +) => stream[{ + H with + dead: bool, + _type: D, + _time: J, + _time: time, + _source_timestamp: int, + _source_measurement: I, + _message: t10, + _measurement: I, + _measurement: string, + _level: string, + _check_name: C, + _check_id: B, +}] where E: Record, F: Record, t11: Comparable + Equatable, t12: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### check {data-type="record"} +### check ({{< req >}}) -InfluxDB check data. -_See [`tickscript.defineCheck()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/definecheck/)._ +InfluxDB check data. See `tickscript.defineCheck()`. -### measurement {data-type="string"} + + +### measurement ({{< req >}}) -Measurement name. -Should match the queried measurement. +Measurement name. Should match the queried measurement. -### threshold {data-type="int"} -Count threshold. -The function assigns a `crit` status to input tables with a number of rows less -than or equal to the threshold. -Default is `0`. -### id {data-type="function"} -Function that returns the InfluxDB check ID provided by the [`check` record](#check). + +### threshold + +Count threshold. Default is `0`. + +The function assigns a `crit` status to input tables with a number of rows less than or equal to the threshold. + +### id + +Function that returns the InfluxDB check ID provided by the check record. Default is `(r) => "${r._check_id}"`. -### message {data-type="function"} + + +### message + Function that returns the InfluxDB check message using data from input rows. Default is `(r) => "Deadman Check: ${r._check_name} is: " + (if r.dead then "dead" else "alive")`. -### topic {data-type="string"} -Check topic. -Default is `""`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + +### topic + +Check topic. Default is `""`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{< code-tabs-wrapper >}} -{{% code-tabs %}} -[Flux](#) -[TICKscript](#) -{{% /code-tabs %}} -{{% code-tab-content %}} -```javascript +### Detect when a series stops reporting + +```js import "contrib/bonitoo-io/tickscript" option task = {name: "Example task", every: 1m} @@ -93,17 +146,4 @@ from(bucket: "example-bucket") threshold: 2, ) ``` -{{% /code-tab-content %}} -{{% code-tab-content %}} -```javascript -data = batch - |query('SELECT value from pulse') - .every(1m) -data - |deadman(2.0, 1m) - .id('kapacitor/{{ index .Tags "service" }}') - .message('{{ .ID }} is {{ .Level }} value:{{ index .Fields "value" }}') -``` -{{% /code-tab-content %}} -{{< /code-tabs-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/definecheck.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/definecheck.md index 3c4ca35e3..64ac79268 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/definecheck.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/definecheck.md @@ -1,66 +1,81 @@ --- title: tickscript.defineCheck() function description: > - The `tickscript.defineCheck()` function creates and returns a record with custom - check data required by `tickscript.alert()` and `tickscript.deadman()`. + `tickscript.defineCheck()` creates custom check data required by `alert()` and `deadman()`. menu: flux_0_x_ref: name: tickscript.defineCheck - parent: tickscript -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/definecheck/ - - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/definecheck/ -introduced: 0.111.0 + parent: contrib/bonitoo-io/tickscript + identifier: contrib/bonitoo-io/tickscript/defineCheck +weight: 301 --- -The `tickscript.defineCheck()` function creates and returns a record with custom check data required by -[`tickscript.alert()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/alert/) and -[`tickscript.deadman()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/deadman/). -This check data specifies information about the check in the InfluxDB monitoring system. + + +`tickscript.defineCheck()` creates custom check data required by `alert()` and `deadman()`. + + + +##### Function type signature + +```js +(id: A, name: B, ?type: C) => {tags: {}, _type: C, _check_name: B, _check_id: A} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### id +({{< req >}}) +InfluxDB check ID. + + + +### name +({{< req >}}) +InfluxDB check name. + + + +### type + +InfluxDB check type. Default is `custom`. + +**Valid values**: +- `threshold` +-`deadman` +-`custom` + + +## Examples + +### Generate InfluxDB check data ```js import "contrib/bonitoo-io/tickscript" -tickscript.defineCheck( - id: "000000000000", - name: "Example check name", - type: "custom", -) +tickscript.defineCheck(id: "000000000000", name: "Example check name")// Returns: +// { +// _check_id: 000000000000, +// _check_name: Example check name, +// _type: custom, +// tags: {} +// } + ``` -## Parameters - -## id {data-type="string"} -({{< req >}}) -InfluxDB check ID. - -## name {data-type="string"} -({{< req >}}) -InfluxDB check name. - -## type {data-type="string"} -InfluxDB check type. -Default is `custom`. - -**Supported values:** - -- threshold -- deadman -- custom - -## Examples - -##### Generate InfluxDB check data -```javascript -import "contrib/bonitoo-io/tickscript" - -tickscript.defineCheck(id: "000000000000", name: "Example check name") - -// The function above returns: { -// _check_id: "000000000000", -// _check_name: "Example check name", -// _type: "custom", -// tags: {} -// } -``` diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/groupby.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/groupby.md index 791e6e553..8ed6824ae 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/groupby.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/groupby.md @@ -1,53 +1,110 @@ --- title: tickscript.groupBy() function description: > - The `tickscript.groupBy()` function groups results by the `_measurement` column - and other specified columns. + `tickscript.groupBy()` groups results by the `_measurement` column and other specified columns. menu: flux_0_x_ref: name: tickscript.groupBy - parent: tickscript -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/groupby/ - - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/groupby/ -related: - - /{{< latest "kapacitor" >}}/nodes/query_node/#groupby, Kapacitor QueryNode - groupBy + parent: contrib/bonitoo-io/tickscript + identifier: contrib/bonitoo-io/tickscript/groupBy +weight: 301 flux/v0.x/tags: [transformations] --- -The `tickscript.groupBy()` function groups results by the `_measurement` column and -other specified columns. + + +`tickscript.groupBy()` groups results by the `_measurement` column and other specified columns. + +This function is comparable to [Kapacitor QueryNode .groupBy](https://docs.influxdata.com/kapacitor/latest/nodes/query_node/#groupby). + +**Note**: To group by time intervals, use `window()` or `tickscript.selectWindow()`. + +##### Function type signature ```js -import "contrib/bonitoo-io/tickscript" - -tickscript.groupBy(columns: ["exampleColumn"]) +(<-tables: stream[A], columns: [string]) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### columns {data-type="array of strings"} +### columns ({{< req >}}) List of columns to group by. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -##### Group by host and region +### Group by host and region + ```js import "contrib/bonitoo-io/tickscript" data |> tickscript.groupBy(columns: ["host", "region"]) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _measurement | host | region | _field | _value | +| -------------------- | ------------- | ----- | ------- | ------- | ------- | +| 2021-01-01T00:00:00Z | m | h1 | east | foo | 1.2 | +| 2021-01-01T00:01:00Z | m | h1 | east | foo | 3.4 | +| 2021-01-01T00:00:00Z | m | h2 | east | foo | 2.3 | +| 2021-01-01T00:01:00Z | m | h2 | east | foo | 5.6 | +| 2021-01-01T00:00:00Z | m | h3 | west | foo | 1.2 | +| 2021-01-01T00:01:00Z | m | h3 | west | foo | 3.4 | +| 2021-01-01T00:00:00Z | m | h4 | west | foo | 2.3 | +| 2021-01-01T00:01:00Z | m | h4 | west | foo | 5.6 | + + +#### Output data + +| _time | *_measurement | *host | *region | _field | _value | +| -------------------- | ------------- | ----- | ------- | ------- | ------- | +| 2021-01-01T00:00:00Z | m | h1 | east | foo | 1.2 | +| 2021-01-01T00:01:00Z | m | h1 | east | foo | 3.4 | + +| _time | *_measurement | *host | *region | _field | _value | +| -------------------- | ------------- | ----- | ------- | ------- | ------- | +| 2021-01-01T00:00:00Z | m | h2 | east | foo | 2.3 | +| 2021-01-01T00:01:00Z | m | h2 | east | foo | 5.6 | + +| _time | *_measurement | *host | *region | _field | _value | +| -------------------- | ------------- | ----- | ------- | ------- | ------- | +| 2021-01-01T00:00:00Z | m | h3 | west | foo | 1.2 | +| 2021-01-01T00:01:00Z | m | h3 | west | foo | 3.4 | + +| _time | *_measurement | *host | *region | _field | _value | +| -------------------- | ------------- | ----- | ------- | ------- | ------- | +| 2021-01-01T00:00:00Z | m | h4 | west | foo | 2.3 | +| 2021-01-01T00:01:00Z | m | h4 | west | foo | 5.6 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/join.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/join.md index 1977c59c9..51ec5708a 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/join.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/join.md @@ -1,112 +1,120 @@ --- title: tickscript.join() function description: > - The `tickscript.join()` function merges two input streams into a single output - stream based on specified columns with equal values and appends a new measurement name. + `tickscript.join()` merges two input streams into a single output stream + based on specified columns with equal values and appends a new measurement name. menu: flux_0_x_ref: name: tickscript.join - parent: tickscript -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/join/ - - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/join/ -related: - - /{{< latest "kapacitor" >}}/nodes/join_node/, Kapacitor JoinNode - - /flux/v0.x/stdlib/universe/join/ + parent: contrib/bonitoo-io/tickscript + identifier: contrib/bonitoo-io/tickscript/join +weight: 301 flux/v0.x/tags: [transformations] --- -The `tickscript.join()` function merges two input streams into a single output -stream based on specified columns with equal values and appends a new measurement name. + + +`tickscript.join()` merges two input streams into a single output stream +based on specified columns with equal values and appends a new measurement name. + +This function is comparable to [Kapacitor JoinNode](https://docs.influxdata.com/kapacitor/latest/nodes/join_node/). + +##### Function type signature ```js -import "contrib/bonitoo-io/tickscript" - -tickscript.join( - tables: {t1: example1, t2: example2}, - on: ["_time"], - measurement: "example-measurement", -) +(measurement: A, tables: B, ?on: [string]) => stream[{C with _measurement: A}] where B: Record, C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="record"} +### tables ({{< req >}}) Map of two streams to join. -### on {data-type="array of strings"} -List of columns to join on. -Default is `["_time"]`. -### measurement {data-type="string"} + +### on + +List of columns to join on. Default is `["_time"]`. + + + +### measurement ({{< req >}}) Measurement name to use in results. + + + ## Examples ### Join two streams of data -#### Input data - -{{< flex >}} -{{% flex-content %}} -##### metrics -| _time | host | _value | -|:----- |:---- | ------:| -| 2021-01-01T00:00:00Z | host1 | 1.2 | -| 2021-01-01T01:00:00Z | host1 | 0.8 | -| 2021-01-01T02:00:00Z | host1 | 3.2 | - -| _time | host | _value | -|:----- |:---- | ------:| -| 2021-01-01T00:00:00Z | host2 | 8.4 | -| 2021-01-01T01:00:00Z | host2 | 7.3 | -| 2021-01-01T02:00:00Z | host2 | 7.9 | -{{% /flex-content %}} -{{% flex-content %}} -##### states -| _time | host | _value | -|:----- |:---- | ------:| -| 2021-01-01T00:00:00Z | host1 | dead | -| 2021-01-01T01:00:00Z | host1 | dead | -| 2021-01-01T02:00:00Z | host1 | alive | - -| _time | host | _value | -|:----- |:---- | ------:| -| 2021-01-01T00:00:00Z | host2 | alive | -| 2021-01-01T01:00:00Z | host2 | alive | -| 2021-01-01T02:00:00Z | host2 | alive | -{{% /flex-content %}} -{{< /flex >}} - -#### Query ```js +import "array" import "contrib/bonitoo-io/tickscript" -metrics = //... -states = //... +metrics = + array.from( + rows: [ + {_time: 2021-01-01T00:00:00Z, host: "host1", _value: 1.2}, + {_time: 2021-01-01T01:00:00Z, host: "host1", _value: 0.8}, + {_time: 2021-01-01T02:00:00Z, host: "host1", _value: 3.2}, + {_time: 2021-01-01T00:00:00Z, host: "host2", _value: 8.4}, + {_time: 2021-01-01T01:00:00Z, host: "host2", _value: 7.3}, + {_time: 2021-01-01T02:00:00Z, host: "host2", _value: 7.9}, + ], + ) + |> group(columns: ["host"]) -tickscript.join( - tables: {metric: metrics, state: states}, - on: ["_time", "host"], - measurement: "example-m", -) +states = + array.from( + rows: [ + {_time: 2021-01-01T00:00:00Z, host: "host1", _value: "dead"}, + {_time: 2021-01-01T01:00:00Z, host: "host1", _value: "dead"}, + {_time: 2021-01-01T02:00:00Z, host: "host1", _value: "alive"}, + {_time: 2021-01-01T00:00:00Z, host: "host2", _value: "alive"}, + {_time: 2021-01-01T01:00:00Z, host: "host2", _value: "alive"}, + {_time: 2021-01-01T02:00:00Z, host: "host2", _value: "alive"}, + ], + ) + |> group(columns: ["host"]) + +tickscript.join(tables: {metric: metrics, state: states}, on: ["_time", "host"], measurement: "example-m") ``` +{{< expand-wrapper >}} +{{% expand "View example output" %}} + #### Output data -| _measurement | host | _time | _value_metric | _value_state | -|:------------ |:---- |:----- | -------------:| ------------:| -| example-m | host1 | 2021-01-01T00:00:00Z | 1.2 | dead | -| example-m | host1 | 2021-01-01T01:00:00Z | 0.8 | dead | -| example-m | host1 | 2021-01-01T02:00:00Z | 3.2 | alive | +| *_measurement | _time | _value_metric | _value_state | *host | +| ------------- | -------------------- | -------------- | ------------- | ----- | +| example-m | 2021-01-01T00:00:00Z | 1.2 | dead | host1 | +| example-m | 2021-01-01T01:00:00Z | 0.8 | dead | host1 | +| example-m | 2021-01-01T02:00:00Z | 3.2 | alive | host1 | -| _measurement | host | _time | _value_metric | _value_state | -|:------------ |:---- |:----- | -------------:| ------------:| -| example-m | host2 | 2021-01-01T00:00:00Z | 8.4 | alive | -| example-m | host2 | 2021-01-01T01:00:00Z | 7.3 | alive | -| example-m | host2 | 2021-01-01T02:00:00Z | 7.9 | alive | +| *_measurement | _time | _value_metric | _value_state | *host | +| ------------- | -------------------- | -------------- | ------------- | ----- | +| example-m | 2021-01-01T00:00:00Z | 8.4 | alive | host2 | +| example-m | 2021-01-01T01:00:00Z | 7.3 | alive | host2 | +| example-m | 2021-01-01T02:00:00Z | 7.9 | alive | host2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select.md index f1a8af1b4..0ab7ecf22 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select.md @@ -1,41 +1,41 @@ --- title: tickscript.select() function description: > - The `tickscript.select()` function changes a column's name and optionally applies - an aggregate or selector function to values in the column. + `tickscript.select()` changes a column’s name and optionally applies an aggregate or selector + function to values in the column. menu: flux_0_x_ref: name: tickscript.select - parent: tickscript -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/select/ - - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/select/ -related: - - /flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow/ - - /{{< latest "kapacitor" >}}/nodes/query_node/ + parent: contrib/bonitoo-io/tickscript + identifier: contrib/bonitoo-io/tickscript/select +weight: 301 flux/v0.x/tags: [transformations] -introduced: 0.111.0 --- -The `tickscript.select()` function changes a column's name and optionally applies -an aggregate or selector function to values in the column. + + +`tickscript.select()` changes a column’s name and optionally applies an aggregate or selector +function to values in the column. + +## TICKscript helper function + +`tickscript.select()` is a helper function meant to replicate TICKscript operations like the following: -tickscript.select( - column: "_value", - fn: sum, - as: "example-name", -) ``` - -#### TICKscript helper function -`tickscript.select()` is a helper function meant to replicate TICKscript operations -like the following: - -```js // Rename query("SELECT x AS y") @@ -43,23 +43,40 @@ query("SELECT x AS y") query("SELECT f(x) AS y") ``` +##### Function type signature + +```js +(<-tables: B, as: string, ?column: A, ?fn: (<-: B, column: A) => stream[C]) => stream[D] where A: Equatable, C: Record, D: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -Column to operate on. -Default is `_value`. +### column -### fn {data-type="function"} -[Aggregate](/flux/v0.x/function-types/#aggregates) or [selector](/flux/v0.x/function-types/#selectors) -function to apply. +Column to operate on. Default is `_value`. -### as {data-type="string"} + + +### fn + +Aggregate or selector function to apply. + + + +### as ({{< req >}}) New column name. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples @@ -67,87 +84,153 @@ Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressi - [Change the name of the value column and apply an aggregate function](#change-the-name-of-the-value-column-and-apply-an-aggregate-function) - [Change the name of the value column and apply a selector function](#change-the-name-of-the-value-column-and-apply-a-selector-function) ---- +### Change the name of the value column -#### Change the name of the value column ```js import "contrib/bonitoo-io/tickscript" +import "sampledata" -data +sampledata.int() |> tickscript.select(as: "example-name") ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T01:00:00Z | 3.2 | -| 2021-01-01T02:00:00Z | 4.0 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | example-name | -|:----- | ------------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T01:00:00Z | 3.2 | -| 2021-01-01T02:00:00Z | 4.0 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} ---- +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | example-name | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | example-name | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Change the name of the value column and apply an aggregate function -#### Change the name of the value column and apply an aggregate function ```js import "contrib/bonitoo-io/tickscript" +import "sampledata" -data +sampledata.int() |> tickscript.select(as: "sum", fn: sum) ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T01:00:00Z | 3.2 | -| 2021-01-01T02:00:00Z | 4.0 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| sum | -|:---:| -| 8.4 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} ---- +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | sum | +| ---- | ---- | +| t1 | 51 | + +| *tag | sum | +| ---- | ---- | +| t2 | 53 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Change the name of the value column and apply a selector function -#### Change the name of the value column and apply a selector function ```js import "contrib/bonitoo-io/tickscript" +import "sampledata" -data +sampledata.int() |> tickscript.select(as: "max", fn: max) ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T01:00:00Z | 3.2 | -| 2021-01-01T02:00:00Z | 4.0 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | max | -|:----- | ---:| -| 2021-01-01T02:00:00Z | 4.0 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} ---- +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | max | *tag | +| -------------------- | ---- | ---- | +| 2021-01-01T00:00:30Z | 17 | t1 | + +| _time | max | *tag | +| -------------------- | ---- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow.md index 0587fc1da..568540e5c 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow.md @@ -1,112 +1,144 @@ --- title: tickscript.selectWindow() function description: > - The `tickscript.selectWindow()` function changes a column's name, windows rows by time, - and applies an aggregate or selector function the specified column for each window of time. + `tickscript.selectWindow()` changes a column’s name, windows rows by time, and then applies an + aggregate or selector function the specified column for each window of time. menu: flux_0_x_ref: name: tickscript.selectWindow - parent: tickscript -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/selectwindow/ - - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/selectwindow/ -related: - - /flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/ - - /{{< latest "kapacitor" >}}/nodes/query_node/ + parent: contrib/bonitoo-io/tickscript + identifier: contrib/bonitoo-io/tickscript/selectWindow +weight: 301 flux/v0.x/tags: [transformations] -introduced: 0.111.0 --- -The `tickscript.selectWindow()` function changes a column's name, windows rows by time, -and applies an aggregate or selector function the specified column for each window of time. + + +`tickscript.selectWindow()` changes a column’s name, windows rows by time, and then applies an +aggregate or selector function the specified column for each window of time. + +## TICKscript helper function +`tickscript.selectWindow` is a helper function meant to replicate TICKscript operations like the following: -tickscript.selectWindow( - column: "_value", - fn: sum, - as: "example-name", - every: 1m, - defaultValue: 0.0, -) ``` - -#### TICKscript helper function -`tickscript.selectWindow()` is a helper function meant to replicate TICKscript operations -like the following: - -```js // Rename, window, and aggregate query("SELECT f(x) AS y") .groupBy(time(t), ...) ``` +##### Function type signature + +```js +( + <-tables: stream[D], + as: string, + defaultValue: A, + every: duration, + fn: (<-: stream[B], column: string) => stream[C], + ?column: string, +) => stream[E] where B: Record, C: Record, D: Record, E: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -Column to operate on. -Default is `_value`. +### column -_**Data type:** String_ +Column to operate on. Default is _value. -### fn {data-type="function"} + + +### fn ({{< req >}}) -[Aggregate](/flux/v0.x/function-types/#aggregates) or [selector](/flux/v0.x/function-types/#selectors) -function to apply. +Aggregate or selector function to apply. -### as {data-type="string"} + + +### as ({{< req >}}) New column name. -### every {data-type="duration"} + + +### every ({{< req >}}) Duration of windows. -### defaultValue {data-type="string, bool, int, uint, float, bytes"} + + +### defaultValue ({{< req >}}) -Default fill value for null values in [`column`](#column). +Default fill value for null values in column. +Must be the same data type as column. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + -_Must be the same data type as `column`._ -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -#### Change the name of, window, and then aggregate the value column +### Change the name of, window, and then aggregate the value column + ```js import "contrib/bonitoo-io/tickscript" data - |> tickscript.selectWindow( - fn: sum, - as: "example-name", - every: 1h, - defaultValue: 0.0, - ) + |> tickscript.selectWindow(fn: sum, as: "example-name", every: 1h, defaultValue: 0) ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T00:30:00Z | 0.8 | -| 2021-01-01T01:00:00Z | 3.2 | -| 2021-01-01T01:30:00Z | 3.9 | -| 2021-01-01T02:00:00Z | | -| 2021-01-01T02:30:00Z | 3.3 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | example-name | -|:----- | ------------:| -| 2021-01-01T00:59:59 | 2.0 | -| 2021-01-01T01:59:59 | 7.1 | -| 2021-01-01T02:59:59 | 3.3 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *_start | *_stop | *tag | example-name | _time | +| -------------------- | -------------------- | ---- | ------------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 51 | 2021-01-01T00:01:00Z | + +| *_start | *_stop | *tag | example-name | _time | +| -------------------- | -------------------- | ---- | ------------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 53 | 2021-01-01T00:01:00Z | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/_index.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/_index.md index 070b089e5..3af590b8c 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/_index.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/_index.md @@ -1,36 +1,44 @@ --- -title: Flux victorops package -list_title: victorops package +title: victorops package description: > - The Flux `victorops` package provides functions that send events to - [VictorOps](https://victorops.com). + The `victorops` package provides functions that send events to [VictorOps](https://victorops.com/). menu: flux_0_x_ref: - name: victorops - parent: bonitoo-io -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/victorops/ - - /influxdb/cloud/reference/flux/stdlib/contrib/victorops/ -flux/v0.x/tags: [functions, victorops, package] -introduced: 0.108.0 + name: victorops + parent: contrib/bonitoo-io + identifier: contrib/bonitoo-io/victorops +weight: 31 +cascade: + + introduced: 0.108.0 --- -The Flux `victorops` package provides functions that send events to -[VictorOps](https://victorops.com). + + +The `victorops` package provides functions that send events to [VictorOps](https://victorops.com/). Import the `contrib/bonitoo-io/victorops` package: ```js import "contrib/bonitoo-io/victorops" ``` +**Note**: VictorOps is now Splunk On-Call + + ## Set up VictorOps To send events to VictorOps with Flux: @@ -38,6 +46,7 @@ To send events to VictorOps with Flux: 2. [Create a REST integration routing key](https://help.victorops.com/knowledge-base/routing-keys/). 3. [Create a VictorOps API key](https://help.victorops.com/knowledge-base/api/). + ## Functions {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/alert.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/alert.md index a5cbf0dcd..3f64eb8cf 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/alert.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/alert.md @@ -1,88 +1,105 @@ --- title: victorops.alert() function description: > - The `victorops.alert()` function sends an alert to VictorOps. + `victorops.alert()` sends an alert to VictorOps. menu: flux_0_x_ref: name: victorops.alert - parent: victorops -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/victorops/event/ - - /influxdb/cloud/reference/flux/stdlib/contrib/victorops/event/ - - /flux/v0.x/stdlib/contrib/bonitoo-io/victorops/event/ -introduced: 0.108.0 + parent: contrib/bonitoo-io/victorops + identifier: contrib/bonitoo-io/victorops/alert +weight: 301 +flux/v0.x/tags: [single notification] --- -The `victorops.alert()` function sends an alert to [VictorOps](https://www.victorops.com/). + + +`victorops.alert()` sends an alert to VictorOps. + + + +##### Function type signature ```js -import "contrib/bonitoo-io/victorops" - -victorops.alert( - url: "https://alert.victorops.com/integrations/generic/00000000/alert/${api_key}/${routing_key}", - monitoringTool: "", - messageType: "CRITICAL", - entityID: "", - entityDisplayName: "", - stateMessage: "", - timestamp: now(), -) +( + messageType: A, + url: string, + ?entityDisplayName: B, + ?entityID: C, + ?monitoringTool: D, + ?stateMessage: E, + ?timestamp: F, +) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url ({{< req >}}) -[VictorOps REST endpoint integration URL](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/). +VictorOps REST endpoint integration URL. -##### VictorOps URL example -``` -https://alert.victorops.com/integrations/generic/00000000/alert// -``` +Example: `https://alert.victorops.com/integrations/generic/00000000/alert//` +Replace `` and `` with valid VictorOps API and routing keys. -_Replace `` and `` with valid VictorOps API and routing keys._ +### monitoringTool -### monitoringTool {data-type="string"} -Monitoring agent name. -Default is `""`. +Monitoring agent name. Default is `""`. -### messageType {data-type="string"} + + +### messageType ({{< req >}}) -VictorOps [message type](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields) -(alert behavior). - -**Valid values:** +VictorOps message type (alert behavior). +**Valid values**: - `CRITICAL` - `WARNING` - `INFO` -### entityID {data-type="string"} -[Incident ID](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields). -Default is `""`. +### entityID + +Incident ID. Default is `""`. + + + +### entityDisplayName + +Incident display name or summary. Default is `""`. + + + +### stateMessage + +Verbose incident message. Default is `""`. + + + +### timestamp + +Incident start time. Default is `now()`. -### entityDisplayName {data-type="string"} -[Incident display name or summary](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields). -Default is `""`. -### stateMessage {data-type="string"} -[Verbose incident message](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields). -Default is `""`. -### timestamp {data-type="time"} -[Incident start time](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields). -Default is `now()`. ## Examples -##### Send the last reported value and incident type to VictorOps +### Send the last reported value and incident type to VictorOps + ```js import "contrib/bonitoo-io/victorops" import "influxdata/influxdb/secrets" @@ -111,3 +128,4 @@ victorops.alert( stateMessage: "Last reported cpu_idle was ${string(v: r._value)}.", ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/endpoint.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/endpoint.md index 7b139b8e2..cd546a8ff 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/endpoint.md @@ -1,95 +1,70 @@ --- title: victorops.endpoint() function description: > - The `victorops.endpoint()` function sends events to VictorOps using data from input rows. + `victorops.endpoint()` sends events to VictorOps using data from input rows. menu: flux_0_x_ref: name: victorops.endpoint - parent: victorops -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/victorops/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/victorops/endpoint/ -flux/v0.x/tags: [notification endpoints] -introduced: 0.108.0 + parent: contrib/bonitoo-io/victorops + identifier: contrib/bonitoo-io/victorops/endpoint +weight: 301 --- -The `victorops.endpoint()` function sends events to VictorOps using data from input rows. + + +`victorops.endpoint()` sends events to VictorOps using data from input rows. + + + +##### Function type signature ```js -import "contrib/bonitoo-io/victorops" - -victorops.endpoint( - url: "https://alert.victorops.com/integrations/generic/00000000/alert${apiKey}/${routingKey}", -) +( + url: string, + ?monitoringTool: A, +) => ( + mapFn: ( + r: B, + ) => { + C with + timestamp: H, + stateMessage: G, + messageType: F, + entityID: E, + entityDisplayName: D, + }, +) => (<-tables: stream[B]) => stream[{B with _sent: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url ({{< req >}}) -[VictorOps REST endpoint integration URL](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/). +VictorOps REST endpoint integration URL. -##### VictorOps URL example -``` -https://alert.victorops.com/integrations/generic/00000000/alert// -``` +Example: `https://alert.victorops.com/integrations/generic/00000000/alert//` +Replace `` and `` with valid VictorOps API and routing keys. -_Replace `` and `` with valid VictorOps API and routing keys._ +### monitoringTool -## Usage -`victorops.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. +Tool to use for monitoring. +Default is `InfluxDB`. -### mapFn {data-type="function"} -A function that builds the object used to generate the POST request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns an object that must include the -following fields: -- `monitoringTool` -- `messageType` -- `entityID` -- `entityDisplayName` -- `stateMessage` -- `timestamp` - -_For more information, see [`victorops.event()` parameters](/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/event/#parameters)._ - -## Examples - -##### Send critical events to VictorOps -```js -import "contrib/bonitoo-io/victorops" -import "influxdata/influxdb/secrets" - -apiKey = secrets.get(key: "VICTOROPS_API_KEY") -routingKey = secrets.get(key: "VICTOROPS_ROUTING_KEY") -url = "https://alert.victorops.com/integrations/generic/00000000/alert/${apiKey}/${routingKey}" -endpoint = victorops.endpoint(url: url) - -crit_events = - from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") - -crit_events - |> endpoint( - mapFn: (r) => - ({ - monitoringTool: "InfluxDB", - messageType: "CRITICAL", - entityID: "${r.host}-${r._field}-critical", - entityDisplayName: "Critical alert for ${r.host}", - stateMessage: "${r.host} is in a critical state. ${r._field} is ${string(v: r._value)}.", - timestamp: now(), - }), - )() -``` diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/_index.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/_index.md index c9ef1cf42..1dfeadd11 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/_index.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/_index.md @@ -1,26 +1,44 @@ --- -title: Flux zenoss package -list_title: zenoss package +title: zenoss package description: > - The Flux `zenoss` package provides functions that send events to - [Zenoss](https://www.zenoss.com/). + The `zenoss` package provides functions that send events to [Zenoss](https://www.zenoss.com/). menu: flux_0_x_ref: - name: zenoss - parent: bonitoo-io -weight: 202 -flux/v0.x/tags: [functions, zenoss, package] -introduced: 0.108.0 + name: zenoss + parent: contrib/bonitoo-io + identifier: contrib/bonitoo-io/zenoss +weight: 31 +cascade: + + introduced: 0.108.0 --- -The Flux `zenoss` package provides functions that send events to -[Zenoss](https://www.zenoss.com/). + + +The `zenoss` package provides functions that send events to [Zenoss](https://www.zenoss.com/). Import the `contrib/bonitoo-io/zenoss` package: ```js import "contrib/bonitoo-io/zenoss" ``` + + + ## Functions {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/endpoint.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/endpoint.md index a893d368e..8f18980ad 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/endpoint.md @@ -1,118 +1,111 @@ --- title: zenoss.endpoint() function description: > - The `zenoss.endpoint()` function sends events to Zenoss using data from input rows. + `zenoss.endpoint()` sends events to Zenoss using data from input rows. menu: flux_0_x_ref: name: zenoss.endpoint - parent: zenoss -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/zenoss/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/zenoss/endpoint/ -flux/v0.x/tags: [notification endpoints] -introduced: 0.108.0 + parent: contrib/bonitoo-io/zenoss + identifier: contrib/bonitoo-io/zenoss/endpoint +weight: 301 --- -The `zenoss.endpoint()` function sends events to Zenoss using data from input rows. + + +`zenoss.endpoint()` sends events to Zenoss using data from input rows. + + + +##### Function type signature ```js -import "contrib/bonitoo-io/zenoss" - -zenoss.endpoint( - url: "https://example.zenoss.io:8080/zport/dmd/evconsole_router", - username: "example-user", - password: "example-password", - action: "EventsRouter", - method: "add_event", - type: "rpc", - tid: 1, -) +( + password: string, + url: string, + username: string, + ?action: A, + ?method: B, + ?tid: C, + ?type: D, +) => ( + mapFn: ( + r: E, + ) => { + F with + summary: t13, + severity: t12, + message: t11, + eventClassKey: t10, + eventClass: J, + device: I, + component: H, + collector: G, + }, +) => (<-tables: stream[E]) => stream[{E with _sent: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url ({{< req >}}) Zenoss [router endpoint URL](https://help.zenoss.com/zsd/RM/configuring-resource-manager/enabling-access-to-browser-interfaces/creating-and-changing-public-endpoints). -### username {data-type="string"} + + +### username ({{< req >}}) Zenoss username to use for HTTP BASIC authentication. Default is `""` (no authentication). -### password {data-type="string"} + + +### password ({{< req >}}) Zenoss password to use for HTTP BASIC authentication. Default is `""` (no authentication). -### action {data-type="string"} -Zenoss [router name](https://help.zenoss.com/dev/collection-zone-and-resource-manager-apis/anatomy-of-an-api-request#AnatomyofanAPIrequest-RouterURL). + + +### action + +Zenoss router name. Default is `"EventsRouter"`. -### method {data-type="string"} -[EventsRouter method](https://help.zenoss.com/dev/collection-zone-and-resource-manager-apis/codebase/routers/router-reference/eventsrouter). + + +### method + +EventsRouter method. Default is `"add_event"`. -### type {data-type="string"} -Event type. -Default is `"rpc"`. -### tid {data-type="int"} + +### type + +Event type. Default is `"rpc"`. + + + +### tid + Temporary request transaction ID. Default is `1`. -## Usage -`zenoss.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. -### mapFn {data-type="function"} -A function that builds the object used to generate the POST request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns an object that must include the -following fields: - -- `summary` -- `device` -- `component` -- `severity` -- `eventClass` -- `eventClassKey` -- `collector` -- `message` - -_For more information, see [`zenoss.event()` parameters](/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/event/#parameters)._ - -## Examples - -##### Send critical events to Zenoss -```js -import "contrib/bonitoo-io/zenoss" -import "influxdata/influxdb/secrets" - -url = "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router" -username = secrets.get(key: "ZENOSS_USERNAME") -password = secrets.get(key: "ZENOSS_PASSWORD") -endpoint = zenoss.endpoint(url: url, username: username, password: password) - -crit_events = - from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") - -crit_events - |> endpoint( - mapFn: (r) => - ({ - summary: "Critical event for ${r.host}", - device: r.deviceID, - component: r.host, - severity: "Critical", - eventClass: "/App", - eventClassKey: "", - collector: "", - message: "${r.host} is in a critical state.", - }), - )() -``` diff --git a/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/event.md b/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/event.md index 4ca055cdc..c5539d344 100644 --- a/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/event.md +++ b/content/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/event.md @@ -1,116 +1,174 @@ --- title: zenoss.event() function description: > - The `zenoss.event()` function sends an event to Zenoss. + `zenoss.event()` sends an event to [Zenoss](https://www.zenoss.com/). menu: flux_0_x_ref: name: zenoss.event - parent: zenoss -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/zenoss/event/ - - /influxdb/cloud/reference/flux/stdlib/contrib/zenoss/event/ -introduced: 0.108.0 + parent: contrib/bonitoo-io/zenoss + identifier: contrib/bonitoo-io/zenoss/event +weight: 301 +flux/v0.x/tags: [single notification] --- -The `zenoss.event()` function sends an event to [Zenoss](https://www.zenoss.com/). + + +`zenoss.event()` sends an event to [Zenoss](https://www.zenoss.com/). + + + +##### Function type signature ```js -import "contrib/bonitoo-io/zenoss" - -zenoss.event( - url: "https://example.zenoss.io:8080/zport/dmd/evconsole_router", - username: "example-user", - password: "example-password", - action: "EventsRouter", - method: "add_event", - type: "rpc", - tid: 1, - summary: "", - device: "", - component: "", - severity: "Critical", - eventClass: "", - eventClassKey: "", - collector: "", - message: "", -) +( + password: string, + severity: A, + url: string, + username: string, + ?action: B, + ?collector: C, + ?component: D, + ?device: E, + ?eventClass: F, + ?eventClassKey: G, + ?message: H, + ?method: I, + ?summary: J, + ?tid: t10, + ?type: t11, +) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url ({{< req >}}) Zenoss [router endpoint URL](https://help.zenoss.com/zsd/RM/configuring-resource-manager/enabling-access-to-browser-interfaces/creating-and-changing-public-endpoints). -### username {data-type="string"} + + +### username ({{< req >}}) Zenoss username to use for HTTP BASIC authentication. Default is `""` (no authentication). -### password {data-type="string"} + + +### password ({{< req >}}) Zenoss password to use for HTTP BASIC authentication. Default is `""` (no authentication). -### action {data-type="string"} -Zenoss [router name](https://help.zenoss.com/dev/collection-zone-and-resource-manager-apis/anatomy-of-an-api-request#AnatomyofanAPIrequest-RouterURL). -Default is `"EventsRouter"`. -### method {data-type="string"} + +### action + +Zenoss router name. +Default is "EventsRouter". + + + +### method + [EventsRouter method](https://help.zenoss.com/dev/collection-zone-and-resource-manager-apis/codebase/routers/router-reference/eventsrouter). -Default is `"add_event"`. +Default is "add_event". + + + +### type -### type {data-type="string"} Event type. -Default is `"rpc"`. +Default is "rpc". + + + +### tid -### tid {data-type="int"} Temporary request transaction ID. Default is `1`. -### summary {data-type="string"} + + +### summary + Event summary. Default is `""`. -### device {data-type="string"} + + +### device + Related device. Default is `""`. -### component {data-type="string"} + + +### component + Related component. Default is `""`. -### severity {data-type="string"} + + +### severity ({{< req >}}) [Event severity level](https://help.zenoss.com/zsd/RM/administering-resource-manager/event-management/event-severity-levels). -**Supported values:** - +**Supported values**: - Critical - Warning - Info - Clear -### eventClass {data-type="string"} +### eventClass + [Event class](https://help.zenoss.com/zsd/RM/administering-resource-manager/event-management/understanding-event-classes). Default is `""`. -### eventClassKey {data-type="string"} + + +### eventClassKey + Event [class key](https://help.zenoss.com/zsd/RM/administering-resource-manager/event-management/event-fields). Default is `""`. -### collector {data-type="string"} + + +### collector + Zenoss [collector](https://help.zenoss.com/zsd/RM/administering-resource-manager/event-management/event-fields). Default is `""`. -### message {data-type="string"} + + +### message + Related message. Default is `""`. + + + ## Examples -##### Send the last reported value and severity to Zenoss +### Send the last reported value and severity to Zenoss + ```js import "contrib/bonitoo-io/zenoss" import "influxdata/influxdb/secrets" @@ -143,3 +201,4 @@ zenoss.event( "Clear", ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/chobbs/_index.md b/content/flux/v0.x/stdlib/contrib/chobbs/_index.md index 10f69cefd..f628a6d38 100644 --- a/content/flux/v0.x/stdlib/contrib/chobbs/_index.md +++ b/content/flux/v0.x/stdlib/contrib/chobbs/_index.md @@ -1,25 +1,36 @@ --- -title: Packages contributed by chobbs -list_title: chobbs package +title: chobbs package description: > - The `chobbs` package contains functions and packages contributed by [@chobbs](https://github.com/chobbs). + The `chobbs` package contains packages and functions contributed by [@chobbs](https://github.com/chobbs). menu: flux_0_x_ref: - name: chobbs + name: chobbs parent: contrib -weight: 101 -introduced: 0.69.0 -cascade: - append: - block: note - content: | - #### Package author and maintainer - **Github:** [@chobbs](https://github.com/chobbs) - **InfluxDB Slack:** [@craig](https://influxdata.com/slack) + identifier: contrib/chobbs +weight: 21 --- -The `chobbs` package contains functions and packages contributed by [@chobbs](https://github.com/chobbs). + + +The `chobbs` package contains packages and functions contributed by [@chobbs](https://github.com/chobbs). + + + ## Packages -{{< children >}} \ No newline at end of file +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/contrib/chobbs/discord/_index.md b/content/flux/v0.x/stdlib/contrib/chobbs/discord/_index.md index 7a1189b6d..e787e02e2 100644 --- a/content/flux/v0.x/stdlib/contrib/chobbs/discord/_index.md +++ b/content/flux/v0.x/stdlib/contrib/chobbs/discord/_index.md @@ -1,47 +1,57 @@ --- -title: Flux discord package -list_title: discord package +title: discord package description: > - The Flux `discord` package provides functions for sending messages to [Discord](https://discord.com/). - Import the `contrib/chobbs/discord` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/discord/ - - /influxdb/cloud/reference/flux/stdlib/contrib/discord/ + The `discord` package provides functions for sending messages to [Discord](https://discord.com/). menu: flux_0_x_ref: - name: discord - parent: chobbs -weight: 201 -flux/v0.x/tags: [functions, discord, package] -introduced: 0.69.0 + name: discord + parent: contrib/chobbs + identifier: contrib/chobbs/discord +weight: 31 +cascade: + + introduced: 0.69.0 --- -The Flux `discord` package provides functions for sending messages to [Discord](https://discord.com/). + + +The `discord` package provides functions for sending messages to [Discord](https://discord.com/). Import the `contrib/chobbs/discord` package: ```js import "contrib/chobbs/discord" ``` + + ## Options -The `contrib/chobbs/discord` package provides the following options: ```js -import "contrib/chobbs/discord" - option discord.discordURL = "https://discordapp.com/api/webhooks/" ``` + +### discordURL -### discordURL {data-type="string"} -Discord webhook URL. +`discordURL` is the Discord webhook URL. Default is `https://discordapp.com/api/webhooks/`. + + + ## Functions {{< children type="functions" show="pages" >}} - -{{% note %}} -#### Package author and maintainer -**Github:** [@chobbs](https://github.com/chobbs) -**InfluxDB Slack:** [@craig](https://influxdata.com/slack) -{{% /note %}} diff --git a/content/flux/v0.x/stdlib/contrib/chobbs/discord/endpoint.md b/content/flux/v0.x/stdlib/contrib/chobbs/discord/endpoint.md index e970fd856..b801c6a5e 100644 --- a/content/flux/v0.x/stdlib/contrib/chobbs/discord/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/chobbs/discord/endpoint.md @@ -1,80 +1,75 @@ --- title: discord.endpoint() function description: > - The `discord.endpoint()` function sends a single message to a Discord channel using - a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3) + `discord.endpoint()` sends a single message to a Discord channel using a + [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3) and data from table rows. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/discord/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/discord/endpoint/ menu: flux_0_x_ref: name: discord.endpoint - parent: discord -weight: 202 -flux/v0.x/tags: [notification endpoints] -introduced: 0.74.0 + parent: contrib/chobbs/discord + identifier: contrib/chobbs/discord/endpoint +weight: 301 --- -The `discord.endpoint()` function sends a single message to a Discord channel using -a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3) + + +`discord.endpoint()` sends a single message to a Discord channel using a +[Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3) and data from table rows. -```js -import "contrib/chobbs/discord" -discord.endpoint( - webhookToken: "mySuPerSecRetTokEn", - webhookID: "123456789", - username: "username", - avatar_url: "https://example.com/avatar_pic.jpg", -) + +##### Function type signature + +```js +( + username: A, + webhookID: string, + webhookToken: string, + ?avatar_url: B, +) => (mapFn: (r: C) => {D with content: E}) => (<-tables: stream[C]) => stream[{C with _sent: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### webhookToken {data-type="string"} +### webhookToken +({{< req >}}) Discord [webhook token](https://discord.com/developers/docs/resources/webhook). -### webhookID {data-type="string"} + + +### webhookID +({{< req >}}) Discord [webhook ID](https://discord.com/developers/docs/resources/webhook). -### username {data-type="string"} -Override the Discord webhook's default username. -### avatar_url {data-type="string"} -Override the Discord webhook's default avatar. -## Usage -`discord.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. +### username +({{< req >}}) +Override the Discord webhook’s default username. -### mapFn {data-type="function"} -A function that builds the record used to generate the Discord webhook request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns a record that must include the -following field: -- `content` +### avatar_url -_For more information, see the [`discord.send() content` parameter](/flux/v0.x/stdlib/contrib/chobbs/discord/send/#content)._ +Override the Discord webhook’s default avatar. -## Examples -##### Send critical statuses to a Discord channel -```js -import "influxdata/influxdb/secrets" -import "contrib/chobbs/discord" -discordToken = secrets.get(key: "DISCORD_TOKEN") -endpoint = telegram.endpoint(webhookToken: discordToken, webhookID: "123456789", username: "critBot") - -crit_statuses = - from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") - -crit_statuses - |> endpoint(mapFn: (r) => ({content: "The status is critical!"}))() -``` diff --git a/content/flux/v0.x/stdlib/contrib/chobbs/discord/send.md b/content/flux/v0.x/stdlib/contrib/chobbs/discord/send.md index 1df4846d7..3d7e7e918 100644 --- a/content/flux/v0.x/stdlib/contrib/chobbs/discord/send.md +++ b/content/flux/v0.x/stdlib/contrib/chobbs/discord/send.md @@ -1,55 +1,89 @@ --- title: discord.send() function description: > - The `discord.send()` function sends a single message to a Discord channel using - a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3). -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/discord/send/ - - /influxdb/cloud/reference/flux/stdlib/contrib/discord/send/ + `discord.send()` sends a single message to a Discord channel using a Discord webhook. menu: flux_0_x_ref: name: discord.send - parent: discord -weight: 202 -introduced: 0.69.0 + parent: contrib/chobbs/discord + identifier: contrib/chobbs/discord/send +weight: 301 +flux/v0.x/tags: [single notification] --- -The `discord.send()` function sends a single message to a Discord channel using -a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3). + + +`discord.send()` sends a single message to a Discord channel using a Discord webhook. + + + +##### Function type signature ```js -import "contrib/chobbs/discord" - -discord.send( - webhookToken: "mySuPerSecRetTokEn", - webhookID: "123456789", - username: "username", - content: "This is an example message", - avatar_url: "https://example.com/avatar_pic.jpg", -) +( + content: A, + username: B, + webhookID: string, + webhookToken: string, + ?avatar_url: C, +) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### webhookToken {data-type="string"} +### webhookToken +({{< req >}}) Discord [webhook token](https://discord.com/developers/docs/resources/webhook). -### webhookID {data-type="string"} + + +### webhookID +({{< req >}}) Discord [webhook ID](https://discord.com/developers/docs/resources/webhook). -### username {data-type="string"} -Override the Discord webhook's default username. -### content {data-type="string"} + +### username +({{< req >}}) +Override the Discord webhook’s default username. + + + +### content +({{< req >}}) Message to send to Discord (2000 character limit). -### avatar_url {data-type="string"} -Override the Discord webhook's default avatar. + + +### avatar_url + +Override the Discord webhook’s default avatar. + + + ## Examples -##### Send the last reported status to Discord +### Send the last reported status to Discord + ```js +import "contrib/chobbs/discord" import "influxdata/influxdb/secrets" token = secrets.get(key: "DISCORD_TOKEN") @@ -70,8 +104,3 @@ discord.send( ) ``` -{{% note %}} -#### Package author and maintainer -**Github:** [@chobbs](https://github.com/chobbs) -**InfluxDB Slack:** [@craig](https://influxdata.com/slack) -{{% /note %}} diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/_index.md b/content/flux/v0.x/stdlib/contrib/jsternberg/_index.md index 6837b7d49..6ea5cb61f 100644 --- a/content/flux/v0.x/stdlib/contrib/jsternberg/_index.md +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/_index.md @@ -1,25 +1,36 @@ --- -title: Packages contributed by jsternberg -list_title: jsternberg package +title: jsternberg package description: > - The `jsternberg` package contains functions and packages contributed by [@jsternberg](https://github.com/jsternberg). + The `jsternberg` package contains packages and functions contributed by [@jsternberg](https://github.com/jsternberg). menu: flux_0_x_ref: - name: jsternberg + name: jsternberg parent: contrib -weight: 101 -introduced: 0.77.0 -cascade: - append: - block: note - content: | - #### Package author and maintainer - **Github:** [@jsternberg](https://github.com/jsternberg) - **InfluxDB Slack:** [@Jonathan Sternberg](https://influxdata.com/slack) + identifier: contrib/jsternberg +weight: 21 --- -The `jsternberg` package contains functions and packages contributed by [@jsternberg](https://github.com/jsternberg). + + +The `jsternberg` package contains packages and functions contributed by [@jsternberg](https://github.com/jsternberg). + + + ## Packages -{{< children >}} \ No newline at end of file +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/_index.md b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/_index.md new file mode 100644 index 000000000..9095d84c9 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/_index.md @@ -0,0 +1,51 @@ +--- +title: aggregate package +description: > + The `aggregate` package provides an API for computing multiple aggregates over multiple columns within the same table stream. +menu: + flux_0_x_ref: + name: aggregate + parent: contrib/jsternberg + identifier: contrib/jsternberg/aggregate +weight: 31 +--- + + + +The `aggregate` package provides an API for computing multiple aggregates over multiple columns within the same table stream. +Import the `contrib/jsternberg/aggregate` package: + +```js +import "contrib/jsternberg/aggregate" +``` + +## Constants + +```js +aggregate.none +aggregate.null +``` + +- **aggregate.none** is a sentinel value for fill that will skip +emitting a row if there are no values for an interval. +- **aggregate.null** is a sentinel value for fill that will fill +in a null value if there were no values for an interval. + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/count.md b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/count.md new file mode 100644 index 000000000..d8cfef9c8 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/count.md @@ -0,0 +1,63 @@ +--- +title: aggregate.count() function +description: > + `aggregate.count()` constructs a count aggregate for the column. +menu: + flux_0_x_ref: + name: aggregate.count + parent: contrib/jsternberg/aggregate + identifier: contrib/jsternberg/aggregate/count +weight: 301 +--- + + + +`aggregate.count()` constructs a count aggregate for the column. + + + +##### Function type signature + +```js +( + ?column: A, + ?fill: B, +) => { + reduce: (state: int, values: [E]) => int, + init: (values: [D]) => int, + fill: B, + compute: (state: C) => C, + column: A, +} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### column + +Name of the column to aggregate. + + + +### fill + +When set, value to replace missing values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/define.md b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/define.md new file mode 100644 index 000000000..8466ae002 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/define.md @@ -0,0 +1,91 @@ +--- +title: aggregate.define() function +description: > + `aggregate.define()` constructs an aggregate function record. +menu: + flux_0_x_ref: + name: aggregate.define + parent: contrib/jsternberg/aggregate + identifier: contrib/jsternberg/aggregate/define +weight: 301 +--- + + + +`aggregate.define()` constructs an aggregate function record. + + + +##### Function type signature + +```js +( + compute: A, + init: B, + reduce: C, + ?fill: D, +) => ( + ?column: E, + ?fill: F, +) => { + reduce: C, + init: B, + fill: F, + compute: A, + column: E, +} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### init +({{< req >}}) +Function to compute the initial state of the +output. This can return either the final aggregate or a +temporary state object that can be used to compute the +final aggregate. The `values` parameter will always be a +non-empty array of values from the specified column. + + + +### reduce +({{< req >}}) +Function that takes in another buffer of values +and the current state of the aggregate and computes +the updated state. + + + +### compute +({{< req >}}) +Function that takes the state and computes the final aggregate. + + + +### fill + +Value passed to `fill()`. If present, the fill value determines what +the aggregate does when there are no values. +This can either be a value or one of the predefined +identifiers, `null` or `none`. +This value must be the same type as the value return from +compute. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/max.md b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/max.md new file mode 100644 index 000000000..b80706369 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/max.md @@ -0,0 +1,63 @@ +--- +title: aggregate.max() function +description: > + `aggregate.max()` constructs a max aggregate or selector for the column. +menu: + flux_0_x_ref: + name: aggregate.max + parent: contrib/jsternberg/aggregate + identifier: contrib/jsternberg/aggregate/max +weight: 301 +--- + + + +`aggregate.max()` constructs a max aggregate or selector for the column. + + + +##### Function type signature + +```js +( + ?column: A, + ?fill: B, +) => { + reduce: (state: D, values: [D]) => D, + init: (values: [D]) => D, + fill: B, + compute: (state: C) => C, + column: A, +} where D: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### column + +Name of the column to aggregate. + + + +### fill + +When set, value to replace missing values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/mean.md b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/mean.md new file mode 100644 index 000000000..7a9d2dc72 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/mean.md @@ -0,0 +1,63 @@ +--- +title: aggregate.mean() function +description: > + `aggregate.mean()` constructs a mean aggregate for the column. +menu: + flux_0_x_ref: + name: aggregate.mean + parent: contrib/jsternberg/aggregate + identifier: contrib/jsternberg/aggregate/mean +weight: 301 +--- + + + +`aggregate.mean()` constructs a mean aggregate for the column. + + + +##### Function type signature + +```js +( + ?column: A, + ?fill: B, +) => { + reduce: (state: {G with sum: H, count: int}, values: [H]) => {sum: H, count: int}, + init: (values: [F]) => {sum: F, count: int}, + fill: B, + compute: (state: {C with sum: E, count: D}) => float, + column: A, +} where F: Numeric, H: Addable + Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### column + +Name of the column to aggregate. + + + +### fill + +When set, value to replace missing values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/min.md b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/min.md new file mode 100644 index 000000000..9a6e61cfa --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/min.md @@ -0,0 +1,63 @@ +--- +title: aggregate.min() function +description: > + `aggregate.min()` constructs a min aggregate or selector for the column. +menu: + flux_0_x_ref: + name: aggregate.min + parent: contrib/jsternberg/aggregate + identifier: contrib/jsternberg/aggregate/min +weight: 301 +--- + + + +`aggregate.min()` constructs a min aggregate or selector for the column. + + + +##### Function type signature + +```js +( + ?column: A, + ?fill: B, +) => { + reduce: (state: D, values: [D]) => D, + init: (values: [D]) => D, + fill: B, + compute: (state: C) => C, + column: A, +} where D: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### column + +Name of the column to aggregate. + + + +### fill + +When set, value to replace missing values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/sum.md b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/sum.md new file mode 100644 index 000000000..b4d7d1221 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/sum.md @@ -0,0 +1,63 @@ +--- +title: aggregate.sum() function +description: > + `aggregate.sum()` constructs a sum aggregate for the column. +menu: + flux_0_x_ref: + name: aggregate.sum + parent: contrib/jsternberg/aggregate + identifier: contrib/jsternberg/aggregate/sum +weight: 301 +--- + + + +`aggregate.sum()` constructs a sum aggregate for the column. + + + +##### Function type signature + +```js +( + ?column: A, + ?fill: B, +) => { + reduce: (state: E, values: [E]) => E, + init: (values: [D]) => D, + fill: B, + compute: (state: C) => C, + column: A, +} where D: Numeric, E: Addable + Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### column + +Name of the column to aggregate. + + + +### fill + +When set, value to replace missing values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/table.md b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/table.md new file mode 100644 index 000000000..d316cc10e --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/table.md @@ -0,0 +1,125 @@ +--- +title: aggregate.table() function +description: > + `aggregate.table()` will aggregate columns and create tables with a single + row containing the aggregated value. +menu: + flux_0_x_ref: + name: aggregate.table + parent: contrib/jsternberg/aggregate + identifier: contrib/jsternberg/aggregate/table +weight: 301 +--- + + + +`aggregate.table()` will aggregate columns and create tables with a single +row containing the aggregated value. + + + +##### Function type signature + +```js +(<-tables: stream[B], columns: A) => stream[C] where A: Record, B: Record, C: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + +### columns +({{< req >}}) +Columns to aggregate and which aggregate method to use. + +Columns is a record where the key is a column name and the value is an aggregate record. +The aggregate record is composed of at least the following required attributes: +- **column**: Input column name (string). +- **init**: A function to compute the initial state of the +output. This can return either the final aggregate or a +temporary state object that can be used to compute the +final aggregate. The `values` parameter will always be a +non-empty array of values from the specified column. +For example: `(values) => state`. +- **reduce**: A function that takes in another buffer of values +and the current state of the aggregate and computes +the updated state. +For example: `(values, state) => state`. +- **compute**: A function that takes the state and computes the final +aggregate. For example, `(state) => value`. +- **fill**: The value passed to `fill()`. If present, the fill value +determines what the aggregate does when there are no values. +This can either be a value or one of the predefined +identifiers of `null` or `none`. +This value must be the same type as the value return from +`compute`. + + +## Examples + +### Compute the min of a specific column + +```js +import "sampledata" +import "contrib/jsternberg/aggregate" + +sampledata.float() + |> aggregate.table(columns: {"min_bottom_degrees": aggregate.min(column: "_value")}) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| *tag | min_bottom_degrees | +| ---- | ------------------- | +| t1 | -2.18 | + +| *tag | min_bottom_degrees | +| ---- | ------------------- | +| t2 | -3.75 | + + +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/window.md b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/window.md new file mode 100644 index 000000000..8d91fc5c4 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/aggregate/window.md @@ -0,0 +1,84 @@ +--- +title: aggregate.window() function +description: > + `aggregate.window()` aggregates columns and create tables by + organizing incoming points into windows. +menu: + flux_0_x_ref: + name: aggregate.window + parent: contrib/jsternberg/aggregate + identifier: contrib/jsternberg/aggregate/window +weight: 301 +--- + + + +`aggregate.window()` aggregates columns and create tables by +organizing incoming points into windows. + +Each table will have two additional columns: start and stop. +These are the start and stop times for each interval. +It is not possible to use start or stop as destination column +names with this function. The start and stop columns are not +added to the group key. + +##### Function type signature + +```js +( + <-tables: stream[B], + columns: A, + every: duration, + ?period: duration, + ?time: string, +) => stream[C] where A: Record, B: Record, C: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + +### columns +({{< req >}}) +Columns to aggregate and which aggregate method to use. See `aggregate.table()` for details. + + + +### every +({{< req >}}) +Duration between the start of each interval. + + + +### time + +Column name for the time input. Defaults to `_time` or `time` (whichever is earlier in the list of columns). + + + +### period + +Length of the interval. Defaults to the `every` duration. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/_index.md b/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/_index.md index d56d2878b..eba40f6a2 100644 --- a/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/_index.md +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/_index.md @@ -1,27 +1,44 @@ --- -title: Flux influxdb package (contributed) -list_title: influxdb package +title: influxdb package description: > - The Flux `influxdb` package provides additional functions for querying data from InfluxDB. - Import the `contrib/jsternberg/influxdb` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/influxdb/ - - /influxdb/cloud/reference/flux/stdlib/contrib/influxdb/ + The `influxdb` package provides additional functions for querying data from InfluxDB. menu: flux_0_x_ref: - name: influxdb - identifier: contrib_influxdb - parent: jsternberg -weight: 201 -flux/v0.x/tags: [functions, package, query] -introduced: 0.77.0 + name: influxdb + parent: contrib/jsternberg + identifier: contrib/jsternberg/influxdb +weight: 31 +cascade: + + introduced: 0.77.0 --- -The Flux `influxdb` package provides additional functions for querying data from InfluxDB. + + +The `influxdb` package provides additional functions for querying data from InfluxDB. Import the `contrib/jsternberg/influxdb` package: ```js import "contrib/jsternberg/influxdb" ``` + + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/from.md b/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/from.md new file mode 100644 index 000000000..c01e18e50 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/from.md @@ -0,0 +1,137 @@ +--- +title: from() function +description: > + `from()` retrieves data from an InfluxDB bucket between the `start` and `stop` times. +menu: + flux_0_x_ref: + name: from + parent: contrib/jsternberg/influxdb + identifier: contrib/jsternberg/influxdb/from +weight: 301 +flux/v0.x/tags: [inputs] +--- + + + +`from()` retrieves data from an InfluxDB bucket between the `start` and `stop` times. + +This version of `from` is equivalent to `from() |> range()` in a single call. + +##### Function type signature + +```js +( + bucket: string, + start: A, + ?host: string, + ?org: string, + ?stop: B, + ?token: string, +) => stream[{ + C with + _value: D, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, +}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### bucket +({{< req >}}) +Name of the bucket to query. + +**InfluxDB 1.x or Enterprise**: Provide an empty string (`""`). + +### start +({{< req >}}) +Earliest time to include in results. + +Results include points that match the specified start time. +Use a relative duration, absolute time, or integer (Unix timestamp in seconds). +For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. +Durations are relative to `now()`. + +### stop + +Latest time to include in results. Default is `now()`. + +Results exclude points that match the specified stop time. +Use a relative duration, absolute time, or integer (Unix timestamp in seconds). +For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. +Durations are relative to `now()`. + +### host + +URL of the InfluxDB instance to query. + +See [InfluxDB OSS URLs](https://docs.influxdata.com/influxdb/latest/reference/urls/) +or [InfluxDB Cloud regions](https://docs.influxdata.com/influxdb/cloud/reference/regions/). + +### org + +Organization name. + + + +### token + +InfluxDB [API token](https://docs.influxdata.com/influxdb/latest/security/tokens/). + + + + +## Examples + +- [Query using the bucket name](#query-using-the-bucket-name) +- [Query using the bucket ID](#query-using-the-bucket-id) +- [Query a remote InfluxDB Cloud instance](#query-a-remote-influxdb-cloud-instance) + +### Query using the bucket name + +```js +import "contrib/jsternberg/influxdb" + +influxdb.from(bucket: "example-bucket") +``` + + +### Query using the bucket ID + +```js +import "contrib/jsternberg/influxdb" + +influxdb.from(bucketID: "0261d8287f4d6000") +``` + + +### Query a remote InfluxDB Cloud instance + +```js +import "contrib/jsternberg/influxdb" +import "influxdata/influxdb/secrets" + +token = secrets.get(key: "INFLUXDB_CLOUD_TOKEN") + +from(bucket: "example-bucket", host: "https://us-west-2-1.aws.cloud2.influxdata.com", org: "example-org", token: token) +``` + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/select.md b/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/select.md index 9d5f7b754..f5747219e 100644 --- a/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/select.md +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/influxdb/select.md @@ -1,102 +1,137 @@ --- title: influxdb.select() function description: > - The `influxdb.select()` function is an alternate implementation of `from()`, `range()`, `filter()` - and `pivot()` that returns pivoted query results and masks the `_start` and `_stop` column - Results are similar to those returned by InfluxQL `SELECT` statements. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/influxdb/select/ - - /influxdb/cloud/reference/flux/stdlib/contrib/influxdb/select/ + `influxdb.select()` is an alternate implementation of `from()`, + `range()`, `filter()` and `pivot()` that returns pivoted query results and masks + the `_measurement`, `_start`, and `_stop` columns. Results are similar to those + returned by InfluxQL `SELECT` statements. menu: flux_0_x_ref: name: influxdb.select - parent: contrib_influxdb + parent: contrib/jsternberg/influxdb + identifier: contrib/jsternberg/influxdb/select weight: 301 flux/v0.x/tags: [inputs] -related: - - /flux/v0.x/stdlib/influxdata/influxdb/from/ - - /flux/v0.x/stdlib/universe/range/ - - /flux/v0.x/stdlib/universe/filter/ - - /flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols/ - - /flux/v0.x/stdlib/universe/pivot/ -introduced: 0.77.0 --- -The `influxdb.select()` function is an alternate implementation of `from()`, `range()`, `filter()` -and `pivot()` that returns pivoted query results and masks the `_measurement`, `_start`, and `_stop` columns. -Results are similar to those returned by InfluxQL `SELECT` statements. + + +`influxdb.select()` is an alternate implementation of `from()`, +`range()`, `filter()` and `pivot()` that returns pivoted query results and masks +the `_measurement`, `_start`, and `_stop` columns. Results are similar to those +returned by InfluxQL `SELECT` statements. + + + +##### Function type signature ```js -import "contrib/jsternberg/influxdb" - -influxdb.select( - from: "example-bucket", - start: -1d, - stop: now(), - m: "example-measurement", - fields: [], - where: (r) => true, - host: "https://example.com", - org: "example-org", - token: "MySuP3rSecr3Tt0k3n", -) +( + from: string, + m: A, + start: B, + ?fields: [string], + ?host: string, + ?org: string, + ?stop: C, + ?token: string, + ?where: ( + r: { + D with + _value: E, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, +) => stream[F] where A: Equatable, F: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -{{% note %}} -[host](#host), [org](#org), and [token](#token) parameters are only required when -querying data from a **different organization** or a **remote InfluxDB instance**. -{{% /note %}} +### from +({{< req >}}) +Name of the bucket to query. -### from {data-type="string"} -({{< req >}}) Name of the bucket to query. -### start {data-type="duration, time, int"} -({{< req >}}) Earliest time to include in results. -Results **include** points that match the specified start time. + +### start +({{< req >}}) +Earliest time to include in results. + +Results include points that match the specified start time. Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -### stop {data-type="duration, time, int"} -Latest time to include in results. -Results **exclude** points that match the specified stop time. +### stop + +Latest time to include in results. Default is `now()`. + +Results exclude points that match the specified stop time. Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -Defaults to `now()`. +### m +({{< req >}}) +Name of the measurement to query. -### m {data-type="string"} -({{< req >}}) Name of the measurement to query. -### fields {data-type="array of strings"} -List of fields to query. -Returns all fields when list is empty or unspecified. -Defaults to `[]`. -### where {data-type="function"} -A single argument predicate function that evaluates true or false and filters results based on tag values. -Records are passed to the function **before fields are pivoted into columns**. -Records that evaluate to true are included in the output tables. -Records that evaluate to _null_ or false are not included in the output tables. -Defaults to `(r) => true`. +### fields -{{% note %}} -Records evaluated in `fn` functions are represented by `r`, short for "record" or "row". -{{% /note %}} +List of fields to query. Default is`[]`. + +_Returns all fields when list is empty or unspecified._ + +### where + +Single argument predicate function that evaluates `true` or `false` +and filters results based on tag values. +Default is `(r) => true`. + +Records are passed to the function before fields are pivoted into columns. +Records that evaluate to `true` are included in the output tables. +Records that evaluate to _null_ or `false` are not included in the output tables. + +### host -### host {data-type="string"} URL of the InfluxDB instance to query. -_See [InfluxDB URLs](/{{< latest "influxdb" >}}/reference/urls/) -or [InfluxDB Cloud regions](/{{< latest "influxdb" >}}/reference/regions/)._ -### org {data-type="string"} +See [InfluxDB OSS URLs](https://docs.influxdata.com/influxdb/latest/reference/urls/) +or [InfluxDB Cloud regions](https://docs.influxdata.com/influxdb/cloud/reference/regions/). + +### org + Organization name. -### token {data-type="string"} -InfluxDB [API token](/{{< latest "influxdb" >}}/security/tokens/). + + +### token + +InfluxDB [API token](https://docs.influxdata.com/influxdb/latest/security/tokens/). + + + ## Examples @@ -105,21 +140,26 @@ InfluxDB [API token](/{{< latest "influxdb" >}}/security/tokens/). - [Query all fields and filter by tags](#query-all-fields-and-filter-by-tags) - [Query data from a remote InfluxDB Cloud instance](#query-data-from-a-remote-influxdb-cloud-instance) -##### Query a single field +### Query a single field + ```js import "contrib/jsternberg/influxdb" influxdb.select(from: "example-bucket", start: -1d, m: "example-measurement", fields: ["field1"]) ``` -##### Query multiple fields + +### Query multiple fields + ```js import "contrib/jsternberg/influxdb" influxdb.select(from: "example-bucket", start: -1d, m: "example-measurement", fields: ["field1", "field2", "field3"]) ``` -##### Query all fields and filter by tags + +### Query all fields and filter by tags + ```js import "contrib/jsternberg/influxdb" @@ -131,7 +171,9 @@ influxdb.select( ) ``` -##### Query data from a remote InfluxDB Cloud instance + +### Query data from a remote InfluxDB Cloud instance + ```js import "contrib/jsternberg/influxdb" import "influxdata/influxdb/secrets" @@ -143,8 +185,9 @@ influxdb.select( start: -1d, m: "example-measurement", fields: ["field1", "field2"], - host: "https://cloud2.influxdata.com", + host: "https://us-west-2-1.aws.cloud2.influxdata.com", org: "example-org", token: token, ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/math/_index.md b/content/flux/v0.x/stdlib/contrib/jsternberg/math/_index.md new file mode 100644 index 000000000..03fa42540 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/math/_index.md @@ -0,0 +1,41 @@ +--- +title: math package +description: > + The `math` package provides implementations of aggregate functions. +menu: + flux_0_x_ref: + name: math + parent: contrib/jsternberg + identifier: contrib/jsternberg/math +weight: 31 +--- + + + +The `math` package provides implementations of aggregate functions. +Import the `contrib/jsternberg/math` package: + +```js +import "contrib/jsternberg/math" +``` + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/math/max.md b/content/flux/v0.x/stdlib/contrib/jsternberg/math/max.md new file mode 100644 index 000000000..b4275bfaf --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/math/max.md @@ -0,0 +1,48 @@ +--- +title: math.max() function +description: > + `math.max()` returns the maximum value within the array. +menu: + flux_0_x_ref: + name: math.max + parent: contrib/jsternberg/math + identifier: contrib/jsternberg/math/max +weight: 301 +--- + + + +`math.max()` returns the maximum value within the array. + + + +##### Function type signature + +```js +(values: [A]) => A where A: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### values +({{< req >}}) +Array of values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/math/maxindex.md b/content/flux/v0.x/stdlib/contrib/jsternberg/math/maxindex.md new file mode 100644 index 000000000..c0e95e35b --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/math/maxindex.md @@ -0,0 +1,48 @@ +--- +title: math.maxIndex() function +description: > + `math.maxIndex()` returns the index of the maximum value within the array. +menu: + flux_0_x_ref: + name: math.maxIndex + parent: contrib/jsternberg/math + identifier: contrib/jsternberg/math/maxIndex +weight: 301 +--- + + + +`math.maxIndex()` returns the index of the maximum value within the array. + + + +##### Function type signature + +```js +(values: [A]) => int where A: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### values +({{< req >}}) +Array of values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/math/min.md b/content/flux/v0.x/stdlib/contrib/jsternberg/math/min.md new file mode 100644 index 000000000..a9adffe77 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/math/min.md @@ -0,0 +1,48 @@ +--- +title: math.min() function +description: > + `math.min()` returns the minimum value within the array. +menu: + flux_0_x_ref: + name: math.min + parent: contrib/jsternberg/math + identifier: contrib/jsternberg/math/min +weight: 301 +--- + + + +`math.min()` returns the minimum value within the array. + + + +##### Function type signature + +```js +(values: [A]) => A where A: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### values +({{< req >}}) +Array of values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/math/minindex.md b/content/flux/v0.x/stdlib/contrib/jsternberg/math/minindex.md new file mode 100644 index 000000000..0758b4cf8 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/math/minindex.md @@ -0,0 +1,48 @@ +--- +title: math.minIndex() function +description: > + `math.minIndex()` returns the index of the minimum value within the array. +menu: + flux_0_x_ref: + name: math.minIndex + parent: contrib/jsternberg/math + identifier: contrib/jsternberg/math/minIndex +weight: 301 +--- + + + +`math.minIndex()` returns the index of the minimum value within the array. + + + +##### Function type signature + +```js +(values: [A]) => int where A: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### values +({{< req >}}) +Array of values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/jsternberg/math/sum.md b/content/flux/v0.x/stdlib/contrib/jsternberg/math/sum.md new file mode 100644 index 000000000..2e96ed7b1 --- /dev/null +++ b/content/flux/v0.x/stdlib/contrib/jsternberg/math/sum.md @@ -0,0 +1,48 @@ +--- +title: math.sum() function +description: > + `math.sum()` returns the sum of all values within the array. +menu: + flux_0_x_ref: + name: math.sum + parent: contrib/jsternberg/math + identifier: contrib/jsternberg/math/sum +weight: 301 +--- + + + +`math.sum()` returns the sum of all values within the array. + + + +##### Function type signature + +```js +(values: [A]) => A where A: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### values +({{< req >}}) +Array of values. + + + diff --git a/content/flux/v0.x/stdlib/contrib/rhajek/_index.md b/content/flux/v0.x/stdlib/contrib/rhajek/_index.md index 6968be517..88d1c415f 100644 --- a/content/flux/v0.x/stdlib/contrib/rhajek/_index.md +++ b/content/flux/v0.x/stdlib/contrib/rhajek/_index.md @@ -1,26 +1,36 @@ --- -title: Packages contributed by rhajek -list_title: rhajek package +title: rhajek package description: > - The `rhajek` package contains functions and packages contributed by - [@rhajek](https://github.com/rhajek). + The `rhajek` package contains packages and functions contributed by [@rhajek](https://github.com/rhajek). menu: flux_0_x_ref: - name: rhajek + name: rhajek parent: contrib -weight: 101 -introduced: 0.108.0 -cascade: - append: - block: note - content: | - #### Package author and maintainer - **Github:** [@rhajek](https://github.com/rhajek), [@bonitoo-io](https://github.com/bonitoo-io) + identifier: contrib/rhajek +weight: 21 --- -The `rhajek` package contains functions and packages contributed by -[@rhajek](https://github.com/rhajek). + + +The `rhajek` package contains packages and functions contributed by [@rhajek](https://github.com/rhajek). + + + ## Packages -{{< children >}} \ No newline at end of file +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/_index.md b/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/_index.md index 20e1ab368..01b40ef03 100644 --- a/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/_index.md +++ b/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/_index.md @@ -1,58 +1,64 @@ --- -title: Flux bigpanda package -list_title: bigpanda package +title: bigpanda package description: > - The Flux `bigpanda` package provides functions that send alerts to - [BigPanda](https://www.bigpanda.io/). + The `bigpanda` package provides functions for sending alerts to [BigPanda](https://www.bigpanda.io/). menu: flux_0_x_ref: - name: bigpanda - parent: rhajek -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/ - - /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/ -flux/v0.x/tags: [functions, bigpanda, package] + name: bigpanda + parent: contrib/rhajek + identifier: contrib/rhajek/bigpanda +weight: 31 --- -The Flux `bigpanda` package provides functions that send alerts to -[BigPanda](https://www.bigpanda.io/). + + +The `bigpanda` package provides functions for sending alerts to [BigPanda](https://www.bigpanda.io/). Import the `contrib/rhajek/bigpanda` package: ```js import "contrib/rhajek/bigpanda" ``` -## Options -The BigPanda package provides the following options: -- [defaultURL](#defaulturl) -- [defaultTokenPrefix](#defaulttokenprefix) + +## Options ```js -import "contrib/rhajek/bigpanda" +option bigpanda.defaultTokenPrefix = "Bearer" option bigpanda.defaultUrl = "https://api.bigpanda.io/data/v2/alerts" -option bigpanda.defaultTokenPrefix = "Bearer" ``` + +### defaultTokenPrefix -### defaultUrl {data-type="string"} -The default [BigPanda alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works) -for functions in the BigPanda package. -Default is `https://api.bigpanda.io/data/v2/alerts`. - -### defaultTokenPrefix {data-type="string"} -The default HTTP authentication schema to use when authenticating with BigPanda. +`defaultTokenPrefix` is the default HTTP authentication scheme to use when authenticating with BigPanda. Default is `Bearer`. + + +### defaultUrl + +`defaultUrl` is the default [BigPanda alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works) +for functions in the `bigpanda` package. +Default is `https://api.bigpanda.io/data/v2/alerts`. + + + + ## Functions + {{< children type="functions" show="pages" >}} - -## Send alert timestamps to BigPanda -Sending alert timestamps to BigPanda is optional, but if you choose to send them, -convert timestamps to **epoch second timestamps**: - -```js -data - |> map(fn: (r) => ({ r with secTime: int(v: r._time) / 1000000000 })) -``` diff --git a/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/endpoint.md b/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/endpoint.md index 172259413..4fb520d32 100644 --- a/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/endpoint.md @@ -1,87 +1,65 @@ --- title: bigpanda.endpoint() function description: > - The `bigpanda.endpoint()` function sends alerts to BigPanda using data from input rows. + `bigpanda.endpoint()` sends alerts to BigPanda using data from input rows. menu: flux_0_x_ref: name: bigpanda.endpoint - parent: bigpanda -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/endpoint/ -flux/v0.x/tags: [notification endpoints] -introduced: 0.108.0 + parent: contrib/rhajek/bigpanda + identifier: contrib/rhajek/bigpanda/endpoint +weight: 301 --- -The `bigpanda.endpoint()` function sends alerts to [BigPanda](https://www.bigpanda.io/) -using data from input rows. + + +`bigpanda.endpoint()` sends alerts to BigPanda using data from input rows. + + + +##### Function type signature ```js -import "contrib/rhajek/bigpanda" - -bigpanda.endpoint( - url: "https://api.bigpanda.io/data/v2/alerts", - token: "my5uP3rS3cRe7t0k3n", - appKey: "example-app-key", -) +( + appKey: A, + token: string, + ?url: string, +) => (mapFn: (r: B) => {C with status: D}) => (<-tables: stream[B]) => stream[{B with _sent: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -BigPanda [alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works). -Default is the value of the [`bigpanda.defaultURL` option](/flux/v0.x/stdlib/contrib/rhajek/bigpanda/#defaulturl). +### url -### token {data-type="string"} +BigPanda [alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works). +Default is the value of the `bigpanda.defaultURL` option. + + + +### token ({{< req >}}) BigPanda [API Authorization token (API key)](https://docs.bigpanda.io/docs/api-key-management). -### appKey {data-type="string"} + + +### appKey ({{< req >}}) BigPanda [App Key](https://docs.bigpanda.io/reference#integrating-monitoring-systems). -## Usage -`bigpanda.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. -### mapFn {data-type="function"} -A function that builds the object used to generate the POST request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns an object that must include the -following fields: - -- `status` -- Additional [alert parameters](https://docs.bigpanda.io/reference#alert-object) - to send to the BigPanda alert API. - -_For more information, see [`bigpanda.sendAlert()` parameters](/flux/v0.x/stdlib/contrib/rhajek/bigpanda/sendalert/#parameters)._ - -## Examples - -##### Send critical alerts to BigPanda -```js -import "contrib/rhajek/bigpanda" -import "influxdata/influxdb/secrets" -import "json" - -token = secrets.get(key: "BIGPANDA_API_KEY") -endpoint = bigpanda.endpoint(token: token, appKey: "example-app-key") - -crit_events = - from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") - -crit_events - |> endpoint( - mapFn: (r) => { - return {r with status: "critical", - check: "critical-status-check", - description: "${r._field} is critical: ${string(v: r._value)}", - tags: json.encode(v: [{"name": "host", "value": r.host}]), - } - }, - )() -``` diff --git a/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/sendalert.md b/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/sendalert.md index 75e3f466a..a09d42395 100644 --- a/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/sendalert.md +++ b/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/sendalert.md @@ -1,65 +1,92 @@ --- title: bigpanda.sendAlert() function description: > - The `bigpanda.sendAlert()` function sends an alert to BigPanda. + `bigpanda.sendAlert()` sends an alert to [BigPanda](https://www.bigpanda.io/). menu: flux_0_x_ref: name: bigpanda.sendAlert - parent: bigpanda -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/sendAlert/ - - /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/sendAlert/ -introduced: 0.108.0 + parent: contrib/rhajek/bigpanda + identifier: contrib/rhajek/bigpanda/sendAlert +weight: 301 +flux/v0.x/tags: [single notification] --- -The `bigpanda.sendAlert()` function sends an alert to [BigPanda](https://www.bigpanda.io/). + + +`bigpanda.sendAlert()` sends an alert to [BigPanda](https://www.bigpanda.io/). + + + +##### Function type signature ```js -import "contrib/rhajek/bigpanda" - -bigpanda.sendAlert( - url: "https://api.bigpanda.io/data/v2/alerts", - token: "my5uP3rS3cRe7t0k3n", - appKey: "example-app-key", - status: "critical", - rec: {}, -) +( + appKey: A, + rec: B, + status: C, + token: string, + url: string, +) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url +({{< req >}}) BigPanda [alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works). -Default is the value of the [`bigpanda.defaultURL` option](/flux/v0.x/stdlib/contrib/rhajek/bigpanda/#defaulturl). +Default is the value of the `bigpanda.defaultURL` option. -### token {data-type="string"} + + +### token ({{< req >}}) BigPanda [API Authorization token (API key)](https://docs.bigpanda.io/docs/api-key-management). -### appKey {data-type="string"} + + +### appKey ({{< req >}}) BigPanda [App Key](https://docs.bigpanda.io/reference#integrating-monitoring-systems). -### status {data-type="string"} + + +### status ({{< req >}}) BigPanda [alert status](https://docs.bigpanda.io/reference#alerts). -**Supported statuses:** - +Supported statuses: - `ok` - `critical` - `warning` - `acknowledged` -### rec {data-type="record"} +### rec ({{< req >}}) -Additional [alert parameters](https://docs.bigpanda.io/reference#alert-object) -to send to the BigPanda alert API. +Additional [alert parameters](https://docs.bigpanda.io/reference#alert-object) to send to the BigPanda alert API. + + + ## Examples -##### Send the last reported value and status to BigPanda +### Send the last reported value and status to BigPanda + ```js import "contrib/rhajek/bigpanda" import "influxdata/influxdb/secrets" @@ -85,3 +112,4 @@ bigpanda.sendAlert( }, ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/statusfromlevel.md b/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/statusfromlevel.md index 3a32d2fc7..31418cfd4 100644 --- a/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/statusfromlevel.md +++ b/content/flux/v0.x/stdlib/contrib/rhajek/bigpanda/statusfromlevel.md @@ -1,41 +1,106 @@ --- title: bigpanda.statusFromLevel() function description: > - The `bigpanda.statusFromLevel()` function converts an alert level into a BigPanda status. + `bigpanda.statusFromLevel()` converts an alert level to a BigPanda status. menu: flux_0_x_ref: name: bigpanda.statusFromLevel - parent: bigpanda -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/statusfromlevel/ - - /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/statusfromlevel/ -introduced: 0.108.0 + parent: contrib/rhajek/bigpanda + identifier: contrib/rhajek/bigpanda/statusFromLevel +weight: 301 --- -The `bigpanda.statusFromLevel()` function converts an alert level into a BigPanda status. + + +`bigpanda.statusFromLevel()` converts an alert level to a BigPanda status. + +BigPanda accepts one of ok, warning, or critical,. + +##### Function type signature ```js -import "contrib/rhajek/bigpanda" - -bigpanda.statusFromLevel(level: "crit") - -// Returns "critical" +(level: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### level {data-type="string"} +### level ({{< req >}}) Alert level. ##### Supported alert levels - | Alert level | BigPanda status | -|:-----------:|:---------------:| +| :---------- | :--------------| | crit | critical | | warn | warning | | info | ok | | ok | ok | - _All other alert levels return a `critical` BigPanda status._ + + +## Examples + +- [Convert an alert level to a BigPanda status](#convert-an-alert-level-to-a-bigpanda-status) +- [Convert alert levels in a stream of tables to BigPanda statuses](#convert-alert-levels-in-a-stream-of-tables-to-bigpanda-statuses) + +### Convert an alert level to a BigPanda status + +```js +import "contrib/rhajek/bigpanda" + +bigpanda.statusFromLevel(level: "crit")// Returns "critical" + +``` + + +### Convert alert levels in a stream of tables to BigPanda statuses + +Use `map()` to iterate over rows in a stream of tables and convert alert levels to Big Panda statuses. + +```js +import "contrib/rhajek/bigpanda" + +data + |> map(fn: (r) => ({r with big_panda_status: bigpanda.statusFromLevel(level: r._level)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _level | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | ok | +| 2021-01-01T00:01:00Z | info | +| 2021-01-01T00:02:00Z | warn | +| 2021-01-01T00:03:00Z | crit | + + +#### Output data + +| _level | _time | big_panda_status | +| ------- | -------------------- | ----------------- | +| ok | 2021-01-01T00:00:00Z | ok | +| info | 2021-01-01T00:01:00Z | ok | +| warn | 2021-01-01T00:02:00Z | warning | +| crit | 2021-01-01T00:03:00Z | critical | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/contrib/sranka/_index.md b/content/flux/v0.x/stdlib/contrib/sranka/_index.md index d1206023b..b28ea16ef 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/_index.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/_index.md @@ -1,27 +1,36 @@ --- -title: Packages contributed by sranka -list_title: sranka package +title: sranka package description: > - The `sranka` package contains functions and packages contributed by - [@sranka](https://github.com/sranka). + The `sranka` package contains packages and functions contributed by [@sranka](https://github.com/sranka). menu: flux_0_x_ref: - name: sranka + name: sranka parent: contrib -weight: 101 -introduced: 0.70.0 -cascade: - append: - block: note - content: | - #### Package author and maintainer - **Github:** [@sranka](https://github.com/sranka) - **InfluxDB Slack:** [@sranka](https://influxdata.com/slack) + identifier: contrib/sranka +weight: 21 --- -The `sranka` package contains functions and packages contributed by -[@sranka](https://github.com/sranka). + + +The `sranka` package contains packages and functions contributed by [@sranka](https://github.com/sranka). + + + ## Packages -{{< children >}} \ No newline at end of file +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/_index.md b/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/_index.md index efe586bf8..926e85a2d 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/_index.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/_index.md @@ -1,30 +1,48 @@ --- -title: Flux opsgenie package -list_title: opsgenie package +title: opsgenie package description: > - The Flux `opsgenie` package provides functions that send alerts to - [Atlassian Opsgenie](https://www.atlassian.com/software/opsgenie) using the - [Opsgenie v2 API](https://docs.opsgenie.com/docs/alert-api#create-alert). - Import the `contrib/sranka/opsgenie` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/opsgenie/ - - /influxdb/cloud/reference/flux/stdlib/contrib/opsgenie/ + The `opsgenie` package provides functions that send alerts to + [Atlassian Opsgenie](https://www.atlassian.com/software/opsgenie) + using the [Opsgenie v2 API](https://docs.opsgenie.com/docs/alert-api#create-alert). menu: flux_0_x_ref: - name: opsgenie - parent: sranka -weight: 201 -flux/v0.x/tags: [functions, opsgenie, package] -introduced: 0.84.0 + name: opsgenie + parent: contrib/sranka + identifier: contrib/sranka/opsgenie +weight: 31 +cascade: + + introduced: 0.84.0 --- -The Flux `opsgenie` package provides functions that send alerts to -[Atlassian Opsgenie](https://www.atlassian.com/software/opsgenie) using the -[Opsgenie v2 API](https://docs.opsgenie.com/docs/alert-api#create-alert). + + +The `opsgenie` package provides functions that send alerts to +[Atlassian Opsgenie](https://www.atlassian.com/software/opsgenie) +using the [Opsgenie v2 API](https://docs.opsgenie.com/docs/alert-api#create-alert). Import the `contrib/sranka/opsgenie` package: ```js import "contrib/sranka/opsgenie" ``` + + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/endpoint.md b/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/endpoint.md index 5952e1bf3..1280b53e2 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/endpoint.md @@ -1,96 +1,79 @@ --- title: opsgenie.endpoint() function description: > - The `opsgenie.endpoint()` function sends an alert message to Opsgenie using data from table rows. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/opsgenie/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/opsgenie/endpoint/ + `opsgenie.endpoint()` sends an alert message to Opsgenie using data from table rows. menu: flux_0_x_ref: name: opsgenie.endpoint - parent: opsgenie + parent: contrib/sranka/opsgenie + identifier: contrib/sranka/opsgenie/endpoint weight: 301 -flux/v0.x/tags: [notification endpoints] -introduced: 0.84.0 --- -The `opsgenie.endpoint()` function sends an alert message to Opsgenie using data from table rows. + + +`opsgenie.endpoint()` sends an alert message to Opsgenie using data from table rows. + + + +##### Function type signature ```js -import "contrib/sranka/opsgenie" - -opsgenie.endpoint( - url: "https://api.opsgenie.com/v2/alerts", - apiKey: "YoUrSup3R5ecR37AuThK3y", - entity: "example-entity", -) +( + apiKey: string, + ?entity: string, + ?url: string, +) => ( + mapFn: ( + r: A, + ) => { + B with + visibleTo: [string], + tags: E, + responders: [string], + priority: string, + message: string, + details: D, + description: string, + alias: string, + actions: C, + }, +) => (<-tables: stream[A]) => stream[{A with _sent: string}] where D: Stringable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -Opsgenie API URL. -Defaults to `https://api.opsgenie.com/v2/alerts`. +### url -### apiKey {data-type="string"} +Opsgenie API URL. Defaults to `https://api.opsgenie.com/v2/alerts`. + + + +### apiKey ({{< req >}}) -Opsgenie API authorization key. +(Required) Opsgenie API authorization key. + + + +### entity -### entity {data-type="string"} Alert entity used to specify the alert domain. -## Usage -`opsgenie.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. -### mapFn {data-type="function"} -A function that builds the record used to generate the POST request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns a record that must include the -following fields: - -- `message` -- `alias` -- `description` -- `priority` -- `responders` -- `tags` -- `actions` -- `details` -- `visibleTo` - -_For more information, see [`opsgenie.sendAlert()`](/flux/v0.x/stdlib/contrib/sranka/opsgenie/sendalert/)._ - -## Examples - -##### Send critical statuses to Opsgenie -```js -import "influxdata/influxdb/secrets" -import "contrib/sranka/opsgenie" - -apiKey = secrets.get(key: "OPSGENIE_APIKEY") -endpoint = opsgenie.endpoint(apiKey: apiKey) - -crit_statuses = - from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") - -crit_statuses - |> endpoint( - mapFn: (r) => - ({ - message: "Great Scott!- Disk usage is: ${r.status}.", - alias: "disk-usage-${r.status}", - description: "", - priority: "P3", - responders: ["user:john@example.com", "team:itcrowd"], - tags: [], - entity: "my-lab", - actions: [], - details: "{}", - visibleTo: [], - }), - )() -``` diff --git a/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/responderstojson.md b/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/responderstojson.md index 95d24afa3..d4502da91 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/responderstojson.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/responderstojson.md @@ -1,40 +1,52 @@ --- title: opsgenie.respondersToJSON() function description: > - The `opsgenie.respondersToJSON()` function converts an array of - [Opsgenie responder](https://docs.opsgenie.com/docs/alert-recipients-and-teams) - strings to a string-encoded JSON array that can be embedded in an alert message. + `opsgenie.respondersToJSON()` converts an array of Opsgenie responder strings + to a string-encoded JSON array that can be embedded in an alert message. menu: flux_0_x_ref: name: opsgenie.respondersToJSON - parent: opsgenie + parent: contrib/sranka/opsgenie + identifier: contrib/sranka/opsgenie/respondersToJSON weight: 301 -introduced: 0.84.0 --- -The `opsgenie.respondersToJSON()` function converts an array of -[Opsgenie responder](https://docs.opsgenie.com/docs/alert-recipients-and-teams) -strings to a string-encoded JSON array that can be embedded in an alert message. + + +`opsgenie.respondersToJSON()` converts an array of Opsgenie responder strings +to a string-encoded JSON array that can be embedded in an alert message. + + + +##### Function type signature ```js -import "contrib/sranka/opsgenie" - -import "contrib/sranka/opsgenie" - -opsgenie.respondersToJSON( - v: ["user:example-user", "team:example-team", "escalation:example-escalation", "schedule:example-schedule"], -) - -// Returns "[ -// {"type":"user","username":"example-user"}, -// {"type":"team","name":"example-team"}, -// {"type":"escalation","name":"example-escalation"}, -// {"type":"schedule","name":"example-schedule"} -// ]" +(v: [string]) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="array of strings"} -({{< req >}}) Array of Opsgenie responder strings. -Responder strings must begin with `user:`, `team:`, `escalation:`, or `schedule:`. +### v +({{< req >}}) +(Required) Array of Opsgenie responder strings. +Responder strings must begin with +`user: `, `team: `, `escalation: `, or `schedule: `. + + + diff --git a/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/sendalert.md b/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/sendalert.md index 7e6581476..7d026c9d4 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/sendalert.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/opsgenie/sendalert.md @@ -1,97 +1,146 @@ --- title: opsgenie.sendAlert() function description: > - The `opsgenie.sendAlert()` function sends an alert message to Opsgenie. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/opsgenie/sendalert/ - - /influxdb/cloud/reference/flux/stdlib/contrib/opsgenie/sendalert/ + `opsgenie.sendAlert()` sends an alert message to Opsgenie. menu: flux_0_x_ref: name: opsgenie.sendAlert - parent: opsgenie + parent: contrib/sranka/opsgenie + identifier: contrib/sranka/opsgenie/sendAlert weight: 301 -introduced: 0.84.0 +flux/v0.x/tags: [single notification] --- -The `opsgenie.sendAlert()` function sends an alert message to Opsgenie. + + +`opsgenie.sendAlert()` sends an alert message to Opsgenie. + + + +##### Function type signature ```js -import "contrib/sranka/opsgenie" - -opsgenie.sendAlert( - url: "https://api.opsgenie.com/v2/alerts", - apiKey: "YoUrSup3R5ecR37AuThK3y", - message: "Example message", - alias: "Example alias", - description: "Example description", - priority: "P3", - responders: ["user:john@example.com", "team:itcrowd"], - tags: ["tag1", "tag2"], - entity: "example-entity", - actions: ["action1", "action2"], - details: "{}", - visibleTo: [], -) +( + apiKey: string, + message: string, + ?actions: A, + ?alias: string, + ?description: string, + ?details: B, + ?entity: string, + ?priority: string, + ?responders: [string], + ?tags: C, + ?url: string, + ?visibleTo: [string], +) => int where B: Stringable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -Opsgenie API URL. -Defaults to `https://api.opsgenie.com/v2/alerts`. +### url -### apiKey {data-type="string"} -({{< req >}}) -Opsgenie API authorization key. +Opsgenie API URL. Defaults to `https://api.opsgenie.com/v2/alerts`. -### message {data-type="string"} + + +### apiKey ({{< req >}}) -Alert message text. +(Required) Opsgenie API authorization key. + + + +### message +({{< req >}}) +(Required) Alert message text. 130 characters or less. -### alias {data-type="string"} + + +### alias + Opsgenie alias usee to de-deduplicate alerts. 250 characters or less. -Defaults to [message](#message). +Defaults to [message](https://docs.influxdata.com/flux/v0.x/stdlib/contrib/sranka/opsgenie/sendalert/#message). -### description {data-type="string"} -Alert description. -15000 characters or less. -### priority {data-type="string"} -Opsgenie [alert priority](https://docs.opsgenie.com/docs/alert-priority-settings). + +### description + +Alert description. 15000 characters or less. + + + +### priority + +Opsgenie alert priority. + Valid values include: - - `P1` - `P2` -- `P3` _(default)_ +- `P3` (default) - `P4` - `P5` -### responders {data-type="array of strings"} -List of responder teams or users. -Use the `user:` prefix for users and `teams:` prefix for teams. +### responders + +List of responder teams or users. +Use the `user: ` prefix for users and `teams: ` prefix for teams. + + + +### tags -### tags {data-type="array of strings"} Alert tags. -### entity {data-type="string"} + + +### entity + Alert entity used to specify the alert domain. -### actions {data-type="array of strings"} + + +### actions + List of actions available for the alert. -### details {data-type="string"} -Additional alert details. -Must be a JSON-encoded map of key-value string pairs. -### visibleTo {data-type="array of strings"} + +### details + +Additional alert details. Must be a JSON-encoded map of key-value string pairs. + + + +### visibleTo + List of teams and users the alert will be visible to without sending notifications. -Use the `user:` prefix for users and `teams:` prefix for teams. +Use the `user: ` prefix for users and `teams: ` prefix for teams. + + + ## Examples -##### Send the last reported status to a Opsgenie +### Send the last reported status to a Opsgenie + ```js import "influxdata/influxdb/secrets" import "contrib/sranka/opsgenie" @@ -112,3 +161,4 @@ opsgenie.sendAlert( responders: ["user:john@example.com", "team:itcrowd"], ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/sranka/sensu/_index.md b/content/flux/v0.x/stdlib/contrib/sranka/sensu/_index.md index 1efb0e73c..585ca8006 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/sensu/_index.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/sensu/_index.md @@ -1,35 +1,48 @@ --- -title: Flux sensu package -list_title: sensu package +title: sensu package description: > - The Flux `sensu` package provides functions for sending events to - [Sensu Go](https://docs.sensu.io/sensu-go/latest/). - Import the `contrib/sranka/sensu` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/sensu/ - - /influxdb/cloud/reference/flux/stdlib/contrib/sensu/ + The `sensu` package provides functions for sending events to [Sensu Go](https://docs.sensu.io/sensu-go/latest/). menu: flux_0_x_ref: - name: sensu - parent: sranka -weight: 201 -v2.0/tags: [functions, teams, sensu, package] -introduced: 0.90.0 + name: sensu + parent: contrib/sranka + identifier: contrib/sranka/sensu +weight: 31 +cascade: + + introduced: 0.90.0 --- -The Flux `sensu` package provides functions for sending events to -[Sensu Go](https://docs.sensu.io/sensu-go/latest/). + + +The `sensu` package provides functions for sending events to [Sensu Go](https://docs.sensu.io/sensu-go/latest/). Import the `contrib/sranka/sensu` package: ```js import "contrib/sranka/sensu" ``` -{{< children type="functions" show="pages" >}} - ## Sensu API Key authentication + The Flux Sensu package only supports [Sensu API key authentication](https://docs.sensu.io/sensu-go/latest/api/#authenticate-with-an-api-key). -All `sensu` functions require an `apiKey` parameter to successfully authenticate -with your Sensu service. -For information about managing Sensu API keys, see the -[Sensu APIKeys API documentation](https://docs.sensu.io/sensu-go/latest/api/apikeys/). +All `sensu` functions require an `apiKey` parameter to successfully authenticate with your Sensu service. +For information about managing Sensu API keys, see the [Sensu APIKeys API documentation](https://docs.sensu.io/sensu-go/latest/api/apikeys/). + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/sranka/sensu/endpoint.md b/content/flux/v0.x/stdlib/contrib/sranka/sensu/endpoint.md index a21529a3c..72fd61b03 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/sensu/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/sensu/endpoint.md @@ -1,98 +1,90 @@ --- title: sensu.endpoint() function description: > - The `sensu.endpoint()` function sends an event to the - [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event) + `sensu.endpoint()` sends an event + to the [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event) using data from table rows. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/sensu/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/sensu/endpoint/ menu: flux_0_x_ref: name: sensu.endpoint - parent: sensu + parent: contrib/sranka/sensu + identifier: contrib/sranka/sensu/endpoint weight: 301 -related: - - https://docs.sensu.io/sensu-go/latest/api/events/, Sensu Events API - - https://docs.sensu.io/sensu-go/latest/api/apikeys/, Sensu APIKeys API - - https://docs.sensu.io/sensu-go/latest/reference/handlers/, Sensu handlers -flux/v0.x/tags: [notification endpoints] -introduced: 0.90.0 --- -The `sensu.endpoint()` function sends an event to the -[Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event) + + +`sensu.endpoint()` sends an event +to the [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event) using data from table rows. -```js -import "contrib/sranka/sensu" -sensu.endpoint( - url: "http://localhost:8080", - apiKey: "mYSuP3rs3cREtApIK3Y", - handlers: [], - namespace: "default", - entityName: "influxdb", -) + +##### Function type signature + +```js +( + apiKey: string, + url: string, + ?entityName: string, + ?handlers: A, + ?namespace: string, +) => ( + mapFn: (r: B) => {C with text: E, status: D, checkName: string}, +) => (<-tables: stream[B]) => stream[{B with _sent: string}] where D: Equatable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url ({{< req >}}) Base URL of [Sensu API](https://docs.sensu.io/sensu-go/latest/migrate/#architecture) -**without a trailing slash**. Example: `http://localhost:8080`. +*without a trailing slash*. +Example: `http://localhost:8080`. -### apiKey {data-type="string"} + + +### apiKey ({{< req >}}) Sensu [API Key](https://docs.sensu.io/sensu-go/latest/operations/control-access/). -### handlers {data-type="array of strings"} + + +### handlers + [Sensu handlers](https://docs.sensu.io/sensu-go/latest/reference/handlers/) to execute. Default is `[]`. -### namespace {data-type="string"} + + +### namespace + [Sensu namespace](https://docs.sensu.io/sensu-go/latest/reference/rbac/). Default is `default`. -### entityName {data-type="string"} + + +### entityName + Event source. -Use alphanumeric characters, underscores (`_`), periods (`.`), and hyphens (`-`). -All other characters are replaced with an underscore. Default is `influxdb`. -## Usage -`sensu.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. +Use alphanumeric characters, underscores (`_`), periods (`.`), and hyphens (`-`). +All other characters are replaced with an underscore. -### mapFn {data-type="function"} -A function that builds the object used to generate the POST request. -Requires an `r` parameter. - -`mapFn` accepts a table row (`r`) and returns an object that must include the -following fields: - -- `checkName` -- `text` -- `status` - -_For more information, see [`sensu.event()` parameters](/v2.0/reference/flux/stdlib/contrib/sensu/event/#parameters)._ - -## Examples - -##### Send critical status events to Sensu -```js -import "influxdata/influxdb/secrets" -import "contrib/sranka/sensu" - -token = secrets.get(key: "TELEGRAM_TOKEN") -endpoint = sensu.endpoint(url: "http://localhost:8080", apiKey: apiKey) - -crit_statuses = - from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") - -crit_statuses - |> endpoint(mapFn: (r) => ({checkName: "critStatus", text: "Status is critical", status: 2}))() -``` diff --git a/content/flux/v0.x/stdlib/contrib/sranka/sensu/event.md b/content/flux/v0.x/stdlib/contrib/sranka/sensu/event.md index 6727c9b9b..7f6da0f54 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/sensu/event.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/sensu/event.md @@ -1,102 +1,130 @@ --- title: sensu.event() function description: > - The `sensu.event()` function sends a single event to the - [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event). -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/sensu/event/ - - /influxdb/cloud/reference/flux/stdlib/contrib/sensu/event/ + `sensu.event()` sends a single event to the [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event). menu: flux_0_x_ref: name: sensu.event - parent: sensu + parent: contrib/sranka/sensu + identifier: contrib/sranka/sensu/event weight: 301 -related: - - https://docs.sensu.io/sensu-go/latest/api/events/, Sensu Events API - - https://docs.sensu.io/sensu-go/latest/api/apikeys/, Sensu APIKeys API - - https://docs.sensu.io/sensu-go/latest/reference/handlers/, Sensu handlers -introduced: 0.90.0 +flux/v0.x/tags: [single notification] --- -The `sensu.event()` function sends a single event to the -[Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event). + + +`sensu.event()` sends a single event to the [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event). + + + +##### Function type signature ```js -import "contrib/sranka/sensu" - -sensu.event( - url: "http://localhost:8080", - apiKey: "mYSuP3rs3cREtApIK3Y", - checkName: "checkName", - text: "Event output text", - handlers: [], - status: 0, - state: "passing", - namespace: "default", - entityName: "influxdb", -) +( + apiKey: string, + checkName: string, + text: A, + url: string, + ?entityName: string, + ?handlers: B, + ?namespace: string, + ?state: string, + ?status: C, +) => int where C: Equatable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url ({{< req >}}) Base URL of [Sensu API](https://docs.sensu.io/sensu-go/latest/migrate/#architecture) -**without a trailing slash**. Example: `http://localhost:8080`. +without a trailing slash. -### apiKey {data-type="string"} +Example: `http://localhost:8080` + +### apiKey ({{< req >}}) Sensu [API Key](https://docs.sensu.io/sensu-go/latest/operations/control-access/). -### checkName {data-type="string"} + + +### checkName ({{< req >}}) Check name. + Use alphanumeric characters, underscores (`_`), periods (`.`), and hyphens (`-`). All other characters are replaced with an underscore. -### text {data-type="string"} +### text ({{< req >}}) Event text. + Mapped to `output` in the Sensu Events API request. -### handlers {data-type="array of strings"} -[Sensu handlers](https://docs.sensu.io/sensu-go/latest/reference/handlers/) to execute. -Default is `[]`. +### handlers -### status {data-type="int"} -Event status code that indicates [state](#state). +Sensu handlers to execute. Default is `[]`. + + + +### status + +Event status code that indicates [state](https://docs.influxdata.com/flux/v0.x/stdlib/contrib/sranka/sensu/event/#state). Default is `0`. | Status code | State | -|:----------- |:----- | -| `0` | OK | -| `1` | WARNING | -| `2` | CRITICAL | +| :-------------- | :---------------------- | +| 0 | OK | +| 1 | WARNING | +| 2 | CRITICAL | | Any other value | UNKNOWN or custom state | -### state {data-type="string"} +### state + Event state. -Default is `"passing"` for `0` [status](#status) and `"failing"` for other statuses. - -The following values are accepted: +Default is `"passing"` for `0` [status](https://docs.influxdata.com/flux/v0.x/stdlib/contrib/sranka/sensu/event/#status) and `"failing"` for other statuses. +**Accepted values**: - `"failing"` - `"passing"` - `"flapping"` -### namespace {data-type="string"} +### namespace + [Sensu namespace](https://docs.sensu.io/sensu-go/latest/reference/rbac/). Default is `"default"`. -### entityName {data-type="string"} + + +### entityName + Event source. +Default is `influxdb`. + Use alphanumeric characters, underscores (`_`), periods (`.`), and hyphens (`-`). All other characters are replaced with an underscore. -Default is `influxdb`. + ## Examples -##### Send the last reported status to Sensu +### Send the last reported status to Sensu + ```js import "influxdata/influxdb/secrets" import "contrib/sranka/sensu" @@ -117,3 +145,4 @@ sensu.event( text: "Disk usage is **${lastReported.status}**.", ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/sranka/sensu/tosensuname.md b/content/flux/v0.x/stdlib/contrib/sranka/sensu/tosensuname.md index 3eacba8d9..b503f0e79 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/sensu/tosensuname.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/sensu/tosensuname.md @@ -1,29 +1,62 @@ --- title: sensu.toSensuName() function description: > - The `sensu.toSensuName()` function translates a string value to a Sensu name by - replacing non-alphanumeric characters (`[a-zA-Z0-9_.-]`) with underscores (`_`). + `sensu.toSensuName()` translates a string value to a Sensu name + by replacing non-alphanumeric characters (`[a-zA-Z0-9_.-]`) with underscores (`_`). menu: flux_0_x_ref: name: sensu.toSensuName - parent: sensu + parent: contrib/sranka/sensu + identifier: contrib/sranka/sensu/toSensuName weight: 301 -introduced: 0.90.0 --- -The `sensu.toSensuName()` function translates a string value to a Sensu name by -replacing non-alphanumeric characters (`[a-zA-Z0-9_.-]`) with underscores (`_`). + + +`sensu.toSensuName()` translates a string value to a Sensu name +by replacing non-alphanumeric characters (`[a-zA-Z0-9_.-]`) with underscores (`_`). + + + +##### Function type signature + +```js +(v: string) => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### v +({{< req >}}) +String to operate on. + + + + +## Examples + +### Convert a string into a Sensu name ```js import "contrib/sranka/sensu" -sensu.toSensuName(v: "Example string 1.2?") +sensu.toSensuName(v: "Example name conversion")// Returns "Example_name_conversion" -// Returns "Example_string_1.2_" ``` -## Parameters - -### v {data-type="string"} -({{< req >}}) -String to operate on. diff --git a/content/flux/v0.x/stdlib/contrib/sranka/teams/_index.md b/content/flux/v0.x/stdlib/contrib/sranka/teams/_index.md index f06d4c844..0d2a5878e 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/teams/_index.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/teams/_index.md @@ -1,25 +1,38 @@ --- -title: Flux Microsoft Teams package -list_title: teams package +title: teams package description: > - The Flux `teams` (Microsoft Teams) package provides functions for sending messages to a - [Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software) + The `teams` package (Microsoft Teams) provides functions + for sending messages to a [Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software) channel using an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook). - Import the `contrib/sranka/teams` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/teams/ - - /influxdb/cloud/reference/flux/stdlib/contrib/teams/ menu: flux_0_x_ref: - name: teams - parent: sranka -weight: 201 -flux/v0.x/tags: [functions, teams, microsoft, package] -introduced: 0.70.0 + name: teams + parent: contrib/sranka + identifier: contrib/sranka/teams +weight: 31 +cascade: + + introduced: 0.70.0 --- -The Flux `teams` (Microsoft Teams) package provides functions for sending messages to a -[Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software) + + +The `teams` package (Microsoft Teams) provides functions +for sending messages to a [Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software) channel using an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook). Import the `contrib/sranka/teams` package: @@ -27,17 +40,21 @@ Import the `contrib/sranka/teams` package: import "contrib/sranka/teams" ``` + + ## Options -The `contrib/sranka/teams` package provides the following options: ```js -import "contib/sranka/teams" - option teams.summaryCutoff = 70 ``` + +### summaryCutoff + +`summaryCutoff` is the limit for message summaries. +Default is `70`. + + -### summaryCutoff {data-type="int"} -Character limit for message summaries. Default is `70`. ## Functions diff --git a/content/flux/v0.x/stdlib/contrib/sranka/teams/endpoint.md b/content/flux/v0.x/stdlib/contrib/sranka/teams/endpoint.md index 52944788e..6fbfdd01e 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/teams/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/teams/endpoint.md @@ -1,68 +1,52 @@ --- title: teams.endpoint() function description: > - The `teams.endpoint()` function sends a message to a Microsoft Teams channel - using data from table rows. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/teams/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/teams/endpoint/ + `teams.endpoint()` sends a message to a Microsoft Teams channel using data from table rows. menu: flux_0_x_ref: name: teams.endpoint - parent: teams -weight: 202 -flux/v0.x/tags: [notification endpoints] -introduced: 0.70.0 + parent: contrib/sranka/teams + identifier: contrib/sranka/teams/endpoint +weight: 301 --- -The `teams.endpoint()` function sends a message to a Microsoft Teams channel -using data from table rows. + + +`teams.endpoint()` sends a message to a Microsoft Teams channel using data from table rows. + + + +##### Function type signature ```js -import "contrib/sranka/teams" - -teams.endpoint(url: "https://outlook.office.com/webhook/example-webhook") +( + url: string, +) => ( + mapFn: (r: A) => {B with title: C, text: string, summary: string}, +) => (<-tables: stream[A]) => stream[{A with _sent: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url +({{< req >}}) Incoming webhook URL. -## Usage -`teams.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. -### mapFn {data-type="function"} -A function that builds the object used to generate the POST request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns an object that must include the -following fields: - -- `title` -- `text` -- `summary` - -_For more information, see [`teams.message()` parameters](/v2.0/reference/flux/stdlib/contrib/teams/message/#parameters)._ - -## Examples - -##### Send critical statuses to a Microsoft Teams channel -```js -import "contrib/sranka/teams" - -url = "https://outlook.office.com/webhook/example-webhook" -endpoint = teams.endpoint(url: url) - -crit_statuses = - from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") - -crit_statuses - |> endpoint( - mapFn: (r) => - ({title: "Disk Usage", text: "Disk usage is: **${r.status}**.", summary: "Disk usage is ${r.status}"}), - )() -``` diff --git a/content/flux/v0.x/stdlib/contrib/sranka/teams/message.md b/content/flux/v0.x/stdlib/contrib/sranka/teams/message.md index 08a0f65f1..0e7ead00f 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/teams/message.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/teams/message.md @@ -1,52 +1,78 @@ --- title: teams.message() function description: > - The `teams.message()` function sends a single message to a Microsoft Teams channel using - an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook). -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/teams/message/ - - /influxdb/cloud/reference/flux/stdlib/contrib/teams/message/ + `teams.message()` sends a single message to a Microsoft Teams channel using an + [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook). menu: flux_0_x_ref: name: teams.message - parent: teams -weight: 202 -introduced: 0.70.0 + parent: contrib/sranka/teams + identifier: contrib/sranka/teams/message +weight: 301 +flux/v0.x/tags: [single notification] --- -The `teams.message()` function sends a single message to a Microsoft Teams channel using -an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook). + + +`teams.message()` sends a single message to a Microsoft Teams channel using an +[incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook). + + + +##### Function type signature ```js -import "contrib/sranka/teams" - -teams.message( - url: "https://outlook.office.com/webhook/example-webhook", - title: "Example message title", - text: "Example message text", - summary: "", -) +(text: string, title: A, url: string, ?summary: string) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} +### url +({{< req >}}) Incoming webhook URL. -### title {data-type="string"} + + +### title +({{< req >}}) Message card title. -### text {data-type="string"} + + +### text +({{< req >}}) Message card text. -### summary {data-type="string"} + + +### summary + Message card summary. Default is `""`. + If no summary is provided, Flux generates the summary from the message text. + ## Examples -##### Send the last reported status to a Microsoft Teams channel +### Send the last reported status to a Microsoft Teams channel + ```js import "contrib/sranka/teams" @@ -64,3 +90,4 @@ teams.message( summary: "Disk usage is ${lastReported.status}", ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/sranka/telegram/_index.md b/content/flux/v0.x/stdlib/contrib/sranka/telegram/_index.md index d043ecd1f..383250cdb 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/telegram/_index.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/telegram/_index.md @@ -1,65 +1,49 @@ --- -title: Flux telegram package -list_title: telegram package +title: telegram package description: > - The Flux `telegram` package provides functions for sending messages to - [Telegram](https://telegram.org/) using the [Telegram Bot API](https://core.telegram.org/bots/api). - Import the `contrib/sranka/telegram` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/telegram/ - - /influxdb/cloud/reference/flux/stdlib/contrib/telegram/ + The `telegram` package provides functions for sending messages to [Telegram](https://telegram.org/) + using the [Telegram Bot API](https://core.telegram.org/bots/api). menu: flux_0_x_ref: - name: telegram - parent: sranka -weight: 202 -v2.0/tags: [functions, teams, telegram, package] -introduced: 0.70.0 + name: telegram + parent: contrib/sranka + identifier: contrib/sranka/telegram +weight: 31 +cascade: + + introduced: 0.70.0 --- -The Flux `telegram` package provides functions for sending messages to -[Telegram](https://telegram.org/) using the [Telegram Bot API](https://core.telegram.org/bots/api). + + +The `telegram` package provides functions for sending messages to [Telegram](https://telegram.org/) +using the [Telegram Bot API](https://core.telegram.org/bots/api). Import the `contrib/sranka/telegram` package: ```js import "contrib/sranka/telegram" ``` -## Options -The `contrib/sranka/telegram` package provides the following options: - -```js -option telegram.defaultURL = "https://api.telegram.org/bot" -option telegram.defaultParseMode = "MarkdownV2" -option telegram.defaultDisableWebPagePreview = false -option telegram.defaultSilent = true -``` - -### defaultURL {data-type="string"} -Default Telegram bot URL. Default is `https://api.telegram.org/bot`. - -### defaultParseMode {data-type="string"} -Default [Telegram parse mode](https://core.telegram.org/bots/api#formatting-options). -Default is `MarkdownV2`. - -### defaultDisableWebPagePreview {data-type="bool"} -Disable Telegram web page preview by default. -Default is `false`. - -### defaultSilent {data-type="bool"} -Send silent Telegram notifications by default. -Default is `true`. - -## Functions - -{{< children type="functions" show="pages" >}} - ## Set up a Telegram bot The **Telegram Bot API** requires a **bot token** and a **channel ID**. To set up a Telegram bot and obtain the required bot token and channel ID: 1. [Create a new Telegram account](https://telegram.org/) or use an existing account. -2. [Create a Telegram bot](https://core.telegram.org/bots#creating-a-new-bot). +2. [Create a Telegram bot](https://core.telegram.org/bots#creating-a-new-bot). Telegram provides a **bot token** for the newly created bot. 3. Use the **Telegram application** to create a new channel. 4. [Add the new bot to the channel](https://stackoverflow.com/questions/33126743/how-do-i-add-my-bot-to-a-channel) as an **Administrator**. @@ -72,3 +56,44 @@ To set up a Telegram bot and obtain the required bot token and channel ID: ``` Find your **channel ID** in the `id` field of the response. + +## Options + +```js +option telegram.defaultDisableWebPagePreview = false + +option telegram.defaultParseMode = "MarkdownV2" + +option telegram.defaultSilent = true + +option telegram.defaultURL = "https://api.telegram.org/bot" +``` + +### defaultDisableWebPagePreview + +`defaultDisableWebPagePreview` - Use Telegram web page preview by default. Default is `false`. + + + +### defaultParseMode + +`defaultParseMode` is the default [Telegram parse mode](https://core.telegram.org/bots/api#formatting-options). Default is `MarkdownV2`. + + + +### defaultSilent + +`defaultSilent` - Send silent Telegram notifications by default. Default is `true`. + + + +### defaultURL + +`defaultURL` is the default Telegram bot URL. Default is `https://api.telegram.org/bot`. + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/sranka/telegram/endpoint.md b/content/flux/v0.x/stdlib/contrib/sranka/telegram/endpoint.md index fd99eae82..ad88cea9a 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/telegram/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/telegram/endpoint.md @@ -1,77 +1,108 @@ --- title: telegram.endpoint() function description: > - The `telegram.endpoint()` function sends a message to a Telegram channel - using data from table rows. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/telegram/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/telegram/endpoint/ + `telegram.endpoint()` sends a message to a Telegram channel using data from table rows. menu: flux_0_x_ref: name: telegram.endpoint - parent: telegram -weight: 201 -introduced: 0.70.0 -flux/v0.x/tags: [notification endpoints] + parent: contrib/sranka/telegram + identifier: contrib/sranka/telegram/endpoint +weight: 301 + --- -The `telegram.endpoint()` function sends a message to a Telegram channel -using data from table rows. + -### token {data-type="string"} -({{< req >}}) -Telegram bot token. - -### parseMode {data-type="string"} -[Parse mode](https://core.telegram.org/bots/api#formatting-options) of the message text. -Default is `"MarkdownV2"`. - -### disableWebPagePreview {data-type="bool"} -Disable preview of web links in the sent message. -Default is `false`. +`telegram.endpoint()` sends a message to a Telegram channel using data from table rows. ## Usage + `telegram.endpoint` is a factory function that outputs another function. The output function requires a `mapFn` parameter. -### mapFn {data-type="function"} -A function that builds the object used to generate the POST request. -Requires an `r` parameter. +### `mapFn` +A function that builds the object used to generate the POST request. Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns an object that must include the -following fields: +`mapFn` accepts a table row (`r`) and returns an object that must include the following fields: - `channel` - `text` - `silent` -_For more information, see [`telegram.message()` parameters](/v2.0/reference/flux/stdlib/contrib/telegram/message/#parameters)._ +For more information, see `telegram.message()` parameters. + +The returned factory function accepts a `mapFn` parameter. +The `mapFn` must return an record with the following properties: + +- `channel` +- `text` +- `silent` + +See `telegram.message` parameters for more information. + +##### Function type signature + +```js +( + token: string, + ?disableWebPagePreview: A, + ?parseMode: B, + ?url: string, +) => ( + mapFn: (r: C) => {D with text: G, silent: F, channel: E}, +) => (<-tables: stream[C]) => stream[{C with _sent: string}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### url + +URL of the Telegram bot endpoint. Default is `https://api.telegram.org/bot`. + + + +### token +({{< req >}}) +Telegram bot token. + + + +### parseMode + +[Parse mode](https://core.telegram.org/bots/api#formatting-options) +of the message text. +Default is `MarkdownV2`. + + + +### disableWebPagePreview + +Disable preview of web links in the sent message. +Default is false. + + + ## Examples -##### Send critical statuses to a Telegram channel +### Send critical statuses to a Telegram channel + ```js import "influxdata/influxdb/secrets" import "contrib/sranka/telegram" @@ -87,3 +118,4 @@ crit_statuses = crit_statuses |> endpoint(mapFn: (r) => ({channel: "-12345", text: "Disk usage is **${r.status}**.", silent: true}))() ``` + diff --git a/content/flux/v0.x/stdlib/contrib/sranka/telegram/message.md b/content/flux/v0.x/stdlib/contrib/sranka/telegram/message.md index 431ac7678..a92d07382 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/telegram/message.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/telegram/message.md @@ -1,73 +1,107 @@ --- title: telegram.message() function description: > - The `telegram.message()` function sends a single message to a Telegram channel using - the [`sendMessage` method of the Telegram Bot API](https://core.telegram.org/bots/api#sendmessage). -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/telegram/message/ - - /influxdb/cloud/reference/flux/stdlib/contrib/telegram/message/ + `telegram.message()` sends a single message to a Telegram channel + using the [`sendMessage`](https://core.telegram.org/bots/api#sendmessage) method of the Telegram Bot API. menu: flux_0_x_ref: name: telegram.message - parent: telegram -weight: 201 -introduced: 0.70.0 + parent: contrib/sranka/telegram + identifier: contrib/sranka/telegram/message +weight: 301 +flux/v0.x/tags: [single notification] --- -The `telegram.message()` function sends a single message to a Telegram channel using -the [`sendMessage` method of the Telegram Bot API](https://core.telegram.org/bots/api#sendmessage). + + +`telegram.message()` sends a single message to a Telegram channel +using the [`sendMessage`](https://core.telegram.org/bots/api#sendmessage) method of the Telegram Bot API. + + + +##### Function type signature ```js -import "contrib/sranka/telegram" - -telegram.message( - url: "https://api.telegram.org/bot", - token: "S3crEtTel3gRamT0k3n", - channel: "-12345", - text: "Example message text", - parseMode: "MarkdownV2", - disableWebPagePreview: false, - silent: true, -) +( + channel: A, + text: B, + token: string, + ?disableWebPagePreview: C, + ?parseMode: D, + ?silent: E, + ?url: string, +) => int ``` -{{% note %}} -For information about retrieving your Telegram **bot token** and **channel ID**, -see [Set up a Telegram bot](/v2.0/reference/flux/stdlib/contrib/telegram/#set-up-a-telegram-bot). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### url {data-type="string"} -URL of the Telegram bot endpoint. -Default is `https://api.telegram.org/bot`. +### url -### token {data-type="string"} +URL of the Telegram bot endpoint. Default is `https://api.telegram.org/bot`. + + + +### token ({{< req >}}) Telegram bot token. -### channel {data-type="string"} + + +### channel ({{< req >}}) Telegram channel ID. -### text {data-type="string"} + + +### text +({{< req >}}) Message text. -### parseMode {data-type="string"} -[Parse mode](https://core.telegram.org/bots/api#formatting-options) of the message text. -Default is `"MarkdownV2"`. -### disableWebPagePreview {data-type="bool"} + +### parseMode + +[Parse mode](https://core.telegram.org/bots/api#formatting-options) +of the message text. +Default is `MarkdownV2`. + + + +### disableWebPagePreview + Disable preview of web links in the sent message. Default is `false`. -### silent {data-type="bool"} + + +### silent + Send message [silently](https://telegram.org/blog/channels-2-0#silent-messages). Default is `true`. + + + ## Examples -##### Send the last reported status to Telegram +### Send the last reported status to Telegram + ```js import "influxdata/influxdb/secrets" import "contrib/sranka/telegram" @@ -83,3 +117,4 @@ lastReported = telegram.message(token: token, channel: "-12345", text: "Disk usage is **${lastReported.status}**.") ``` + diff --git a/content/flux/v0.x/stdlib/contrib/sranka/webexteams/_index.md b/content/flux/v0.x/stdlib/contrib/sranka/webexteams/_index.md index cc5fdded3..93504910d 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/webexteams/_index.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/webexteams/_index.md @@ -1,28 +1,46 @@ --- -title: Flux webexteams package -list_title: webexteams package +title: webexteams package description: > - The Flux `webexteams` package provides functions that send messages to - [Webex Teams](https://www.webex.com/team-collaboration.html). + The `webexteams` package provides functions that send messages + to [Webex Teams](https://www.webex.com/team-collaboration.html). menu: flux_0_x_ref: - name: webexteams - parent: sranka -weight: 202 + name: webexteams + parent: contrib/sranka + identifier: contrib/sranka/webexteams +weight: 31 cascade: + introduced: 0.125.0 -influxdb/v2.0/tags: [functions, webex, package] --- -The Flux `webexteams` package provides functions that send messages to -[Webex Teams](https://www.webex.com/team-collaboration.html). + + +The `webexteams` package provides functions that send messages +to [Webex Teams](https://www.webex.com/team-collaboration.html). Import the `contrib/sranka/webexteams` package: ```js import "contrib/sranka/webexteams" ``` + + + ## Functions {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/sranka/webexteams/endpoint.md b/content/flux/v0.x/stdlib/contrib/sranka/webexteams/endpoint.md index 2f55c76ec..209bdac5a 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/webexteams/endpoint.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/webexteams/endpoint.md @@ -1,78 +1,60 @@ --- title: webexteams.endpoint() function description: > - The `webexteams.endpoint()` function sends a single message to Webex using the - [Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message). + `webexteams.endpoint()` returns a function that sends a message that includes data from input rows to a Webex room. menu: flux_0_x_ref: name: webexteams.endpoint - parent: webexteams -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/webexteams/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/contrib/webexteams/endpoint/ -flux/v0.x/tags: [notification endpoints] + parent: contrib/sranka/webexteams + identifier: contrib/sranka/webexteams/endpoint +weight: 301 --- -The `webexteams.endpoint()` function returns a function that sends a message that -includes data from input rows to a Webex room. + + +`webexteams.endpoint()` returns a function that sends a message that includes data from input rows to a Webex room. + + + +##### Function type signature ```js -import "contrib/sranka/webexteams" - -webexteams.endpoint( - url: "https://webexapis.com", - token: "token", -) +( + token: string, + ?url: string, +) => ( + mapFn: (r: A) => {B with text: E, roomId: D, markdown: C}, +) => (<-tables: stream[A]) => stream[{A with _sent: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -Base URL of Webex API endpoint _(without a trailing slash)_. +### url + +Base URL of Webex API endpoint (without a trailing slash). Default is `https://webexapis.com`. -### token {data-type="string"} + + +### token ({{< req >}}) [Webex API access token](https://developer.webex.com/docs/api/getting-started). -## Usage -`webexteams.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. -### mapFn {data-type="function"} -A function that builds the object used to generate the POST request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns an object that must include the -following fields: - -- `roomId` -- `text` -- `markdown` - -_For more information, see [`webexteams.message()` parameters](/flux/v0.x/stdlib/contrib/sranka/webexteams/message/#parameters)._ - -## Examples - -##### Send the last reported status to Webex Teams -```js -import "contrib/sranka/webexteams" -import "influxdata/influxdb/secrets" - -token = secrets.get(key: "WEBEX_API_KEY") - -from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses") - |> last() - |> tableFind(fn: (key) => true) - |> webexteams.endpoint(token: token)( - mapFn: (r) => - ({ - roomId: "Y2lzY29zcGFyazovL3VzL1JPT00vYmJjZWIxYWQtNDNmMS0zYjU4LTkxNDctZjE0YmIwYzRkMTU0", - text: "", - markdown: "Disk usage is **${r.status}**.", - }), - ) -``` \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/contrib/sranka/webexteams/message.md b/content/flux/v0.x/stdlib/contrib/sranka/webexteams/message.md index 33c0f0545..f42896afd 100644 --- a/content/flux/v0.x/stdlib/contrib/sranka/webexteams/message.md +++ b/content/flux/v0.x/stdlib/contrib/sranka/webexteams/message.md @@ -1,58 +1,90 @@ --- title: webexteams.message() function description: > - The `webexteams.message()` function sends a single message to Webex using the - [Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message). + `webexteams.message()` sends a single message to Webex + using the [Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message). menu: flux_0_x_ref: name: webexteams.message - parent: webexteams -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/webexteams/message/ - - /influxdb/cloud/reference/flux/stdlib/contrib/webexteams/message/ + parent: contrib/sranka/webexteams + identifier: contrib/sranka/webexteams/message +weight: 301 +flux/v0.x/tags: [single notification] --- -The `webexteams.message()` function sends a single message to Webex using the -[Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message). + + +`webexteams.message()` sends a single message to Webex +using the [Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message). + + + +##### Function type signature ```js -import "contrib/sranka/webexteams" - -webexteams.message(, - url: "https://webexapis.com" - token: "My5uP3rs3cRe7T0k3n", - roomId: "Y2lzY29zcGFyazovL3VzL1JPT00vYmJjZWIxYWQtNDNmMS0zYjU4LTkxNDctZjE0YmIwYzRkMTU0", - text: "Example plain text message", - markdown: "Example [markdown message](https://developer.webex.com/docs/api/basics).", -) +( + markdown: A, + roomId: B, + text: C, + token: string, + ?url: string, +) => int ``` -## Parameters +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} -### url {data-type="string"} -Base URL of Webex API endpoint _(without a trailing slash)_. +## Parameters + +### url + +Base URL of Webex API endpoint (without a trailing slash). Default is `https://webexapis.com`. -### token {data-type="string"} + + +### token ({{< req >}}) [Webex API access token](https://developer.webex.com/docs/api/getting-started). -### roomId {data-type="string"} + + +### roomId ({{< req >}}) Room ID to send the message to. -### text {data-type="string"} + + +### text ({{< req >}}) Plain text message. -### markdown {data-type="string"} + + +### markdown ({{< req >}}) [Markdown formatted message](https://developer.webex.com/docs/api/basics#formatting-messages). + + + ## Examples -##### Send the last reported status to Webex Teams +### Send the last reported status to Webex Teams + ```js import "contrib/sranka/webexteams" import "influxdata/influxdb/secrets" @@ -73,3 +105,4 @@ webexteams.message( markdown: "Disk usage is **${lastReported.status}**.", ) ``` + diff --git a/content/flux/v0.x/stdlib/contrib/tomhollingworth/_index.md b/content/flux/v0.x/stdlib/contrib/tomhollingworth/_index.md index c2e839c54..09ff9a5a0 100644 --- a/content/flux/v0.x/stdlib/contrib/tomhollingworth/_index.md +++ b/content/flux/v0.x/stdlib/contrib/tomhollingworth/_index.md @@ -1,27 +1,36 @@ --- -title: Packages contributed by tomhollingworth -list_title: tomhollingworth package +title: tomhollingworth package description: > - The `tomhollingworth` package contains functions and packages contributed by - [@tomhollingworth](https://github.com/tomhollingworth). + The `tomhollingworth` package contains packages and functions contributed by [@tomhollingworth](https://github.com/tomhollingworth). menu: flux_0_x_ref: - name: tomhollingworth + name: tomhollingworth parent: contrib -weight: 101 -cascade: - introduced: 0.91.0 - append: - block: note - content: | - #### Package author and maintainer - **Github:** [@tomhollingworth](https://github.com/tomhollingworth) - **InfluxDB Slack:** [@Tom Hollingworth](https://influxdata.com/slack) + identifier: contrib/tomhollingworth +weight: 21 --- -The `tomhollingworth` package contains functions and packages contributed by -[@tomhollingworth](https://github.com/tomhollingworth). + + +The `tomhollingworth` package contains packages and functions contributed by [@tomhollingworth](https://github.com/tomhollingworth). + + + ## Packages -{{< children >}} \ No newline at end of file +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/contrib/tomhollingworth/events/_index.md b/content/flux/v0.x/stdlib/contrib/tomhollingworth/events/_index.md index 4dd837dcd..63223e059 100644 --- a/content/flux/v0.x/stdlib/contrib/tomhollingworth/events/_index.md +++ b/content/flux/v0.x/stdlib/contrib/tomhollingworth/events/_index.md @@ -1,26 +1,44 @@ --- -title: Flux Events package -list_title: Events package +title: events package description: > - The Flux Events package provides tools for analyzing event-based data. - Import the `contrib/tomhollingworth/events` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/events/ - - /influxdb/cloud/reference/flux/stdlib/contrib/events/ + The `events` package provides tools for analyzing event-based data. menu: flux_0_x_ref: - name: events - parent: tomhollingworth - identifier: tomhollingworth-events -weight: 201 -flux/v0.x/tags: [functions, events, package] + name: events + parent: contrib/tomhollingworth + identifier: contrib/tomhollingworth/events +weight: 31 +cascade: + + introduced: 0.91.0 --- -The Flux Events package provides tools for analyzing event-based data. + + +The `events` package provides tools for analyzing event-based data. Import the `contrib/tomhollingworth/events` package: ```js import "contrib/tomhollingworth/events" ``` + + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/contrib/tomhollingworth/events/duration.md b/content/flux/v0.x/stdlib/contrib/tomhollingworth/events/duration.md index a3e50a904..a44ecde3b 100644 --- a/content/flux/v0.x/stdlib/contrib/tomhollingworth/events/duration.md +++ b/content/flux/v0.x/stdlib/contrib/tomhollingworth/events/duration.md @@ -1,150 +1,190 @@ --- title: events.duration() function description: > - The `events.duration()` function calculates the duration of events. - The function determines the time between a record and the subsequent record and - associates the duration with the first record (start of the event). -aliases: - - /influxdb/v2.0/reference/flux/stdlib/contrib/events/duration/ - - /influxdb/cloud/reference/flux/stdlib/contrib/events/duration/ + `events.duration()` calculates the duration of events. menu: flux_0_x_ref: name: events.duration - parent: tomhollingworth-events + parent: contrib/tomhollingworth/events + identifier: contrib/tomhollingworth/events/duration weight: 301 -flux/v0.x/tags: [functions, events, package] -related: - - /flux/v0.x/stdlib/universe/elapsed/ - - /flux/v0.x/stdlib/universe/stateduration/ +flux/v0.x/tags: [transformations, events] --- -The `events.duration()` function calculates the duration of events. -The function determines the time between a record and the subsequent record and -associates the duration with the first record (start of the event). -To calculate the duration of the last event, the function compares the timestamp -of the final record to the timestamp in the [`stopColumn`](#stopcolumn) or the -specified [`stop`](#stop) time. + + +`events.duration()` calculates the duration of events. + +The function determines the time between a record and the subsequent record +and associates the duration with the first record (start of the event). +To calculate the duration of the last event, +the function compares the timestamp of the final record +to the timestamp in the `stopColumn` or the specified stop time. + +### Similar functions +`events.duration()` is similar to `elapsed()` and `stateDuration()`, but differs in important ways: - `elapsed()` drops the first record. `events.duration()` does not. -- `stateDuration()` calculates the total time spent in a state (determined by a - [predicate function](/flux/v0.x/get-started/syntax-basics/#predicate-functions)). +- `stateDuration()` calculates the total time spent in a state (determined by a predicate function). `events.duration()` returns the duration between all records and their subsequent records. -For examples, see [below](#compared-to-similar-functions). -{{% /note %}} +See the example [below](#compared-to-similar-functions). + +##### Function type signature + +```js +( + <-tables: stream[A], + ?columnName: string, + ?stop: time, + ?stopColumn: string, + ?timeColumn: string, + ?unit: duration, +) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### unit {data-type="duration"} +### unit + Duration unit of the calculated state duration. Default is `1ns` -### columnName {data-type="string"} + + +### columnName + Name of the result column. Default is `"duration"`. -### timeColumn {data-type="string"} + + +### timeColumn + Name of the time column. Default is `"_time"`. -### stopColumn {data-type="string"} + + +### stopColumn + Name of the stop column. Default is `"_stop"`. -### stop {data-type="time"} -The latest time to use when calculating results. -If provided, `stop` overrides the time value in the [`stopColumn`](#stopcolumn). -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + +### stop + +The latest time to use when calculating results. + +If provided, `stop` overrides the time value in the `stopColumn`. + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -##### Calculate the duration of states +- [Calculate the duration of states](#calculate-the-duration-of-states) +- [Compared to similar functions](#compared-to-similar-functions) + +### Calculate the duration of states + ```js +import "array" import "contrib/tomhollingworth/events" data |> events.duration(unit: 1m, stop: 2020-01-02T00:00:00Z) ``` -{{< flex >}} -{{% flex-content %}} -##### Input -| _time | state | -|:----- | -----:| -| 2020-01-01T00:00:00Z | ok | -| 2020-01-01T00:12:34Z | warn | -| 2020-01-01T00:25:01Z | ok | -| 2020-01-01T16:07:55Z | crit | -| 2020-01-01T16:54:21Z | warn | -| 2020-01-01T18:20:45Z | ok | -{{% /flex-content %}} -{{% flex-content %}} -##### Output -| _time | state | duration | -|:----- |:-----:| --------:| -| 2020-01-01T00:00:00Z | ok | 12 | -| 2020-01-01T00:12:34Z | warn | 12 | -| 2020-01-01T00:25:01Z | ok | 942 | -| 2020-01-01T16:07:55Z | crit | 46 | -| 2020-01-01T16:54:21Z | warn | 86 | -| 2020-01-01T18:20:45Z | ok | 339 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -## Compared to similar functions -The example below includes output values of `events.duration()`, `elapsed()`, and -`stateDuration()` related to the `_time` and `state` values of input data. +#### Input data + +| _time | state | +| -------------------- | ------ | +| 2020-01-01T00:00:00Z | ok | +| 2020-01-01T00:12:34Z | warn | +| 2020-01-01T00:25:01Z | ok | +| 2020-01-01T16:07:55Z | crit | +| 2020-01-01T16:54:21Z | warn | +| 2020-01-01T18:20:45Z | ok | + + +#### Output data + +| _time | state | duration | +| -------------------- | ------ | --------- | +| 2020-01-01T00:00:00Z | ok | 12 | +| 2020-01-01T00:12:34Z | warn | 12 | +| 2020-01-01T00:25:01Z | ok | 942 | +| 2020-01-01T16:07:55Z | crit | 46 | +| 2020-01-01T16:54:21Z | warn | 86 | +| 2020-01-01T18:20:45Z | ok | 339 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Compared to similar functions + +The example below includes output values of +`events.duration()`, `elapsed()`, and `stateDuration()` +related to the `_time` and `state` values of input data. -{{< flex >}} -{{% flex-content %}} -##### Input -| _time | state | -|:----- | -----:| -| 2020-01-01T00:00:00Z | ok | -| 2020-01-01T00:12:34Z | warn | -| 2020-01-01T00:25:01Z | ok | -| 2020-01-01T16:07:55Z | crit | -| 2020-01-01T16:54:21Z | warn | -| 2020-01-01T18:20:45Z | ok | -{{% /flex-content %}} -{{% flex-content %}} -##### Functions ```js -data |> events.duration(unit: 1m, stop: 2020-01-02T00:00:00Z) +import "array" +import "contrib/tomhollingworth/events" -data |> elapsed(unit: 1m) - -data |> stateDuration(unit: 1m, fn: (r) => true) +union( + tables: [ + data + |> events.duration(unit: 1m, stop: 2020-01-02T00:00:00Z) + |> map(fn: (r) => ({_time: r._time, state: r.state, function: "events.Duration()", value: r.duration})), + data + |> elapsed(unit: 1m) + |> map(fn: (r) => ({_time: r._time, state: r.state, function: "elapsed()", value: r.elapsed})), + data + |> stateDuration(unit: 1m, fn: (r) => true) + |> map(fn: (r) => ({_time: r._time, state: r.state, function: "stateDuration()", value: r.stateDuration})), + ], +) + |> pivot(rowKey: ["_time", "state"], columnKey: ["function"], valueColumn: "value") ``` -{{% /flex-content %}} -{{< /flex >}} -##### Output values -| _time | state | events.duration() | elapsed() | stateDuration() | -|:----- |:-----:| -----------------:| ---------: | ---------------:| -| 2020-01-01T00:00:00Z | ok | 12 | N/A | 0 | -| 2020-01-01T00:12:34Z | warn | 12 | 12 | 12 | -| 2020-01-01T00:25:01Z | ok | 942 | 12 | 25 | -| 2020-01-01T16:07:55Z | crit | 46 | 942 | 967 | -| 2020-01-01T16:54:21Z | warn | 86 | 46 | 1014 | -| 2020-01-01T18:20:45Z | ok | 339 | 86 | 1100 | +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| _time | state | events.Duration() | elapsed() | stateDuration() | +| -------------------- | ------ | ------------------ | ---------- | ---------------- | +| 2020-01-01T00:00:00Z | ok | 12 | | 0 | +| 2020-01-01T00:12:34Z | warn | 12 | 12 | 12 | +| 2020-01-01T00:25:01Z | ok | 942 | 12 | 25 | +| 2020-01-01T16:07:55Z | crit | 46 | 942 | 967 | +| 2020-01-01T16:54:21Z | warn | 86 | 46 | 1014 | +| 2020-01-01T18:20:45Z | ok | 339 | 86 | 1100 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/csv/_index.md b/content/flux/v0.x/stdlib/csv/_index.md index 1dbaff609..d6b5bd8d9 100644 --- a/content/flux/v0.x/stdlib/csv/_index.md +++ b/content/flux/v0.x/stdlib/csv/_index.md @@ -1,28 +1,44 @@ --- -title: Flux csv package -list_title: csv package +title: csv package description: > - The Flux `csv` package provides functions for working with data in annotated CSV format. - Import the `csv` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/csv/ - - /influxdb/v2.0/reference/flux/stdlib/csv/ - - /influxdb/cloud/reference/flux/stdlib/csv/ + The `csv` package provides tools for working with data in annotated CSV format. menu: flux_0_x_ref: - name: csv - parent: Standard library + name: csv + parent: stdlib + identifier: csv weight: 11 -flux/v0.x/tags: [functions, csv, package] -introduced: 0.14.0 +cascade: + flux/v0.x/tags: [csv] + introduced: 0.14.0 --- -The Flux `csv` package provides functions for working with data in -[annotated CSV format](https://github.com/influxdata/flux/blob/master/docs/SPEC.md#csv). + + +The `csv` package provides tools for working with data in annotated CSV format. Import the `csv` package: ```js import "csv" ``` + + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/csv/from.md b/content/flux/v0.x/stdlib/csv/from.md index 49799069c..347c3b5ad 100644 --- a/content/flux/v0.x/stdlib/csv/from.md +++ b/content/flux/v0.x/stdlib/csv/from.md @@ -1,115 +1,144 @@ --- title: csv.from() function -description: The `csv.from()` function retrieves data from a CSV data source. -aliases: - - /influxdb/v2.0/reference/flux/functions/inputs/fromcsv - - /influxdb/v2.0/reference/flux/functions/built-in/inputs/fromcsv - - /influxdb/v2.0/reference/flux/functions/csv/from/ - - /influxdb/v2.0/reference/flux/stdlib/csv/from/ - - /influxdb/cloud/reference/flux/stdlib/csv/from/ +description: > + `csv.from()` retrieves data from a comma separated value (CSV) data source and + returns a stream of tables. menu: flux_0_x_ref: name: csv.from parent: csv -weight: 202 -flux/v0.x/tags: [inputs] -introduced: 0.14.0 + identifier: csv/from +weight: 101 +flux/v0.x/tags: [csv, inputs] --- -The `csv.from()` function retrieves data from a comma-separated value (CSV) data source. -It returns a stream of tables. -Each unique series is contained within its own table. -Each record in the table represents a single point in the series. + + +`csv.from()` retrieves data from a comma separated value (CSV) data source and +returns a stream of tables. + + + +##### Function type signature ```js -import "csv" - -csv.from( - csv: csvData, - mode: "annotations", -) - -// OR - -csv.from( - file: "/path/to/data-file.csv", - mode: "annotations", -) +(?csv: string, ?file: string, ?mode: string) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### csv {data-type="string"} +### csv + CSV data. -Supports [annotated CSV](/{{< latest "influxdb" >}}/reference/syntax/annotated-csv/) or raw CSV. -Use [`mode`](#mode) to specify the parsing mode. -{{% note %}} -Annotated CSV data must include all [annotation rows](/{{< latest "influxdb" >}}/reference/syntax/annotated-csv/#annotations). -{{% /note %}} +Supports anonotated CSV or raw CSV. Use `mode` to specify the parsing mode. + +### file + +File path of the CSV file to query. -### file {data-type="string"} -The file path of the CSV file to query. The path can be absolute or relative. If relative, it is relative to the working directory of the `fluxd` process. -_The CSV file must exist in the same file system running the `fluxd` process._ +The CSV file must exist in the same file system running the `fluxd` process. -{{% warn %}} -**InfluxDB OSS** and **{{< cloud-name "short" >}}** user interfaces do _**not**_ support the `file` parameter. -Neither allow access to the underlying filesystem. -However, the [Flux REPL](/{{< latest "influxdb" >}}/tools/repl/) does support the `file` parameter. -{{% /warn %}} +### mode -### mode {data-type="string"} -CSV parsing mode. -Default is `annotations`. +is the CSV parsing mode. Default is `annotations`. + +**Available annotation modes** +- **annotations**: Use CSV notations to determine column data types. +- **raw**: Parse all columns as strings and use the first row as the +header row and all subsequent rows as data. -##### Available modes -- **annotations:** Use CSV annotations to determine column data types. -- **raw:** Parse all columns as strings and use the first row as the - [header row](/{{< latest "influxdb" >}}/reference/syntax/annotated-csv/#rows) and all - subsequent rows as data. ## Examples -- [Query annotated CSV data from a file](#query-annotated-csv-data-from-a-file) -- [Query raw CSV data from a file](#query-raw-csv-data-from-a-file) +- [Query anotated CSV data from file](#query-anotated-csv-data-from-file) +- [Query raw data from CSV file](#query-raw-data-from-csv-file) - [Query an annotated CSV string](#query-an-annotated-csv-string) - [Query a raw CSV string](#query-a-raw-csv-string) -##### Query annotated CSV data from a file +### Query anotated CSV data from file + ```js import "csv" -csv.from(file: "/path/to/data-file.csv") +csv.from(file: "path/to/data-file.csv") ``` -##### Query raw CSV data from a file + +### Query raw data from CSV file + ```js import "csv" csv.from(file: "/path/to/data-file.csv", mode: "raw") ``` -##### Query an annotated CSV string + +### Query an annotated CSV string + ```js import "csv" csvData = " #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double -#group,false,false,false,false,false,false,false,false +#group,false,false,false,false,false,true,true,false #default,,,,,,,, ,result,table,_start,_stop,_time,region,host,_value ,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 -,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 -,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62 +,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:51:00Z,east,A,65.15 +,mean,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 +,mean,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:51:20Z,east,B,18.67 +,mean,2,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62 +,mean,2,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:51:40Z,east,C,82.16 " csv.from(csv: csvData) ``` -##### Query a raw CSV string +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| _start | _stop | _time | *region | *host | _value | +| -------------------- | -------------------- | -------------------- | ------- | ----- | ------- | +| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:00Z | east | A | 15.43 | +| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:51:00Z | east | A | 65.15 | + +| _start | _stop | _time | *region | *host | _value | +| -------------------- | -------------------- | -------------------- | ------- | ----- | ------- | +| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:20Z | east | B | 59.25 | +| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:51:20Z | east | B | 18.67 | + +| _start | _stop | _time | *region | *host | _value | +| -------------------- | -------------------- | -------------------- | ------- | ----- | ------- | +| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:40Z | east | C | 52.62 | +| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:51:40Z | east | C | 82.16 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Query a raw CSV string + ```js import "csv" @@ -125,8 +154,15 @@ csv.from(csv: csvData, mode: "raw") ``` {{< expand-wrapper >}} -{{% expand "Function updates" %}} -#### v0.109.0 -- Add `mode` parameter to support querying raw CSV data. +{{% expand "View example output" %}} + +#### Output data + +| _start | _stop | _time | region | host | _value | +| -------------------- | -------------------- | -------------------- | ------- | ----- | ------- | +| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:00Z | east | A | 15.43 | +| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:20Z | east | B | 59.25 | +| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:40Z | east | C | 52.62 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/date/_index.md b/content/flux/v0.x/stdlib/date/_index.md index 63e08b710..29d00582a 100644 --- a/content/flux/v0.x/stdlib/date/_index.md +++ b/content/flux/v0.x/stdlib/date/_index.md @@ -1,64 +1,86 @@ --- -title: Flux date package -list_title: date package +title: date package description: > - The Flux `date` package provides date and time constants and functions. - Import the `date` package. -aliases: - - /influxdb/v2.0/reference/flux/language/built-ins/time-constants/ - - /influxdb/v2.0/reference/flux/functions/date/ - - /influxdb/v2.0/reference/flux/stdlib/date/ - - /influxdb/cloud/reference/flux/stdlib/date/ + The `date` package provides date and time constants and functions. menu: flux_0_x_ref: - name: date - parent: Standard library + name: date + parent: stdlib + identifier: date weight: 11 cascade: flux/v0.x/tags: [date/time] -introduced: 0.37.0 + introduced: 0.37.0 --- -The Flux `date` package provides date and time constants and functions. -Import the `date` package. + + +The `date` package provides date and time constants and functions. +Import the `date` package: ```js import "date" ``` -## Date and time constants -That `date` package includes the following date and time constants. - -### Days of the week -Days of the week are represented as integers in the range `[0-6]`. +## Constants ```js -date.Sunday = 0 -date.Monday = 1 -date.Tuesday = 2 -date.Wednesday = 3 -date.Thursday = 4 -date.Friday = 5 -date.Saturday = 6 -``` - -### Months of the year -Months are represented as integers in the range `[1-12]`. - -```js -date.January = 1 -date.February = 2 -date.March = 3 -date.April = 4 -date.May = 5 -date.June = 6 -date.July = 7 -date.August = 8 +date.April = 4 +date.August = 8 +date.December = 12 +date.February = 2 +date.Friday = 5 +date.January = 1 +date.July = 7 +date.June = 6 +date.March = 3 +date.May = 5 +date.Monday = 1 +date.November = 11 +date.October = 10 +date.Saturday = 6 date.September = 9 -date.October = 10 -date.November = 11 -date.December = 12 +date.Sunday = 0 +date.Thursday = 4 +date.Tuesday = 2 +date.Wednesday = 3 ``` -## Date and time functions +- **date.April** is a constant that represents the month of April. +- **date.August** is a constant that represents the month of August. +- **date.December** is a constant that represents the month of December. +- **date.February** is a constant that represents the month of February. +- **date.Friday** is a constant that represents Friday as a day of the week. +- **date.January** is a constant that represents the month of January. +- **date.July** is a constant that represents the month of July. +- **date.June** is a constant that represents the month of June. +- **date.March** is a constant that represents the month of March. +- **date.May** is a constant that represents the month of May. +- **date.Monday** is a constant that represents Monday as a day of the week. +- **date.November** is a constant that represents the month of November. +- **date.October** is a constant that represents the month of October. +- **date.Saturday** is a constant that represents Saturday as a day of the week. +- **date.September** is a constant that represents the month of September. +- **date.Sunday** is a constant that represents Sunday as a day of the week +- **date.Thursday** is a constant that represents Thursday as a day of the week. +- **date.Tuesday** is a constant that represents Tuesday as a day of the week. +- **date.Wednesday** is a constant that represents Wednesday as a day of the week. + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/date/add.md b/content/flux/v0.x/stdlib/date/add.md index 973daf239..ceedbbea6 100644 --- a/content/flux/v0.x/stdlib/date/add.md +++ b/content/flux/v0.x/stdlib/date/add.md @@ -1,56 +1,106 @@ --- title: date.add() function description: > - `date.add()` adds a duration to a time value and returns the resulting time. + `date.add()` adds a duration to a time value and returns the resulting time value. menu: flux_0_x_ref: name: date.add parent: date -weight: 302 + identifier: date/add +weight: 101 flux/v0.x/tags: [date/time] -aliases: - - /flux/v0.x/stdlib/date/addduration/ -related: - - /flux/v0.x/stdlib/date/subduration/ -introduced: 0.162.0 --- -`date.add()` adds a duration to a time value and returns the resulting time. + + +`date.add()` adds a duration to a time value and returns the resulting time value. + + + +##### Function type signature ```js -import "date" - -date.add(d: 12h, to: now()) +(d: duration, to: A, ?location: {zone: string, offset: duration}) => time where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### d {data-type="duration"} +### d +({{< req >}}) Duration to add. -### to {data-type="time, duration"} -Time to add the [duration](#d) to. + + +### to +({{< req >}}) +Time to add the duration to. + + + +### location + +Location to use for the time value. + Use an absolute time or a relative duration. -Durations are relative to [`now()`](/flux/v0.x/stdlib/universe/now/). +Durations are relative to `now()`. + ## Examples +- [Add six hours to a timestamp](#add-six-hours-to-a-timestamp) +- [Add one month to yesterday](#add-one-month-to-yesterday) +- [Add six hours to a relative duration](#add-six-hours-to-a-relative-duration) + ### Add six hours to a timestamp + ```js import "date" -date.add(d: 6h, to: 2019-09-16T12:00:00Z) +date.add(d: 6h, to: 2019-09-16T12:00:00Z)// Returns 2019-09-16T18:00:00.000000000Z -// Returns 2019-09-16T18:00:00.000000000Z ``` + +### Add one month to yesterday + +A time may be represented as either an explicit timestamp +or as a relative time from the current `now` time. add can +support either type of value. + +```js +import "date" + +option now = () => 2021-12-10T16:27:40Z + +date.add(d: 1mo, to: -1d)// Returns 2022-01-09T16:27:40Z + +``` + + ### Add six hours to a relative duration + ```js import "date" option now = () => 2022-01-01T12:00:00Z -date.add(d: 6h, to: 3h) +date.add(d: 6h, to: 3h)// Returns 2022-01-01T21:00:00.000000000Z -// Returns 2022-01-01T21:00:00.000000000Z ``` + diff --git a/content/flux/v0.x/stdlib/date/hour.md b/content/flux/v0.x/stdlib/date/hour.md index b23347af1..7f87af514 100644 --- a/content/flux/v0.x/stdlib/date/hour.md +++ b/content/flux/v0.x/stdlib/date/hour.md @@ -1,56 +1,83 @@ --- title: date.hour() function description: > - The `date.hour()` function returns the hour of a specified time. - Results range from `[0-23]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/hour/ - - /influxdb/v2.0/reference/flux/stdlib/date/hour/ - - /influxdb/cloud/reference/flux/stdlib/date/hour/ + `date.hour()` returns the hour of a specified time. Results range from `[0 - 23]`. menu: flux_0_x_ref: name: date.hour parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/hour +weight: 101 --- -The `date.hour()` function returns the hour of a specified time. -Results range from `[0-23]`. + + +`date.hour()` returns the hour of a specified time. Results range from `[0 - 23]`. + + + +##### Function type signature ```js -import "date" - -date.hour(t: 2019-07-17T12:05:21.012Z) - -// Returns 12 +(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. +### location + +Location used to determine timezone. +Default is the `location` option. + + + + ## Examples -##### Return the hour of a time value +- [Return the hour of a time value](#return-the-hour-of-a-time-value) +- [Return the hour of a relative duration](#return-the-hour-of-a-relative-duration) + +### Return the hour of a time value + ```js import "date" -date.hour(t: 2020-02-11T12:21:03.293534940Z) +date.hour(t: 2020-02-11T12:21:03.29353494Z)// Returns 12 -// Returns 12 ``` -##### Return the hour of a relative duration + +### Return the hour of a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.hour(t: -8h) +date.hour(t: -8h)// Returns 7 -// Returns 4 ``` + diff --git a/content/flux/v0.x/stdlib/date/microsecond.md b/content/flux/v0.x/stdlib/date/microsecond.md index d43a6e17a..8bc06d465 100644 --- a/content/flux/v0.x/stdlib/date/microsecond.md +++ b/content/flux/v0.x/stdlib/date/microsecond.md @@ -1,56 +1,78 @@ --- title: date.microsecond() function description: > - The `date.microsecond()` function returns the microsecond of a specified time. - Results range from `[0-999999]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/microsecond/ - - /influxdb/v2.0/reference/flux/stdlib/date/microsecond/ - - /influxdb/cloud/reference/flux/stdlib/date/microsecond/ + `date.microsecond()` returns the microseconds for a specified time. + Results range `from [0-999999]`. menu: flux_0_x_ref: name: date.microsecond parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/microsecond +weight: 101 --- -The `date.microsecond()` function returns the microsecond of a specified time. -Results range from `[0-999999]`. + + +`date.microsecond()` returns the microseconds for a specified time. +Results range `from [0-999999]`. + + + +##### Function type signature ```js -import "date" - -date.microsecond(t: 2019-07-17T12:05:21.012934584Z) - -// Returns 12934 +(t: A) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. + ## Examples -##### Return the microsecond of a time value +- [Return the microsecond of a time value](#return-the-microsecond-of-a-time-value) +- [Return the microsecond of a relative duration](#return-the-microsecond-of-a-relative-duration) + +### Return the microsecond of a time value + ```js import "date" -date.microsecond(t: 2020-02-11T12:21:03.293534940Z) +date.microsecond(t: 2020-02-11T12:21:03.29353494Z)// Returns 293534 -// Returns 293534 ``` -##### Return the microsecond of a relative duration + +### Return the microsecond of a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.microsecond(t: -1890us) +date.microsecond(t: -1890us)// Returns 322661 -// Returns 291644 ``` + diff --git a/content/flux/v0.x/stdlib/date/millisecond.md b/content/flux/v0.x/stdlib/date/millisecond.md index e54c2f060..b95d12ee3 100644 --- a/content/flux/v0.x/stdlib/date/millisecond.md +++ b/content/flux/v0.x/stdlib/date/millisecond.md @@ -1,56 +1,78 @@ --- title: date.millisecond() function description: > - The `date.millisecond()` function returns the millisecond of a specified time. - Results range from `[0-999999]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/millisecond/ - - /influxdb/v2.0/reference/flux/stdlib/date/millisecond/ - - /influxdb/cloud/reference/flux/stdlib/date/millisecond/ + `date.millisecond()` returns the milliseconds for a specified time. + Results range from `[0-999]`. menu: flux_0_x_ref: name: date.millisecond parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/millisecond +weight: 101 --- -The `date.millisecond()` function returns the millisecond of a specified time. + + +`date.millisecond()` returns the milliseconds for a specified time. Results range from `[0-999]`. + + +##### Function type signature + ```js -import "date" - -date.millisecond(t: 2019-07-17T12:05:21.012934584Z) - -// Returns 12 +(t: A) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. + ## Examples -##### Return the millisecond of a time value +- [Return the millisecond of the time value](#return-the-millisecond-of-the-time-value) +- [Return the millisecond of a relative duration](#return-the-millisecond-of-a-relative-duration) + +### Return the millisecond of the time value + ```js import "date" -date.millisecond(t: 2020-02-11T12:21:03.293534940Z) +date.millisecond(t: 2020-02-11T12:21:03.29353494Z)// Returns 293 -// Returns 293 ``` -##### Return the millisecond of a relative duration + +### Return the millisecond of a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.millisecond(t: -150ms) +date.millisecond(t: -150ms)// Returns 127 -// Returns 143 ``` + diff --git a/content/flux/v0.x/stdlib/date/minute.md b/content/flux/v0.x/stdlib/date/minute.md index bf0a813a8..930b390aa 100644 --- a/content/flux/v0.x/stdlib/date/minute.md +++ b/content/flux/v0.x/stdlib/date/minute.md @@ -1,56 +1,83 @@ --- title: date.minute() function description: > - The `date.minute()` function returns the minute of a specified time. - Results range from `[0-59]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/minute/ - - /influxdb/v2.0/reference/flux/stdlib/date/minute/ - - /influxdb/cloud/reference/flux/stdlib/date/minute/ + `date.minute()` returns the minute of a specified time. Results range from `[0 - 59]`. menu: flux_0_x_ref: name: date.minute parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/minute +weight: 101 --- -The `date.minute()` function returns the minute of a specified time. -Results range from `[0-59]`. + + +`date.minute()` returns the minute of a specified time. Results range from `[0 - 59]`. + + + +##### Function type signature ```js -import "date" - -date.minute(t: 2019-07-17T12:05:21.012Z) - -// Returns 5 +(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. +### location + +Location used to determine timezone. +Default is the `location` option. + + + + ## Examples -##### Return the minute of a time value +- [Return the minute of a time value](#return-the-minute-of-a-time-value) +- [Return the minute of a relative duration](#return-the-minute-of-a-relative-duration) + +### Return the minute of a time value + ```js import "date" -date.minute(t: 2020-02-11T12:21:03.293534940Z) +date.minute(t: 2020-02-11T12:21:03.29353494Z)// Returns 21 -// Returns 21 ``` -##### Return the minute of a relative duration + +### Return the minute of a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.minute(t: -45m) +date.minute(t: -45m)// Returns 6 -// Returns 36 ``` + diff --git a/content/flux/v0.x/stdlib/date/month.md b/content/flux/v0.x/stdlib/date/month.md index 975d478f4..01891394b 100644 --- a/content/flux/v0.x/stdlib/date/month.md +++ b/content/flux/v0.x/stdlib/date/month.md @@ -1,57 +1,83 @@ --- title: date.month() function description: > - The `date.month()` function returns the month of a specified time. - Results range from `[1-12]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/month/ - - /influxdb/v2.0/reference/flux/stdlib/date/month/ - - /influxdb/cloud/reference/flux/stdlib/date/month/ + `date.month()` returns the month of a specified time. Results range from `[1 - 12]`. menu: flux_0_x_ref: name: date.month parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/month +weight: 101 --- -The `date.month()` function returns the month of a specified time. -Results range from `[1-12]` and correspond to `date` package -[month constants](/flux/v0.x/stdlib/date/#months-of-the-year). + + +`date.month()` returns the month of a specified time. Results range from `[1 - 12]`. + + + +##### Function type signature ```js -import "date" - -date.month(t: 2019-07-17T12:05:21.012Z) - -// Returns 7 +(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. +### location + +Location used to determine timezone. +Default is the `location` option. + + + + ## Examples -##### Return the month of a time value +- [Return the month of a time value](#return-the-month-of-a-time-value) +- [Return the month of a relative duration](#return-the-month-of-a-relative-duration) + +### Return the month of a time value + ```js import "date" -date.month(t: 2020-02-11T12:21:03.293534940Z) +date.month(t: 2020-02-11T12:21:03.29353494Z)// Returns 2 -// Returns 2 ``` -##### Return the month of a relative duration + +### Return the month of a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.month(t: -3mo) +date.month(t: -3mo)// Returns 8 -// Returns 11 ``` + diff --git a/content/flux/v0.x/stdlib/date/monthday.md b/content/flux/v0.x/stdlib/date/monthday.md index d2d69b0a9..dd121e897 100644 --- a/content/flux/v0.x/stdlib/date/monthday.md +++ b/content/flux/v0.x/stdlib/date/monthday.md @@ -1,56 +1,85 @@ --- title: date.monthDay() function description: > - The `date.monthDay()` function returns the day of the month for a specified time. - Results range from `[1-31]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/monthday/ - - /influxdb/v2.0/reference/flux/stdlib/date/monthday/ - - /influxdb/cloud/reference/flux/stdlib/date/monthday/ + `date.monthDay()` returns the day of the month for a specified time. + Results range from `[1 - 31]`. menu: flux_0_x_ref: name: date.monthDay parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/monthDay +weight: 101 --- -The `date.monthDay()` function returns the day of the month for a specified time. -Results range from `[1-31]`. + + +`date.monthDay()` returns the day of the month for a specified time. +Results range from `[1 - 31]`. + + + +##### Function type signature ```js -import "date" - -date.monthDay(t: 2019-07-17T12:05:21.012Z) - -// Returns 17 +(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. +### location + +Location used to determine timezone. +Default is the `location` option. + + + + ## Examples -##### Return the day of the month for a time value +- [Return the day of the month for a time value](#return-the-day-of-the-month-for-a-time-value) +- [Return the day of the month for a relative duration](#return-the-day-of-the-month-for-a-relative-duration) + +### Return the day of the month for a time value + ```js import "date" -date.monthDay(t: 2020-02-11T12:21:03.293534940Z) +date.monthDay(t: 2020-02-11T12:21:03.29353494Z)// Returns 11 -// Returns 11 ``` -##### Return the day of the month for a relative duration + +### Return the day of the month for a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.monthDay(t: -8d) +date.monthDay(t: -8d)// Returns 25 -// Returns 3 ``` + diff --git a/content/flux/v0.x/stdlib/date/nanosecond.md b/content/flux/v0.x/stdlib/date/nanosecond.md index a56b89a95..1b738534b 100644 --- a/content/flux/v0.x/stdlib/date/nanosecond.md +++ b/content/flux/v0.x/stdlib/date/nanosecond.md @@ -1,56 +1,78 @@ --- title: date.nanosecond() function description: > - The `date.nanosecond()` function returns the nanosecond of a specified time. + `date.nanosecond()` returns the nanoseconds for a specified time. Results range from `[0-999999999]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/nanosecond/ - - /influxdb/v2.0/reference/flux/stdlib/date/nanosecond/ - - /influxdb/cloud/reference/flux/stdlib/date/nanosecond/ menu: flux_0_x_ref: name: date.nanosecond parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/nanosecond +weight: 101 --- -The `date.nanosecond()` function returns the nanosecond of a specified time. + + +`date.nanosecond()` returns the nanoseconds for a specified time. Results range from `[0-999999999]`. + + +##### Function type signature + ```js -import "date" - -date.nanosecond(t: 2019-07-17T12:05:21.012934584Z) - -// Returns 12934584 +(t: A) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. + ## Examples -##### Return the nanosecond for a time value +- [Return the nanosecond for a time value](#return-the-nanosecond-for-a-time-value) +- [Return the nanosecond for a relative duration](#return-the-nanosecond-for-a-relative-duration) + +### Return the nanosecond for a time value + ```js import "date" -date.nanosecond(t: 2020-02-11T12:21:03.293534940Z) +date.nanosecond(t: 2020-02-11T12:21:03.29353494Z)// Returns 293534940 -// Returns 293534940Z ``` -##### Return the nanosecond for a relative duration + +### Return the nanosecond for a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.nanosecond(t: -2111984ns) +date.nanosecond(t: -2111984ns)// Returns 128412016 -// Returns 291422956 ``` + diff --git a/content/flux/v0.x/stdlib/date/quarter.md b/content/flux/v0.x/stdlib/date/quarter.md index 7e2e26331..27900e4a0 100644 --- a/content/flux/v0.x/stdlib/date/quarter.md +++ b/content/flux/v0.x/stdlib/date/quarter.md @@ -1,56 +1,83 @@ --- title: date.quarter() function description: > - The `date.quarter()` function returns the quarter of the year for a specified time. - Results range from `[1-4]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/quarter/ - - /influxdb/v2.0/reference/flux/stdlib/date/quarter/ - - /influxdb/cloud/reference/flux/stdlib/date/quarter/ + `date.quarter()` returns the quarter for a specified time. Results range from `[1-4]`. menu: flux_0_x_ref: name: date.quarter parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/quarter +weight: 101 --- -The `date.quarter()` function returns the quarter of the year for a specified time. -Results range from `[1-4]`. + + +`date.quarter()` returns the quarter for a specified time. Results range from `[1-4]`. + + + +##### Function type signature ```js -import "date" - -date.quarter(t: 2019-07-17T12:05:21.012Z) - -// Returns 3 +(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. +### location + +Location used to determine timezone. +Default is the `location` option. + + + + ## Examples -##### Return the quarter for a time value +- [Return the quarter for a time value](#return-the-quarter-for-a-time-value) +- [Return the quarter for a relative duration](#return-the-quarter-for-a-relative-duration) + +### Return the quarter for a time value + ```js import "date" -date.quarter(t: 2020-02-11T12:21:03.293534940Z) +date.quarter(t: 2020-02-11T12:21:03.29353494Z)// Returns 1 -// Returns 1 ``` -##### Return the quarter for a relative duration + +### Return the quarter for a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.quarter(t: -7mo) +date.quarter(t: -7mo)// Returns 2 -// Returns 3 ``` + diff --git a/content/flux/v0.x/stdlib/date/scale.md b/content/flux/v0.x/stdlib/date/scale.md index 217ebf075..1a0a92c6f 100644 --- a/content/flux/v0.x/stdlib/date/scale.md +++ b/content/flux/v0.x/stdlib/date/scale.md @@ -1,50 +1,77 @@ --- title: date.scale() function description: > - `date.scale()` multiplies a duration by a specified value. + `date.scale()` will multiply the duration by the given value. menu: flux_0_x_ref: name: date.scale parent: date -weight: 301 -introduced: 0.167.0 + identifier: date/scale +weight: 101 flux/v0.x/tags: [date/time] --- -`date.scale()` multiplies a duration by a specified value. + + +`date.scale()` will multiply the duration by the given value. + + + +##### Function type signature ```js -import "date" - -date.scale(d: 1h, n: 12) - -// Returns 12h +(d: duration, n: int) => duration ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### d {data-type="duration"} -({{< req >}}) Duration to scale. +### d +({{< req >}}) +Duration to scale. + + + +### n +({{< req >}}) +Amount to scale the duration by. + + -### n {data-type="int"} -({{< req >}} Amount to scale the duration (`d`) by. ## Examples +- [Add n hours to a time](#add-n-hours-to-a-time) +- [Add scaled mixed duration to a time](#add-scaled-mixed-duration-to-a-time) + ### Add n hours to a time + ```js import "date" n = 5 d = date.scale(d: 1h, n: n) -date.add(d: d, to: 2022-05-10T00:00:00Z) +date.add(d: d, to: 2022-05-10T00:00:00Z)// Returns 2022-05-10T00:00:00.000000000Z -// Returns 2022-05-10T00:00:00.000000000Z ``` + ### Add scaled mixed duration to a time ```js @@ -53,7 +80,7 @@ import "date" n = 5 d = date.scale(d: 1mo1h, n: 5) -date.add(d: d, to: 2022-01-01T00:00:00Z) +date.add(d: d, to: 2022-01-01T00:00:00Z)// Returns 2022-06-01T05:00:00.000000000Z -// Returns 2022-06-01T05:00:00.000000000Z ``` + diff --git a/content/flux/v0.x/stdlib/date/second.md b/content/flux/v0.x/stdlib/date/second.md index f32a5da89..e06625215 100644 --- a/content/flux/v0.x/stdlib/date/second.md +++ b/content/flux/v0.x/stdlib/date/second.md @@ -1,56 +1,76 @@ --- title: date.second() function description: > - The `date.second()` function returns the second of a specified time. - Results range from `[0-59]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/second/ - - /influxdb/v2.0/reference/flux/stdlib/date/second/ - - /influxdb/cloud/reference/flux/stdlib/date/second/ + `date.second()` returns the second of a specified time. Results range from `[0 - 59]`. menu: flux_0_x_ref: name: date.second parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/second +weight: 101 --- -The `date.second()` function returns the second of a specified time. -Results range from `[0-59]`. + + +`date.second()` returns the second of a specified time. Results range from `[0 - 59]`. + + + +##### Function type signature ```js -import "date" - -date.second(t: 2019-07-17T12:05:21.012Z) - -// Returns 21 +(t: A) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. + ## Examples -##### Return the second of a time value +- [Return the second of a time value](#return-the-second-of-a-time-value) +- [Return the second of a relative duration](#return-the-second-of-a-relative-duration) + +### Return the second of a time value + ```js import "date" -date.second(t: 2020-02-11T12:21:03.293534940Z) +date.second(t: 2020-02-11T12:21:03.29353494Z)// Returns 3 -// Returns 3 ``` -##### Return the second of a relative duration + +### Return the second of a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.second(t: -50s) +date.second(t: -50s)// Returns 28 -// Returns 13 ``` + diff --git a/content/flux/v0.x/stdlib/date/sub.md b/content/flux/v0.x/stdlib/date/sub.md index 79ca1ad9f..b9bcc88ae 100644 --- a/content/flux/v0.x/stdlib/date/sub.md +++ b/content/flux/v0.x/stdlib/date/sub.md @@ -1,58 +1,106 @@ --- title: date.sub() function description: > - `date.sub()` subtracts a duration from a time value and returns the - resulting time value. + `date.sub()` subtracts a duration from a time value and returns the resulting time value. menu: flux_0_x_ref: name: date.sub parent: date -weight: 302 + identifier: date/sub +weight: 101 flux/v0.x/tags: [date/time] -aliases: - - /flux/v0.x/stdlib/date/subduration/ -related: - - /flux/v0.x/stdlib/date/addduration/ -introduced: 0.162.0 --- -`date.sub()` subtracts a duration from a time value and returns the -resulting time value. + + +`date.sub()` subtracts a duration from a time value and returns the resulting time value. + + + +##### Function type signature ```js -import "date" - -date.sub(d: 12h, from: now()) +(d: duration, from: A, ?location: {zone: string, offset: duration}) => time where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### d {data-type="duration"} +### from +({{< req >}}) +Time to subtract the duration from. + +Use an absolute time or a relative duration. +Durations are relative to `now()`. + +### d +({{< req >}}) Duration to subtract. -### from {data-type="time, duration"} -Time to subtract the [duration](#d) from. -Use an absolute time or a relative duration. -Durations are relative to [`now()`](/flux/v0.x/stdlib/universe/now/). + + +### location + +Location to use for the time value. + + + ## Examples +- [Subtract six hours from a timestamp](#subtract-six-hours-from-a-timestamp) +- [Subtract six hours from a relative duration](#subtract-six-hours-from-a-relative-duration) +- [Subtract two days from one hour ago](#subtract-two-days-from-one-hour-ago) + ### Subtract six hours from a timestamp + ```js import "date" -date.sub(d: 6h, from: 2019-09-16T12:00:00Z) +date.sub(from: 2019-09-16T12:00:00Z, d: 6h)// Returns 2019-09-16T06:00:00.000000000Z -// Returns 2019-09-16T06:00:00.000000000Z ``` + ### Subtract six hours from a relative duration + ```js import "date" option now = () => 2022-01-01T12:00:00Z -date.sub(d: 6h, from: -3h) +date.sub(d: 6h, from: -3h)// Returns 2022-01-01T03:00:00.000000000Z -// Returns 2022-01-01T03:00:00.000000000Z ``` + + +### Subtract two days from one hour ago + +A time may be represented as either an explicit timestamp +or as a relative time from the current `now` time. sub can +support either type of value. + +```js +import "date" + +option now = () => 2021-12-10T16:27:40Z + +date.sub(from: -1h, d: 2d)// Returns 2021-12-08T15:27:40Z + +``` + diff --git a/content/flux/v0.x/stdlib/date/truncate.md b/content/flux/v0.x/stdlib/date/truncate.md index 6998ae7c2..0ff2ac0bd 100644 --- a/content/flux/v0.x/stdlib/date/truncate.md +++ b/content/flux/v0.x/stdlib/date/truncate.md @@ -1,85 +1,114 @@ --- title: date.truncate() function description: > - The `date.truncate()` function truncates a time to a specified unit. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/truncate/ - - /influxdb/v2.0/reference/flux/stdlib/date/truncate/ - - /influxdb/cloud/reference/flux/stdlib/date/truncate/ + `date.truncate()` returns a time truncated to the specified duration unit. menu: flux_0_x_ref: name: date.truncate parent: date -weight: 301 -related: - - /flux/v0.x/stdlib/universe/today/ -introduced: 0.37.0 + identifier: date/truncate +weight: 101 --- -The `date.truncate()` function truncates a time to a specified unit. + + +`date.truncate()` returns a time truncated to the specified duration unit. + + + +##### Function type signature ```js -import "date" - -date.truncate( - t: 2019-07-17T12:05:21.012Z, - unit: 1s -) - -// Returns 2019-07-17T12:05:21.000000000Z +(t: A, unit: duration, ?location: {zone: string, offset: duration}) => time where A: Timeable ``` -{{% note %}} -#### Truncate to weeks -When truncating a time value to the week (`1w`), weeks are determined using the -**Unix epoch (1970-01-01T00:00:00Z UTC)**. The Unix epoch was on a Thursday, so -all calculated weeks begin on Thursday. -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. -### unit {data-type="duration"} -The unit of time to truncate to. +### unit +({{< req >}}) +Unit of time to truncate to. -{{% note %}} -Only use `1` and the unit of time to specify the `unit`. +Only use 1 and the unit of time to specify the unit. For example: `1s`, `1m`, `1h`. -{{% /note %}} + +### location + +Location used to determine timezone. +Default is the `location` option. + + + ## Examples -##### Truncate time values +- [Truncate time values](#truncate-time-values) +- [Truncate time values using relative durations](#truncate-time-values-using-relative-durations) + +### Truncate time values + ```js import "date" +import "timezone" + +option location = timezone.location(name: "Europe/Madrid") + +date.truncate(t: 2019-06-03T13:59:01Z, unit: 1s) -date.truncate(t: 2019-06-03T13:59:01.000000000Z, unit: 1s) // Returns 2019-06-03T13:59:01.000000000Z +date.truncate(t: 2019-06-03T13:59:01Z, unit: 1m) -date.truncate(t: 2019-06-03T13:59:01.000000000Z, unit: 1m) // Returns 2019-06-03T13:59:00.000000000Z +date.truncate(t: 2019-06-03T13:59:01Z, unit: 1h) -date.truncate(t: 2019-06-03T13:59:01.000000000Z, unit: 1h) // Returns 2019-06-03T13:00:00.000000000Z +date.truncate(t: 2019-06-03T13:59:01Z, unit: 1d) + +// Returns 2019-06-02T22:00:00.000000000Z +date.truncate(t: 2019-06-03T13:59:01Z, unit: 1mo) + +// Returns 2019-05-31T22:00:00.000000000Z +date.truncate(t: 2019-06-03T13:59:01Z, unit: 1y)// Returns 2018-12-31T23:00:00.000000000Z + ``` -##### Truncate time values using durations + +### Truncate time values using relative durations + ```js import "date" -option now = () => 2020-01-01T00:00:30.500000000Z +option now = () => 2020-01-01T00:00:30.5Z date.truncate(t: -30s, unit: 1s) + // Returns 2019-12-31T23:59:30.000000000Z - date.truncate(t: -1m, unit: 1m) -// Returns 2019-12-31T23:59:00.000000000Z -date.truncate(t: -1h, unit: 1h) -// Returns 2019-12-31T23:00:00.000000000Z +// Returns 2019-12-31T23:59:00.000000000Z +date.truncate(t: -1h, unit: 1h)// Returns 2019-12-31T23:00:00.000000000Z + ``` + diff --git a/content/flux/v0.x/stdlib/date/week.md b/content/flux/v0.x/stdlib/date/week.md index b9ce3354a..cca2867a1 100644 --- a/content/flux/v0.x/stdlib/date/week.md +++ b/content/flux/v0.x/stdlib/date/week.md @@ -1,56 +1,85 @@ --- title: date.week() function description: > - The `date.week()` function returns the ISO week of the year for a specified time. - Results range from `[1-53]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/week/ - - /influxdb/v2.0/reference/flux/stdlib/date/week/ - - /influxdb/cloud/reference/flux/stdlib/date/week/ + `date.week()` returns the ISO week of the year for a specified time. + Results range from `[1 - 53]`. menu: flux_0_x_ref: name: date.week parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/week +weight: 101 --- -The `date.week()` function returns the ISO week of the year for a specified time. -Results range from `[1-53]`. + + +`date.week()` returns the ISO week of the year for a specified time. +Results range from `[1 - 53]`. + + + +##### Function type signature ```js -import "date" - -date.week(t: 2019-07-17T12:05:21.012Z) - -// Returns 29 +(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. +### location + +Location used to determine timezone. +Default is the `location` option. + + + + ## Examples -##### Return the week of the year +- [Return the week of the year](#return-the-week-of-the-year) +- [Return the week of the year using a relative duration](#return-the-week-of-the-year-using-a-relative-duration) + +### Return the week of the year + ```js import "date" -date.week(t: 2020-02-11T12:21:03.293534940Z) +date.week(t: 2020-02-11T12:21:03.29353494Z)// Returns 7 -// Returns 7 ``` -##### Return the week of the year using a relative duration + +### Return the week of the year using a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.week(t: -12d) +date.week(t: -12d)// Returns 42 -// Returns 5 ``` + diff --git a/content/flux/v0.x/stdlib/date/weekday.md b/content/flux/v0.x/stdlib/date/weekday.md index 204abe49c..f565eccdd 100644 --- a/content/flux/v0.x/stdlib/date/weekday.md +++ b/content/flux/v0.x/stdlib/date/weekday.md @@ -1,57 +1,85 @@ --- title: date.weekDay() function description: > - The `date.weekDay()` function returns the day of the week for a specified time. - Results range from `[0-6]`. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/weekday/ - - /influxdb/v2.0/reference/flux/stdlib/date/weekday/ - - /influxdb/cloud/reference/flux/stdlib/date/weekday/ + `date.weekDay()` returns the day of the week for a specified time. + Results range from `[0 - 6]`. menu: flux_0_x_ref: name: date.weekDay parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/weekDay +weight: 101 --- -The `date.weekDay()` function returns the day of the week for a specified time. -Results range from `[0-6]` and correspond to `date` package -[weekday constants](/flux/v0.x/stdlib/date/#days-of-the-week). + + +`date.weekDay()` returns the day of the week for a specified time. +Results range from `[0 - 6]`. + + + +##### Function type signature ```js -import "date" - -date.weekDay(t: 2019-07-17T12:05:21.012Z) - -// Returns 3 +(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. +### location + +Location used to determine timezone. +Default is the `location` option. + + + + ## Examples -##### Return the day of the week for a time value +- [Return the day of the week for a time value](#return-the-day-of-the-week-for-a-time-value) +- [Return the day of the week for a relative duration](#return-the-day-of-the-week-for-a-relative-duration) + +### Return the day of the week for a time value + ```js import "date" -date.weekDay(t: 2020-02-11T12:21:03.293534940Z) +date.weekDay(t: 2020-02-11T12:21:03.29353494Z)// Returns 2 -// Returns 2 ``` -##### Return the day of the week for a relative duration + +### Return the day of the week for a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.weekDay(t: -84h) +date.weekDay(t: -84h)// Returns 6 -// Returns 6 ``` + diff --git a/content/flux/v0.x/stdlib/date/year.md b/content/flux/v0.x/stdlib/date/year.md index 11c38bc68..f6489db37 100644 --- a/content/flux/v0.x/stdlib/date/year.md +++ b/content/flux/v0.x/stdlib/date/year.md @@ -1,54 +1,83 @@ --- title: date.year() function description: > - The `date.year()` function returns the year of a specified time. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/year/ - - /influxdb/v2.0/reference/flux/stdlib/date/year/ - - /influxdb/cloud/reference/flux/stdlib/date/year/ + `date.year()` returns the year of a specified time. menu: flux_0_x_ref: name: date.year parent: date -weight: 301 -introduced: 0.39.0 + identifier: date/year +weight: 101 --- -The `date.year()` function returns the year of a specified time. + + +`date.year()` returns the year of a specified time. + + + +##### Function type signature ```js -import "date" - -date.year(t: 2019-07-17T12:05:21.012Z) - -// Returns 2019 +(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. +### location + +Location used to determine timezone. +Default is the `location` option. + + + + ## Examples -##### Return the year for a time value +- [Return the year for a time value](#return-the-year-for-a-time-value) +- [Return the year for a relative duration](#return-the-year-for-a-relative-duration) + +### Return the year for a time value + ```js import "date" -date.year(t: 2020-02-11T12:21:03.293534940Z) +date.year(t: 2020-02-11T12:21:03.29353494Z)// Returns 2020 -// Returns 2020 ``` -##### Return the year for a relative duration + +### Return the year for a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.year(t: -14y) +date.year(t: -14y)// Returns 2007 -// Returns 2006 ``` + diff --git a/content/flux/v0.x/stdlib/date/yearday.md b/content/flux/v0.x/stdlib/date/yearday.md index 58bae0640..7278a6ef7 100644 --- a/content/flux/v0.x/stdlib/date/yearday.md +++ b/content/flux/v0.x/stdlib/date/yearday.md @@ -1,56 +1,85 @@ --- title: date.yearDay() function description: > - The `date.yearDay()` function returns the day of the year for a specified time. - Results range from `[1-365]` for non-leap years, and `[1-366]` in leap years. -aliases: - - /influxdb/v2.0/reference/flux/functions/date/yearday/ - - /influxdb/v2.0/reference/flux/stdlib/date/yearday/ - - /influxdb/cloud/reference/flux/stdlib/date/yearday/ + `date.yearDay()` returns the day of the year for a specified time. + Results can include leap days and range from `[1 - 366]`. menu: flux_0_x_ref: name: date.yearDay parent: date -weight: 301 -introduced: 0.37.0 + identifier: date/yearDay +weight: 101 --- -The `date.yearDay()` function returns the day of the year for a specified time. -Results include leap days and range from `[1-366]`. + + +`date.yearDay()` returns the day of the year for a specified time. +Results can include leap days and range from `[1 - 366]`. + + + +##### Function type signature ```js -import "date" - -date.yearDay(t: 2019-07-17T12:05:21.012Z) - -// Returns 198 +(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### t {data-type="time, duration"} -The time to operate on. +### t +({{< req >}}) +Time to operate on. + Use an absolute time, relative duration, or integer. Durations are relative to `now()`. +### location + +Location used to determine timezone. +Default is the `location` option. + + + + ## Examples -##### Return the day of the year for a time value +- [Return the day of the year for a time value](#return-the-day-of-the-year-for-a-time-value) +- [Return the day of the year for a relative duration](#return-the-day-of-the-year-for-a-relative-duration) + +### Return the day of the year for a time value + ```js import "date" -date.yearDay(t: 2020-02-11T12:21:03.293534940Z) +date.yearDay(t: 2020-02-11T12:21:03.29353494Z)// Returns 42 -// Returns 42 ``` -##### Return the day of the year for a relative duration + +### Return the day of the year for a relative duration + ```js import "date" -option now = () => 2020-02-11T12:21:03.293534940Z +option now = () => 2020-02-11T12:21:03.29353494Z -date.yearDay(t: -1mo) +date.yearDay(t: -1mo)// Returns 276 -// Returns 11 ``` + diff --git a/content/flux/v0.x/stdlib/dict/_index.md b/content/flux/v0.x/stdlib/dict/_index.md index 99198e25a..260201e60 100644 --- a/content/flux/v0.x/stdlib/dict/_index.md +++ b/content/flux/v0.x/stdlib/dict/_index.md @@ -1,30 +1,44 @@ --- -title: Flux dict package -list_title: dict package +title: dict package description: > - The Flux `dict` package provides functions for interacting with dictionary types. - Import the `dict` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/dict/ - - /influxdb/cloud/reference/flux/stdlib/dict/ + The `dict` package provides functions for interacting with dictionary types. menu: flux_0_x_ref: - name: dict - parent: Standard library + name: dict + parent: stdlib + identifier: dict weight: 11 -flux/v0.x/tags: [package, functions] cascade: - related: - - /flux/v0.x/data-types/composite/dict/ -introduced: 0.97.0 + + introduced: 0.97.0 --- -The Flux `dict` package provides functions for interacting with -[dictionary types](/flux/v0.x/data-types/composite/dict). -Import the `dict` package. + + +The `dict` package provides functions for interacting with dictionary types. +Import the `dict` package: ```js import "dict" ``` + + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/dict/fromlist.md b/content/flux/v0.x/stdlib/dict/fromlist.md index 21df68bed..f55598c6c 100644 --- a/content/flux/v0.x/stdlib/dict/fromlist.md +++ b/content/flux/v0.x/stdlib/dict/fromlist.md @@ -1,44 +1,62 @@ --- title: dict.fromList() function description: > - The `dict.fromList()` function creates a dictionary from a list of records with - `key` and `value` properties. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/dict/fromlist/ - - /influxdb/cloud/reference/flux/stdlib/dict/fromlist/ + `dict.fromList()` creates a dictionary from a list of records with `key` and `value` + properties. menu: flux_0_x_ref: name: dict.fromList parent: dict -weight: 301 -introduced: 0.97.0 + identifier: dict/fromList +weight: 101 --- -The `dict.fromList()` function creates a dictionary from a list of records with -`key` and `value` properties. + + +`dict.fromList()` creates a dictionary from a list of records with `key` and `value` +properties. + + + +##### Function type signature ```js -import "dict" - -dict.fromList(pairs: [{key: 1, value: "foo"},{key: 2, value: "bar"}]) +(pairs: [{value: B, key: A}]) => [A:B] where A: Comparable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### pairs {data-type="array of records"} -({{< req >}}) List of records, each containing `key` and `value` properties. +### pairs +({{< req >}}) +List of records with `key` and `value` properties. + + + ## Examples -##### Create a dictionary from a list of records +### Create a dictionary from a list of records + ```js import "dict" -// Define a new dictionary using an array of records -d = dict.fromList(pairs: [{key: 1, value: "foo"}, {key: 2, value: "bar"}]) +d = dict.fromList(pairs: [{key: 1, value: "foo"}, {key: 2, value: "bar"}])// Returns [1: "foo", 2: "bar"] -// Return a property of the dictionary -dict.get(dict: d, key: 1, default: "") - -// Returns foo ``` + diff --git a/content/flux/v0.x/stdlib/dict/get.md b/content/flux/v0.x/stdlib/dict/get.md index dd89bffca..1b3a7b69e 100644 --- a/content/flux/v0.x/stdlib/dict/get.md +++ b/content/flux/v0.x/stdlib/dict/get.md @@ -1,57 +1,77 @@ --- title: dict.get() function description: > - The `dict.get()` function returns the value of a specified key in a dictionary - or a default value if the key does not exist. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/dict/get/ - - /influxdb/cloud/reference/flux/stdlib/dict/get/ + `dict.get()` returns the value of a specified key in a dictionary or a default value + if the key does not exist. menu: flux_0_x_ref: name: dict.get parent: dict -weight: 301 -introduced: 0.97.0 + identifier: dict/get +weight: 101 --- -The `dict.get()` function returns the value of a specified key in a dictionary -or a default value if the key does not exist. + + +`dict.get()` returns the value of a specified key in a dictionary or a default value +if the key does not exist. + + + +##### Function type signature ```js -import "dict" - -dict.get( - dict: [1: "foo", 2: "bar"], - key: 1, - default: "", -) +(default: A, dict: [B:A], key: B) => A where B: Comparable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -

- {{< req "All paremeters are required" >}} -

- -### dict {data-type="dict"} +### dict +({{< req >}}) Dictionary to return a value from. -### key {data-type="string, bool, int, uint, float, time, bytes"} + + +### key +({{< req >}}) Key to return from the dictionary. -### default {data-type="string, bool, int, uint, float, time, bytes"} -Default value to return if the `key` does not exist in the dictionary. -Must be the same type as values in the dictionary. + + +### default +({{< req >}}) +Default value to return if the key does not exist in the +dictionary. Must be the same type as values in the dictionary. + + + ## Examples -##### Return a property of a dictionary +### Return a property of a dictionary + ```js import "dict" d = [1: "foo", 2: "bar"] -dict.get(dict: d, key: 1, default: "") +dict.get(dict: d, key: 1, default: "")// Returns "foo" -// Returns foo ``` + diff --git a/content/flux/v0.x/stdlib/dict/insert.md b/content/flux/v0.x/stdlib/dict/insert.md index f9cb3d1e6..8a93bc914 100644 --- a/content/flux/v0.x/stdlib/dict/insert.md +++ b/content/flux/v0.x/stdlib/dict/insert.md @@ -1,77 +1,94 @@ --- title: dict.insert() function description: > - The `dict.insert()` function inserts a key value pair into a dictionary and - returns a new, updated dictionary. - If the key already exists in the dictionary, the function overwrites the existing value. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/dict/insert/ - - /influxdb/cloud/reference/flux/stdlib/dict/insert/ + `dict.insert()` inserts a key-value pair into a dictionary and returns a new, + updated dictionary. menu: flux_0_x_ref: name: dict.insert parent: dict -weight: 301 -introduced: 0.97.0 + identifier: dict/insert +weight: 101 --- -The `dict.insert()` function inserts a key value pair into a dictionary and returns -a new, updated dictionary. -If the key already exists in the dictionary, the function overwrites the existing value. + + +`dict.insert()` inserts a key-value pair into a dictionary and returns a new, +updated dictionary. + +If the key already exists in the dictionary, the function overwrites +the existing value. + +##### Function type signature ```js -import "dict" - -dict.insert( - dict: [1: "foo", 2: "bar"], - key: 3, - value: "baz", -) +(dict: [A:B], key: A, value: B) => [A:B] where A: Comparable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -

- {{< req "All paremeters are required" >}} -

- -### dict {data-type="dict"} +### dict +({{< req >}}) Dictionary to update. -### key {data-type="string, bool, int, uint, float, time, bytes"} -Key to insert into the dictionary. -Must be the same type as existing keys in the dictionary. -### default {data-type="string, bool, int, uint, float, time, bytes"} + +### key +({{< req >}}) +Key to insert into the dictionary. +Must be the same type as the existing keys in the dictionary. + + + +### value +({{< req >}}) Value to insert into the dictionary. -Must be the same type as existing values in the dictionary. +Must be the same type as the existing values in the dictionary. + + + ## Examples -##### Insert a new key-value pair into a dictionary +- [Insert a new key-value pair into the a dictionary](#insert-a-new-key-value-pair-into-the-a-dictionary) +- [Overwrite an existing key-value pair in a dictionary](#overwrite-an-existing-key-value-pair-in-a-dictionary) + +### Insert a new key-value pair into the a dictionary + ```js import "dict" d = [1: "foo", 2: "bar"] -dNew = dict.insert(dict: d, key: 3, value: "baz") +dict.insert(dict: d, key: 3, value: "baz")// Returns [1: "foo", 2: "bar", 3: "baz"] -// Verify the new key-value pair was inserted -dict.get(dict: dNew, key: 3, default: "") - -// Returns baz ``` -##### Overwrite an existing key-value pair in a dictionary + +### Overwrite an existing key-value pair in a dictionary + ```js import "dict" d = [1: "foo", 2: "bar"] -dNew = dict.insert(dict: d, key: 2, value: "baz") +dict.insert(dict: d, key: 2, value: "baz")// Returns [1: "foo", 2: "baz"] -// Verify the new key-value pair was overwritten -dict.get(dict: dNew, key: 2, default: "") - -// Returns baz ``` + diff --git a/content/flux/v0.x/stdlib/dict/remove.md b/content/flux/v0.x/stdlib/dict/remove.md index 683fe2d00..a677ced6c 100644 --- a/content/flux/v0.x/stdlib/dict/remove.md +++ b/content/flux/v0.x/stdlib/dict/remove.md @@ -1,56 +1,71 @@ --- title: dict.remove() function description: > - The `dict.remove()` function removes a key value pair from a dictionary and returns - an updated dictionary. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/dict/remove/ - - /influxdb/cloud/reference/flux/stdlib/dict/remove/ + `dict.remove()` removes a key value pair from a dictionary and returns an updated + dictionary. menu: flux_0_x_ref: name: dict.remove parent: dict -weight: 301 -introduced: 0.97.0 + identifier: dict/remove +weight: 101 --- -The `dict.remove()` function removes a key value pair from a dictionary and returns -an updated dictionary. + + +`dict.remove()` removes a key value pair from a dictionary and returns an updated +dictionary. + + + +##### Function type signature ```js -import "dict" - -dict.remove(dict: [1: "foo", 2: "bar"], key: 1) +(dict: [A:B], key: A) => [A:B] where A: Comparable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -

- {{< req "All paremeters are required" >}} -

+### dict +({{< req >}}) +Dictionary to remove the key-value pair from. -### dict {data-type="dict"} -Dictionary to remove a key-value pair from. -### key {data-type="string, bool, int, uint, float, time, bytes"} + +### key +({{< req >}}) Key to remove from the dictionary. Must be the same type as existing keys in the dictionary. + + + ## Examples -##### Remove a property from a dictionary +### Remove a property from a dictionary + ```js import "dict" d = [1: "foo", 2: "bar"] -dNew = dict.remove(dict: d, key: 1) +dict.remove(dict: d, key: 1)// Returns [2: "bar"] -// Verify the key-value pairs was removed - -dict.get(dict: dNew, key: 1, default: "") -// Returns an empty string - -dict.get(dict: dNew, key: 2, default: "") -// Returns bar ``` + diff --git a/content/flux/v0.x/stdlib/experimental/_index.md b/content/flux/v0.x/stdlib/experimental/_index.md index 7c7ab571c..38d24cd12 100644 --- a/content/flux/v0.x/stdlib/experimental/_index.md +++ b/content/flux/v0.x/stdlib/experimental/_index.md @@ -1,43 +1,54 @@ --- -title: Flux experimental package -list_title: experimental package +title: experimental package description: > - The Flux experimental package includes experimental functions that perform various tasks. - Experimental functions are subject to change at any time and are not recommended for production use. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/ - - /influxdb/cloud/reference/flux/stdlib/experimental/ + The `experimental` package includes experimental functions and packages. menu: flux_0_x_ref: - name: experimental - parent: Standard library + name: experimental + parent: stdlib + identifier: experimental weight: 11 -flux/v0.x/tags: [functions, experimental, package] +cascade: + + introduced: 0.39.0 --- -The Flux Experimental package includes experimental functions that perform various tasks. + + +The `experimental` package includes experimental functions and packages. +Import the `experimental` package: ```js import "experimental" ``` +### Experimental packages are subject to change +Please note that experimental packages and functions may: + +- be moved or promoted to a permanent location +- undergo API changes +- stop working with no planned fixes +- be removed without warning or explanation + + +## Functions + {{< children type="functions" show="pages" >}} -## Experimental packages -Experimental packages require different import paths than base experimental functions. +## Packages {{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/experimental/addduration.md b/content/flux/v0.x/stdlib/experimental/addduration.md index a3c780b7d..60f473f6e 100644 --- a/content/flux/v0.x/stdlib/experimental/addduration.md +++ b/content/flux/v0.x/stdlib/experimental/addduration.md @@ -1,68 +1,107 @@ --- title: experimental.addDuration() function description: > - The `experimental.addDuration()` function adds a duration to a time value and - returns the resulting time. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/addduration/ - - /influxdb/cloud/reference/flux/stdlib/experimental/addduration/ + `experimental.addDuration()` adds a duration to a time value and returns the resulting time value. menu: flux_0_x_ref: name: experimental.addDuration parent: experimental -weight: 302 + identifier: experimental/addDuration +weight: 101 flux/v0.x/tags: [date/time] -related: - - /flux/v0.x/stdlib/experimental/subduration/ -introduced: 0.39.0 deprecated: 0.162.0 --- -{{% warn %}} -This function was promoted to the [`date` package](/flux/v0.x/stdlib/date/add/) -in **Flux v0.162.0**. This experimental version has been deprecated. -{{% /warn %}} + + +`experimental.addDuration()` adds a duration to a time value and returns the resulting time value. + + + +##### Function type signature ```js -import "experimental" - -experimental.addDuration( - d: 12h, - to: now(), -) +(d: duration, to: A, ?location: {zone: string, offset: duration}) => time where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### d {data-type="duration"} -The duration to add. +### d +({{< req >}}) +Duration to add. + + + +### to +({{< req >}}) +Time to add the duration to. + + + +### location + +Location to use for the time value. -### to {data-type="time, duration"} -The time to add the [duration](#d) to. Use an absolute time or a relative duration. -Durations are relative to [`now()`](/flux/v0.x/stdlib/universe/now/). +Durations are relative to `now()`. + ## Examples +- [Add six hours to a timestamp](#add-six-hours-to-a-timestamp) +- [Add one month to yesterday](#add-one-month-to-yesterday) +- [Add six hours to a relative duration](#add-six-hours-to-a-relative-duration) + ### Add six hours to a timestamp + ```js import "experimental" -experimental.addDuration(d: 6h, to: 2019-09-16T12:00:00Z) +experimental.addDuration(d: 6h, to: 2019-09-16T12:00:00Z)// Returns 2019-09-16T18:00:00.000000000Z -// Returns 2019-09-16T18:00:00.000000000Z ``` + +### Add one month to yesterday + +A time may be represented as either an explicit timestamp +or as a relative time from the current `now` time. addDuration can +support either type of value. + +```js +import "experimental" + +option now = () => 2021-12-10T16:27:40Z + +experimental.addDuration(d: 1mo, to: -1d)// Returns 2022-01-09T16:27:40Z + +``` + + ### Add six hours to a relative duration + ```js import "experimental" option now = () => 2022-01-01T12:00:00Z -experimental.addDuration(d: 6h, to: 3h) +experimental.addDuration(d: 6h, to: 3h)// Returns 2022-01-01T21:00:00.000000000Z -// Returns 2022-01-01T21:00:00.000000000Z ``` + diff --git a/content/flux/v0.x/stdlib/experimental/aggregate/_index.md b/content/flux/v0.x/stdlib/experimental/aggregate/_index.md index 662468f05..bd5c8c9b8 100644 --- a/content/flux/v0.x/stdlib/experimental/aggregate/_index.md +++ b/content/flux/v0.x/stdlib/experimental/aggregate/_index.md @@ -1,27 +1,44 @@ --- -title: Flux experimental aggregate package -list_title: aggregate package +title: aggregate package description: > - The Flux experimental `aggregate` package provides functions to simplify common aggregate operations. - Import the `experimental/aggregate` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/aggregate/ - - /influxdb/cloud/reference/flux/stdlib/experimental/aggregate/ + The `aggregate` package provides functions to simplify common aggregate operations. menu: flux_0_x_ref: - name: aggregate + name: aggregate parent: experimental -weight: 301 -flux/v0.x/tags: [package] -introduced: 0.61.0 + identifier: experimental/aggregate +weight: 21 +cascade: + + introduced: 0.61.0 --- -The Flux experimental `aggregate` package provides functions to simplify common aggregate operations. + + +The `aggregate` package provides functions to simplify common aggregate operations. Import the `experimental/aggregate` package: ```js import "experimental/aggregate" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/aggregate/rate.md b/content/flux/v0.x/stdlib/experimental/aggregate/rate.md index 9243e0048..60d6f3cbc 100644 --- a/content/flux/v0.x/stdlib/experimental/aggregate/rate.md +++ b/content/flux/v0.x/stdlib/experimental/aggregate/rate.md @@ -1,57 +1,76 @@ --- title: aggregate.rate() function description: > - The `aggregate.rate()` function calculates the rate of change per windows of time. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/aggregate/rate/ - - /influxdb/cloud/reference/flux/stdlib/experimental/aggregate/rate/ + `aggregate.rate()` calculates the rate of change per windows of time for each input table. menu: flux_0_x_ref: name: aggregate.rate - parent: aggregate -weight: 301 -flux/v0.x/tags: [transformations, aggregate] -related: - - /{{< latest "influxdb" >}}/query-data/flux/rate/ -introduced: 0.61.0 + parent: experimental/aggregate + identifier: experimental/aggregate/rate +weight: 201 +flux/v0.x/tags: [transformations, aggregates] --- -The `aggregate.rate()` function calculates the rate of change per windows of time -for each input table. + + +`aggregate.rate()` calculates the rate of change per windows of time for each input table. + +`aggregate.rate()` requires that input data have `_start` and `_stop` columns +to calculate windows of time to operate on. +Use `range()` to assign `_start` and `_stop` values. + +##### Function type signature ```js -import "experimental/aggregate" - -aggregate.rate( - every: 1m, - groupColumns: ["column1", "column2"], - unit: 1s, -) +(<-tables: stream[A], every: duration, ?groupColumns: [string], ?unit: duration) => stream[B] where A: Record, B: Record ``` -`aggregate.rate()` requires that input data have `_start` and `_stop` columns to -calculate windows of time to operate on. Use [`range()`](/flux/v0.x/stdlib/universe/range/) -to assign `_start` and `_stop` values. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### every {data-type="duration"} -({{< req >}}) Duration of time windows. +### every +({{< req >}}) +Duration of time windows. + + + +### groupColumns -### groupColumns {data-type="array of strings"} List of columns to group by. Default is `[]`. -### unit {data-type="duration"} -The time duration to use when calculating the rate. Default is `1s`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + +### unit + +Time duration to use when calculating the rate. Default is `1s`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -### Calculate the average rate of change in sample data -{{% flux/sample-example-intro %}} +### Calculate the average rate of change in data ```js import "experimental/aggregate" @@ -66,45 +85,40 @@ data ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -##### Input data -{{% flux/sample set="int" includeRange=true %}} +{{% expand "View example input and ouput" %}} -##### Output data -| _start | _stop | _time | tag | _value | -| :------------------ | :------------------ | :------------------ | :-- | -----: | -| 2021-01-01T00:00:00 | 2021-01-01T00:01:00 | 2021-01-01T00:00:30 | t1 | 1.2 | -| 2021-01-01T00:00:00 | 2021-01-01T00:01:00 | 2021-01-01T00:01:00 | t1 | 1.0 | +#### Input data + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *_start | *_stop | *tag | _value | _time | +| -------------------- | -------------------- | ---- | ------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 1.2 | 2021-01-01T00:00:30Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 1 | 2021-01-01T00:01:00Z | + +| *_start | *_stop | *tag | _value | _time | +| -------------------- | -------------------- | ---- | ------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | | 2021-01-01T00:00:30Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 2.2 | 2021-01-01T00:01:00Z | -| _start | _stop | _time | tag | _value | -| :------------------ | :------------------ | :------------------ | :-- | -----: | -| 2021-01-01T00:00:00 | 2021-01-01T00:01:00 | 2021-01-01T00:00:30 | t2 | | -| 2021-01-01T00:00:00 | 2021-01-01T00:01:00 | 2021-01-01T00:01:00 | t2 | 2.2 | {{% /expand %}} {{< /expand-wrapper >}} - -## Function definition -```js -package aggregate - -import "experimental" - -rate = (tables=<-, every, groupColumns=[], unit=1s) => - tables - |> derivative(nonNegative:true, unit:unit) - |> aggregateWindow(every: every, fn : (tables=<-, column) => - tables - |> mean(column: column) - |> group(columns: groupColumns) - |> experimental.group(columns: ["_start", "_stop"], mode:"extend") - |> sum() - ) -``` - -_**Used functions:**_ -[aggregateWindow()](/flux/v0.x/stdlib/universe/aggregatewindow/) -[derivative()](/flux/v0.x/stdlib/universe/derivative/) -[experimental.group()](/flux/v0.x/stdlib/experimental/group/) -[group()](/flux/v0.x/stdlib/universe/group/) -[mean()](/flux/v0.x/stdlib/universe/mean/) -[sum()](/flux/v0.x/stdlib/universe/sum/) diff --git a/content/flux/v0.x/stdlib/experimental/aligntime.md b/content/flux/v0.x/stdlib/experimental/aligntime.md index 45927bfb0..9bc268707 100644 --- a/content/flux/v0.x/stdlib/experimental/aligntime.md +++ b/content/flux/v0.x/stdlib/experimental/aligntime.md @@ -1,97 +1,111 @@ --- title: experimental.alignTime() function description: > - The `experimental.alignTime()` function aligns input tables to a common start time. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/aligntime/ - - /influxdb/cloud/reference/flux/stdlib/experimental/aligntime/ + `experimental.alignTime()` shifts time values in input tables to all start at a common start time. menu: flux_0_x_ref: name: experimental.alignTime parent: experimental -weight: 302 -flux/v0.x/tags: [transformations, date/time] + identifier: experimental/alignTime +weight: 101 +flux/v0.x/tags: [transformations, data/time] introduced: 0.66.0 --- -The `experimental.alignTime()` function aligns input tables to a common start time. + + +`experimental.alignTime()` shifts time values in input tables to all start at a common start time. + + + +##### Function type signature ```js -import "experimental" - -experimental.alignTime( - alignTo: 1970-01-01T00:00:00.000000000Z -) +(<-tables: stream[B], ?alignTo: A) => stream[C] where B: Record, C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### alignTo {data-type="time"} -The **UTC time** to align tables to. -Default is `1970-01-01T00:00:00Z`. +### alignTo + +Time to align tables to. Default is `1970-01-01T00:00:00Z`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). ## Examples -### Compare values month-over-month +### Compare month-over-month values + +1. Window data by calendar month creating two separate tables (one for January and one for February). +2. Align tables to `2021-01-01T00:00:00Z`. + +Each output table represents data from a calendar month. +When visualized, data is still grouped by month, but timestamps are aligned +to a common start time and values can be compared by time. + ```js import "experimental" -from(bucket: "example-bucket") - |> range(start: -12mo) - |> filter(fn: (r) => r._measurement == "example-measurement") +data |> window(every: 1mo) - |> experimental.alignTime() + |> experimental.alignTime(alignTo: 2021-01-01T00:00:00Z) ``` -**Given the following input:** +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| _time | _value | -|:----- | ------:| -| 2020-01-01T00:00:00Z | 32.1 | -| 2020-01-02T00:00:00Z | 32.9 | -| 2020-01-03T00:00:00Z | 33.2 | -| 2020-01-04T00:00:00Z | 34.0 | -| 2020-02-01T00:00:00Z | 38.3 | -| 2020-02-02T00:00:00Z | 38.4 | -| 2020-02-03T00:00:00Z | 37.8 | -| 2020-02-04T00:00:00Z | 37.5 | +#### Input data -**The following functions:** +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-01T00:00:00Z | 32.1 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-02T00:00:00Z | 32.9 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-03T00:00:00Z | 33.2 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-04T00:00:00Z | 34 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-01T00:00:00Z | 38.3 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-02T00:00:00Z | 38.4 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-03T00:00:00Z | 37.8 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-04T00:00:00Z | 37.5 | -1. Window data by calendar month creating two separate tables (one for January and one for February). -2. Align tables to `2020-01-01T00:00:00Z`. -```js -//... - |> window(every: 1mo) - |> alignTime(alignTo: 2020-01-01T00:00:00Z) -``` +#### Output data -**And output:** +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-01T00:00:00Z | 32.1 | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-02T00:00:00Z | 32.9 | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-03T00:00:00Z | 33.2 | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-04T00:00:00Z | 34 | -{{< flex >}} -{{% flex-content %}} -| _time | _value | -|:----- | ------:| -| 2020-01-01T00:00:00Z | 32.1 | -| 2020-01-02T00:00:00Z | 32.9 | -| 2020-01-03T00:00:00Z | 33.2 | -| 2020-01-04T00:00:00Z | 34.0 | -{{% /flex-content %}} -{{% flex-content %}} -| _time | _value | -|:----- | ------:| -| 2020-01-01T00:00:00Z | 38.3 | -| 2020-01-02T00:00:00Z | 38.4 | -| 2020-01-03T00:00:00Z | 37.8 | -| 2020-01-04T00:00:00Z | 37.5 | -{{% /flex-content %}} -{{< /flex >}} +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-01T00:00:00Z | 38.3 | +| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-02T00:00:00Z | 38.4 | +| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-03T00:00:00Z | 37.8 | +| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-04T00:00:00Z | 37.5 | -Each output table represents data from a calendar month. -When visualized, data is still grouped by month, but timestamps are aligned to a -common start time and values can be compared by time. +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/array/_index.md b/content/flux/v0.x/stdlib/experimental/array/_index.md index dc8ae2bb0..f55177946 100644 --- a/content/flux/v0.x/stdlib/experimental/array/_index.md +++ b/content/flux/v0.x/stdlib/experimental/array/_index.md @@ -1,35 +1,44 @@ --- -title: Flux experimental array package -list_title: array package +title: array package description: > - The Flux experimental `array` package provides functions for operating on Flux arrays. - Import the `experimental/array` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/array/ - - /influxdb/cloud/reference/flux/stdlib/experimental/array/ - - /influxdb/v2.0/reference/flux/stdlib/array/ - - /influxdb/cloud/reference/flux/stdlib/array/ + The `array` package provides functions for manipulating arrays and for building tables from Flux arrays. menu: flux_0_x_ref: - name: array - identifier: exp-array + name: array parent: experimental -weight: 11 -flux/v0.x/tags: [functions, array, package] + identifier: experimental/array +weight: 21 cascade: - related: - - /flux/v0.x/data-types/composite/array/ -introduced: 0.79.0 + flux/v0.x/tags: [array, tables] + introduced: 0.79.0 --- -The experimental `array` package provides functions for operating on Flux -[arrays](/flux/v0.x/data-types/composite/array/). + + +The `array` package provides functions for manipulating arrays and for building tables from Flux arrays. Import the `experimental/array` package: ```js import "experimental/array" ``` + + + ## Functions {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/array/concat.md b/content/flux/v0.x/stdlib/experimental/array/concat.md index 728554071..0ba6d929e 100644 --- a/content/flux/v0.x/stdlib/experimental/array/concat.md +++ b/content/flux/v0.x/stdlib/experimental/array/concat.md @@ -1,44 +1,66 @@ --- title: array.concat() function description: > - `array.concat` appends two arrays and returns a new array. + `array.concat()` appends two arrays and returns a new array. menu: flux_0_x_ref: name: array.concat - parent: exp-array -weight: 301 -flux/v0.x/tags: [array] + parent: experimental/array + identifier: experimental/array/concat +weight: 201 + introduced: 0.155.0 --- + + `array.concat()` appends two arrays and returns a new array. + + +Neither input array is mutated and a new array is returned. + +##### Function type signature + ```js -import "experimental/array" - -array.concat( - arr: [1,2], - v: [3,4], -) - -// Returns [1, 2, 3, 4] +(<-arr: [A], v: [A]) => [A] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### arr {data-type="array"} +### arr + First array. Default is the piped-forward array (`<-`). -### v {data-type="array"} + + +### v +({{< req >}}) Array to append to the first array. -{{% note %}} -Neither input array is mutated and a new array is returned. -{{% /note %}} + + ## Examples ### Merge two arrays + ```js import "experimental/array" @@ -46,8 +68,25 @@ a = [1, 2, 3] b = [4, 5, 6] c = a |> array.concat(v: b) -// Returns [1, 2, 3, 4, 5, 6] +// Returns [1, 2, 3, 4, 5, 6] // Output each value in the array as a row in a table array.from(rows: c |> array.map(fn: (x) => ({_value: x}))) ``` + +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| _value | +| ------- | +| 1 | +| 2 | +| 3 | +| 4 | +| 5 | +| 6 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/array/filter.md b/content/flux/v0.x/stdlib/experimental/array/filter.md index 0f7279f35..818930642 100644 --- a/content/flux/v0.x/stdlib/experimental/array/filter.md +++ b/content/flux/v0.x/stdlib/experimental/array/filter.md @@ -1,71 +1,94 @@ --- title: array.filter() function description: > - `array.filter` iterates over an array, evaluates each element with a predicate - function, and then returns a new array with only elements that match the predicate. + `array.filter()` iterates over an array, evaluates each element with a predicate function, and then returns + a new array with only elements that match the predicate. menu: flux_0_x_ref: name: array.filter - parent: exp-array -weight: 301 -flux/v0.x/tags: [array] + parent: experimental/array + identifier: experimental/array/filter +weight: 201 + introduced: 0.155.0 --- -`array.filter()` iterates over an array, evaluates each element with a predicate -function, and then returns a new array with only elements that match the predicate. + + +`array.filter()` iterates over an array, evaluates each element with a predicate function, and then returns +a new array with only elements that match the predicate. + + + +##### Function type signature ```js -import "experimental/array" - -array.filter( - arr: [1, 2, 3, 4, 5], - fn: (x) => x >= 3, -) - -// Returns [3, 4, 5] +(<-arr: [A], fn: (x: A) => bool) => [A] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### arr {data-type="array"} +### arr + Array to filter. Default is the piped-forward array (`<-`). -### fn {data-type="function"} + + +### fn +({{< req >}}) Predicate function to evaluate on each element. The element is represented by `x` in the predicate function. + + + ## Examples -### Filter an array of integers +### Filter array of integers + ```js import "experimental/array" -a = [1, 2, 3, 4, 5] +a = [ + 1, + 2, + 3, + 4, + 5, +] b = a |> array.filter(fn: (x) => x >= 3) -// b returns [3, 4, 5] +// b returns [3, 4, 5] // Output the filtered array as a table array.from(rows: b |> array.map(fn: (x) => ({_value: x}))) ``` -### Filter an array of records -```js -import "experimental/array" +{{< expand-wrapper >}} +{{% expand "View example output" %}} -a = - [ - {a: 1, b: 2, c: 3}, - {a: 4, b: 5, c: 6}, - {a: 7, b: 8, c: 9} - ] +#### Output data -b = a |> array.filter(fn: (x) => x.b >= 3) -// b returns [ -// {a: 4, b: 5, c: 6}, -// {a: 7, b: 8, c: 9}, -// ] +| _value | +| ------- | +| 3 | +| 4 | +| 5 | -// Output the filtered array as a table -array.from(rows: b) -``` +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/array/from.md b/content/flux/v0.x/stdlib/experimental/array/from.md new file mode 100644 index 000000000..d74624d85 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/array/from.md @@ -0,0 +1,98 @@ +--- +title: array.from() function +description: > + `array.from()` constructs a table from an array of records. +menu: + flux_0_x_ref: + name: array.from + parent: experimental/array + identifier: experimental/array/from +weight: 201 + +deprecated: 0.103.0 +--- + + + +`array.from()` constructs a table from an array of records. + +The `experimental/array.from()` function was promoted to the `array` package in +Flux 0.103.0. This function is available for backwards compatibility, but we +recommend using the `array` package instead. + + +Each record in the array is converted into an output row or record. All +records must have the same keys and data types. + +##### Function type signature + +```js +(rows: [A]) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### rows +({{< req >}}) +Array of records to construct a table with. + + + + +## Examples + +- [Build an arbitrary table](#build-an-arbitrary-table) +- [Union custom rows with query results](#union-custom-rows-with-query-results) + +### Build an arbitrary table + +```js +import "experimental/array" + +rows = [{foo: "bar", baz: 21.2}, {foo: "bar", baz: 23.8}] + +array.from(rows: rows) +``` + +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| foo | baz | +| ---- | ---- | +| bar | 21.2 | +| bar | 23.8 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Union custom rows with query results + +```js +import "influxdata/influxdb/v1" +import "experimental/array" + +tags = v1.tagValues(bucket: "example-bucket", tag: "host") + +wildcard_tag = array.from(rows: [{_value: "*"}]) + +union(tables: [tags, wildcard_tag]) +``` + diff --git a/content/flux/v0.x/stdlib/experimental/array/map.md b/content/flux/v0.x/stdlib/experimental/array/map.md index 3ba8363de..a1ace5402 100644 --- a/content/flux/v0.x/stdlib/experimental/array/map.md +++ b/content/flux/v0.x/stdlib/experimental/array/map.md @@ -1,70 +1,95 @@ --- title: array.map() function description: > - `array.map` iterates over an array, applies a function to each element to - produce a new element, and then returns a new array. + `array.map()` iterates over an array, applies a function to each element to produce a new element, + and then returns a new array. menu: flux_0_x_ref: name: array.map - parent: exp-array -weight: 301 -flux/v0.x/tags: [array] + parent: experimental/array + identifier: experimental/array/map +weight: 201 + introduced: 0.155.0 --- -`array.map()` iterates over an array, applies a function to each element to -produce a new element, and then returns a new array. + + +`array.map()` iterates over an array, applies a function to each element to produce a new element, +and then returns a new array. + + + +##### Function type signature ```js -import "experimental/array" - -array.map( - arr: [1, 2, 3, 4], - fn: (x) => x * 2, -) - -// Returns [2, 4, 6, 8] +(<-arr: [A], fn: (x: A) => B) => [B] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### arr {data-type="array"} -Array to operate on. Default is the piped-forward array (`<-`). +### arr -### fn {data-type="function"} +Array to operate on. Defaults is the piped-forward array (`<-`). + + + +### fn +({{< req >}}) Function to apply to elements. The element is represented by `x` in the function. + + + ## Examples ### Convert an array of integers to an array of records + ```js import "experimental/array" -a = [1, 2, 3, 4, 5] +a = [ + 1, + 2, + 3, + 4, + 5, +] b = a |> array.map(fn: (x) => ({_value: x})) + // b returns [{_value: 1}, {_value: 2}, {_value: 3}, {_value: 4}, {_value: 5}] - // Output the array of records as a table -> array.from(rows: b) -``` - -### Iterate over and modify an array of records -```js -a = - [ - {a: 1, b: 2, c: 3}, - {a: 4, b: 5, c: 6}, - {a: 7, b: 8, c: 9}, - ] - -b = a |> array.map(fn: (x) => ({x with a: x.a * x.a, d: x.b + x.c})) -// b returns: -// [ -// {a: 1, b: 2, c: 3, d: 5}, -// {a: 16, b: 5, c: 6, d: 11}, -// {a: 49, b: 8, c: 9, d: 17} -// ] - -// Output the modified array of records as a table array.from(rows: b) ``` + +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| _value | +| ------- | +| 1 | +| 2 | +| 3 | +| 4 | +| 5 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bigtable/_index.md b/content/flux/v0.x/stdlib/experimental/bigtable/_index.md index 50eeb68af..d5492d0c4 100644 --- a/content/flux/v0.x/stdlib/experimental/bigtable/_index.md +++ b/content/flux/v0.x/stdlib/experimental/bigtable/_index.md @@ -1,22 +1,36 @@ --- -title: Flux bigtable package -list_title: bigtable package +title: bigtable package description: > - The Flux `bigtable` package provides tools for working with data in Google Cloud Bigtable databases. - Import the `experimental/bigtable` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/bigtable/ - - /influxdb/cloud/reference/flux/stdlib/experimental/bigtable/ + The `bigtable` package provides tools for working with data in + [Google Cloud Bigtable](https://cloud.google.com/bigtable/) databases. menu: flux_0_x_ref: - name: bigtable + name: bigtable parent: experimental -weight: 301 -flux/v0.x/tags: [functions, bigtable, package, google] -introduced: 0.45.0 + identifier: experimental/bigtable +weight: 21 +cascade: + + introduced: 0.45.0 --- -The Flux `bigtable` package provides tools for working with data in + + +The `bigtable` package provides tools for working with data in [Google Cloud Bigtable](https://cloud.google.com/bigtable/) databases. Import the `experimental/bigtable` package: @@ -24,5 +38,9 @@ Import the `experimental/bigtable` package: import "experimental/bigtable" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/bigtable/from.md b/content/flux/v0.x/stdlib/experimental/bigtable/from.md index afc2a217f..e72d283ce 100644 --- a/content/flux/v0.x/stdlib/experimental/bigtable/from.md +++ b/content/flux/v0.x/stdlib/experimental/bigtable/from.md @@ -1,72 +1,81 @@ --- title: bigtable.from() function description: > - The `bigtable.from()` function retrieves data from a Google Cloud Bigtable data source. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/bigtable/from/ - - /influxdb/cloud/reference/flux/stdlib/experimental/bigtable/from/ + `bigtable.from()` retrieves data from a [Google Cloud Bigtable](https://cloud.google.com/bigtable/) data source. menu: flux_0_x_ref: name: bigtable.from - parent: bigtable -weight: 401 + parent: experimental/bigtable + identifier: experimental/bigtable/from +weight: 201 flux/v0.x/tags: [inputs] -introduced: 0.45.0 --- -The `bigtable.from()` function retrieves data from a [Google Cloud Bigtable](https://cloud.google.com/bigtable/) -data source. + + +`bigtable.from()` retrieves data from a [Google Cloud Bigtable](https://cloud.google.com/bigtable/) data source. + + + +##### Function type signature ```js -import "experimental/bigtable" - -bigtable.from( - token: "mySuPeRseCretTokEn", - project: "exampleProjectID", - instance: "exampleInstanceID", - table: "example-table", -) +(instance: string, project: string, table: string, token: string) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### token {data-type="string"} -The Google Cloud IAM token to use to access the Cloud Bigtable database. - -_For more information, see the following:_ +### token +({{< req >}}) +Google Cloud IAM token to use to access the Cloud Bigtable database. +For more information, see the following: - [Cloud Bigtable Access Control](https://cloud.google.com/bigtable/docs/access-control) - [Google Cloud IAM How-to guides](https://cloud.google.com/iam/docs/how-to) - [Setting Up Authentication for Server to Server Production Applications on Google Cloud](https://cloud.google.com/docs/authentication/production) -### project {data-type="string"} -The project ID of the Cloud Bigtable project to retrieve data from. +### project +({{< req >}}) +Cloud Bigtable project ID. + + + +### instance +({{< req >}}) +Cloud Bigtable instance ID. + + + +### table +({{< req >}}) +Cloud Bigtable table name. + -### instance {data-type="string"} -The instance ID of the Cloud Bigtable instance to retrieve data from. -### table {data-type="string"} -The name of the Cloud Bigtable table to retrieve data from. ## Examples -{{% note %}} -The example below uses [InfluxDB secrets](/{{< latest "influxdb" >}}/security/secrets/) -to populate sensitive connection credentials. -{{% /note %}} +### Query Google Cloud Bigtable ```js import "experimental/bigtable" -import "influxdata/influxdb/secrets" -bigtable_token = secrets.get(key: "BIGTABLE_TOKEN") -bigtable_project = secrets.get(key: "BIGTABLE_PROJECT_ID") -bigtable_instance = secrets.get(key: "BIGTABLE_INSTANCE_ID") - -bigtable.from( - token: bigtable_token, - project: bigtable_project, - instance: bigtable_instance, - table: "example-table" -) +bigtable.from(token: "example-token", project: "example-project", instance: "example-instance", table: "example-table") ``` + diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/_index.md b/content/flux/v0.x/stdlib/experimental/bitwise/_index.md index d2916ab6a..0e21e2b9c 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/_index.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/_index.md @@ -1,30 +1,47 @@ --- -title: Flux experimental bitwise package -list_title: bitwise package +title: bitwise package description: > - The Flux experimental `bitwise` package provides functions for performing - bitwise operations on integers. - Import the `experimental/bitwise` package. + The `bitwise` package provides functions for performing bitwise operations on integers. menu: flux_0_x_ref: - name: bitwise + name: bitwise parent: experimental -weight: 301 -flux/v0.x/tags: [functions, bitwise, package] + identifier: experimental/bitwise +weight: 21 cascade: + flux/v0.x/tags: [bitwise] introduced: 0.138.0 --- -The Flux experimental `bitwise` package provides functions for performing bitwise -operations on integers and unsigned integers. + + +The `bitwise` package provides functions for performing bitwise operations on integers. Import the `experimental/bitwise` package: ```js import "experimental/bitwise" ``` +All integers are 64 bit integers. + +Functions prefixed with s operate on signed integers (int). +Functions prefixed with u operate on unsigned integers (uint). + + ## Functions -Functions prefixed with `s` operate on [signed integers (int)](/flux/v0.x/data-types/basic/int/#perform-bitwise-operations-on-integers). -Functions prefixed with `u` operate on [unsigned integers (uint)](/flux/v0.x/data-types/basic/uint/#perform-bitwise-operations-on-uintegers). {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/sand.md b/content/flux/v0.x/stdlib/experimental/bitwise/sand.md index 7e6121878..0e1ed6ce0 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/sand.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/sand.md @@ -1,33 +1,126 @@ --- title: bitwise.sand() function description: > - `bitwise.sand()` performs the bitwise operation `a AND b` with - [integer](/flux/v0.x/data-types/basic/int/) values. + `bitwise.sand()` performs the bitwise operation, `a AND b`, with integers. menu: flux_0_x_ref: name: bitwise.sand - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/int/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/sand +weight: 201 --- -`bitwise.sand()` performs the bitwise operation, `a AND b`, with -[integer](/flux/v0.x/data-types/basic/int/) values. + + +`bitwise.sand()` performs the bitwise operation, `a AND b`, with integers. + + + +##### Function type signature + +```js +(a: int, b: int) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand + + + +### b +({{< req >}}) +Right hand operand + + + + +## Examples + +- [Perform a bitwise AND operation](#perform-a-bitwise-and-operation) +- [Perform a bitwise AND operation on a stream of tables](#perform-a-bitwise-and-operation-on-a-stream-of-tables) + +### Perform a bitwise AND operation ```js import "experimental/bitwise" -bitwise.sand(a: 12, b: 21) +bitwise.sand(a: 1234, b: 4567)// Returns 210 -// Returns 4 ``` -## Parameters -### a {data-type="int"} -Left operand. +### Perform a bitwise AND operation on a stream of tables -### b {data-type="int"} -Right operand. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with _value: bitwise.sand(a: r._value, b: 3)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2 | t1 | +| 2021-01-01T00:00:10Z | 2 | t1 | +| 2021-01-01T00:00:20Z | 3 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 3 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 3 | t2 | +| 2021-01-01T00:00:10Z | 0 | t2 | +| 2021-01-01T00:00:20Z | 1 | t2 | +| 2021-01-01T00:00:30Z | 3 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/sclear.md b/content/flux/v0.x/stdlib/experimental/bitwise/sclear.md index 1042efe35..f95c238ae 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/sclear.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/sclear.md @@ -1,33 +1,128 @@ --- title: bitwise.sclear() function description: > - `bitwise.sclear()` performs the bitwise operation `a AND NOT b` with - [integer](/flux/v0.x/data-types/basic/int/) values. + `bitwise.sclear()` performs the bitwise operation `a AND NOT b`. + Both `a` and `b` are integers. menu: flux_0_x_ref: name: bitwise.sclear - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/int/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/sclear +weight: 201 --- -`bitwise.sclear()` performs the bitwise operation, `a AND NOT b`, with -[integer](/flux/v0.x/data-types/basic/int/) values. + + +`bitwise.sclear()` performs the bitwise operation `a AND NOT b`. +Both `a` and `b` are integers. + + + +##### Function type signature + +```js +(a: int, b: int) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Bits to clear. + + + + +## Examples + +- [Perform a bitwise AND NOT operation](#perform-a-bitwise-and-not-operation) +- [Perform a bitwise AND NOT operation on a stream of tables](#perform-a-bitwise-and-not-operation-on-a-stream-of-tables) + +### Perform a bitwise AND NOT operation ```js import "experimental/bitwise" -bitwise.sclear(a: 12, b: 21) +bitwise.sclear(a: 1234, b: 4567)// Returns 1024 -// Returns 8 ``` -## Parameters -### a {data-type="int"} -Left operand. +### Perform a bitwise AND NOT operation on a stream of tables -### b {data-type="int"} -Right operand. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with _value: bitwise.sclear(a: r._value, b: 3)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -4 | t1 | +| 2021-01-01T00:00:10Z | 8 | t1 | +| 2021-01-01T00:00:20Z | 4 | t1 | +| 2021-01-01T00:00:30Z | 16 | t1 | +| 2021-01-01T00:00:40Z | 12 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 16 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -4 | t2 | +| 2021-01-01T00:00:30Z | 16 | t2 | +| 2021-01-01T00:00:40Z | 12 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/slshift.md b/content/flux/v0.x/stdlib/experimental/bitwise/slshift.md index 4a525b0a2..8f2593982 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/slshift.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/slshift.md @@ -1,33 +1,128 @@ --- title: bitwise.slshift() function description: > - `bitwise.slshift()` shifts bits in `a` left by `b` bits. - Both `a` and `b` are [integers](/flux/v0.x/data-types/basic/int/). + `bitwise.slshift()` shifts the bits in `a` left by `b` bits. + Both `a` and `b` are integers. menu: flux_0_x_ref: name: bitwise.slshift - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/int/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/slshift +weight: 201 --- -`bitwise.slshift()` shifts bits in `a` left by `b` bits. -Both `a` and `b` are [integers](/flux/v0.x/data-types/basic/int/). + + +`bitwise.slshift()` shifts the bits in `a` left by `b` bits. +Both `a` and `b` are integers. + + + +##### Function type signature + +```js +(a: int, b: int) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Number of bits to shift. + + + + +## Examples + +- [Shift bits left in an integer](#shift-bits-left-in-an-integer) +- [Shift bits left in integers in a stream of tables](#shift-bits-left-in-integers-in-a-stream-of-tables) + +### Shift bits left in an integer ```js import "experimental/bitwise" -bitwise.slshift(a: 12, b: 21) +bitwise.slshift(a: 1234, b: 2)// Returns 4936 -// Returns 25165824 ``` -## Parameters -### a {data-type="int"} -Left operand. +### Shift bits left in integers in a stream of tables -### b {data-type="int"} -Number of bits to shift. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with _value: bitwise.slshift(a: r._value, b: 3)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -16 | t1 | +| 2021-01-01T00:00:10Z | 80 | t1 | +| 2021-01-01T00:00:20Z | 56 | t1 | +| 2021-01-01T00:00:30Z | 136 | t1 | +| 2021-01-01T00:00:40Z | 120 | t1 | +| 2021-01-01T00:00:50Z | 32 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 152 | t2 | +| 2021-01-01T00:00:10Z | 32 | t2 | +| 2021-01-01T00:00:20Z | -24 | t2 | +| 2021-01-01T00:00:30Z | 152 | t2 | +| 2021-01-01T00:00:40Z | 104 | t2 | +| 2021-01-01T00:00:50Z | 8 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/snot.md b/content/flux/v0.x/stdlib/experimental/bitwise/snot.md index 2e72a6494..8f48f9d63 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/snot.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/snot.md @@ -1,30 +1,120 @@ --- title: bitwise.snot() function description: > - `bitwise.snot()` inverts every bit in `a`, an - [integer](/flux/v0.x/data-types/basic/int/) value. + `bitwise.snot()` inverts every bit in `a`, an integer. menu: flux_0_x_ref: name: bitwise.snot - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/int/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/snot +weight: 201 --- -`bitwise.snot()` inverts every bit in `a`, an -[integer](/flux/v0.x/data-types/basic/int/) value. + + +`bitwise.snot()` inverts every bit in `a`, an integer. + + + +##### Function type signature + +```js +(a: int) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Integer to invert. + + + + +## Examples + +- [Invert bits in an integer](#invert-bits-in-an-integer) +- [Invert bits in integers in a stream of tables](#invert-bits-in-integers-in-a-stream-of-tables) + +### Invert bits in an integer ```js import "experimental/bitwise" -bitwise.snot(a: 12) +bitwise.snot(a: 1234)// Returns -1235 -// Returns -13 ``` -## Parameters -### a {data-type="int"} -Integer to invert. \ No newline at end of file +### Invert bits in integers in a stream of tables + +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with _value: bitwise.snot(a: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | -11 | t1 | +| 2021-01-01T00:00:20Z | -8 | t1 | +| 2021-01-01T00:00:30Z | -18 | t1 | +| 2021-01-01T00:00:40Z | -16 | t1 | +| 2021-01-01T00:00:50Z | -5 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -20 | t2 | +| 2021-01-01T00:00:10Z | -5 | t2 | +| 2021-01-01T00:00:20Z | 2 | t2 | +| 2021-01-01T00:00:30Z | -20 | t2 | +| 2021-01-01T00:00:40Z | -14 | t2 | +| 2021-01-01T00:00:50Z | -2 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/sor.md b/content/flux/v0.x/stdlib/experimental/bitwise/sor.md index 81c9efaf1..df619a169 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/sor.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/sor.md @@ -1,33 +1,126 @@ --- title: bitwise.sor() function description: > - `bitwise.sor()` performs the bitwise operation `a OR b` with - [integer](/flux/v0.x/data-types/basic/int/) values. + `bitwise.sor()` performs the bitwise operation, `a OR b`, with integers. menu: flux_0_x_ref: name: bitwise.sor - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/int/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/sor +weight: 201 --- -`bitwise.sor()` performs the bitwise operation, `a OR b`, with -[integer](/flux/v0.x/data-types/basic/int/) values. + + +`bitwise.sor()` performs the bitwise operation, `a OR b`, with integers. + + + +##### Function type signature + +```js +(a: int, b: int) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Right hand operand. + + + + +## Examples + +- [Perform a bitwise OR operation](#perform-a-bitwise-or-operation) +- [Perform a bitwise OR operation on a stream of tables](#perform-a-bitwise-or-operation-on-a-stream-of-tables) + +### Perform a bitwise OR operation ```js import "experimental/bitwise" -bitwise.sor(a: 12, b: 21) +bitwise.sor(a: 1234, b: 4567)// Returns 5591 -// Returns 29 ``` -## Parameters -### a {data-type="int"} -Left operand. +### Perform a bitwise OR operation on a stream of tables -### b {data-type="int"} -Right operand. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with _value: bitwise.sor(a: r._value, b: 3)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -1 | t1 | +| 2021-01-01T00:00:10Z | 11 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 19 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 7 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 7 | t2 | +| 2021-01-01T00:00:20Z | -1 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 15 | t2 | +| 2021-01-01T00:00:50Z | 3 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/srshift.md b/content/flux/v0.x/stdlib/experimental/bitwise/srshift.md index 47d8cdd10..0e56bb8ca 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/srshift.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/srshift.md @@ -1,33 +1,128 @@ --- title: bitwise.srshift() function description: > - `bitwise.srshift()` shifts bits in `a` right by `b` bits. - Both `a` and `b` are [integers](/flux/v0.x/data-types/basic/int/). + `bitwise.srshift()` shifts the bits in `a` right by `b` bits. + Both `a` and `b` are integers. menu: flux_0_x_ref: name: bitwise.srshift - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/int/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/srshift +weight: 201 --- -`bitwise.srshift()` shifts bits in `a` right by `b` bits. -Both `a` and `b` are [integers](/flux/v0.x/data-types/basic/int/). + + +`bitwise.srshift()` shifts the bits in `a` right by `b` bits. +Both `a` and `b` are integers. + + + +##### Function type signature + +```js +(a: int, b: int) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Number of bits to shift. + + + + +## Examples + +- [Shift bits right in an integer](#shift-bits-right-in-an-integer) +- [Shift bits right in integers in a stream of tables](#shift-bits-right-in-integers-in-a-stream-of-tables) + +### Shift bits right in an integer ```js import "experimental/bitwise" -bitwise.srshift(a: 21, b: 4) +bitwise.srshift(a: 1234, b: 2)// Returns 308 -// Returns 1 ``` -## Parameters -### a {data-type="int"} -Left operand. +### Shift bits right in integers in a stream of tables -### b {data-type="int"} -Number of bits to shift. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with _value: bitwise.srshift(a: r._value, b: 3)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -1 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 0 | t1 | +| 2021-01-01T00:00:30Z | 2 | t1 | +| 2021-01-01T00:00:40Z | 1 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2 | t2 | +| 2021-01-01T00:00:10Z | 0 | t2 | +| 2021-01-01T00:00:20Z | -1 | t2 | +| 2021-01-01T00:00:30Z | 2 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/sxor.md b/content/flux/v0.x/stdlib/experimental/bitwise/sxor.md index 9419f65af..a86ea9829 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/sxor.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/sxor.md @@ -1,33 +1,126 @@ --- title: bitwise.sxor() function description: > - `bitwise.sxor()` performs the bitwise operation `a XOR b` with - [integer](/flux/v0.x/data-types/basic/int/) values. + `bitwise.sxor()` performs the bitwise operation, `a XOR b`, with integers. menu: flux_0_x_ref: name: bitwise.sxor - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/int/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/sxor +weight: 201 --- -`bitwise.sxor()` performs the bitwise operation, `a XOR b`, with -[integer](/flux/v0.x/data-types/basic/int/) values. + + +`bitwise.sxor()` performs the bitwise operation, `a XOR b`, with integers. + + + +##### Function type signature + +```js +(a: int, b: int) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Right hand operand. + + + + +## Examples + +- [Perform a bitwise XOR operation](#perform-a-bitwise-xor-operation) +- [Perform a bitwise XOR operation on a stream of tables](#perform-a-bitwise-xor-operation-on-a-stream-of-tables) + +### Perform a bitwise XOR operation ```js import "experimental/bitwise" -bitwise.sxor(a: 12, b: 21) +bitwise.sxor(a: 1234, b: 4567)// Returns 5381 -// Returns 25 ``` -## Parameters -### a {data-type="int"} -Left operand. +### Perform a bitwise XOR operation on a stream of tables -### b {data-type="int"} -Right operand. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with _value: bitwise.sxor(a: r._value, b: 3)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -3 | t1 | +| 2021-01-01T00:00:10Z | 9 | t1 | +| 2021-01-01T00:00:20Z | 4 | t1 | +| 2021-01-01T00:00:30Z | 18 | t1 | +| 2021-01-01T00:00:40Z | 12 | t1 | +| 2021-01-01T00:00:50Z | 7 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 16 | t2 | +| 2021-01-01T00:00:10Z | 7 | t2 | +| 2021-01-01T00:00:20Z | -2 | t2 | +| 2021-01-01T00:00:30Z | 16 | t2 | +| 2021-01-01T00:00:40Z | 14 | t2 | +| 2021-01-01T00:00:50Z | 2 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/uand.md b/content/flux/v0.x/stdlib/experimental/bitwise/uand.md index 21f4f79fa..78c79d5df 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/uand.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/uand.md @@ -1,33 +1,126 @@ --- title: bitwise.uand() function description: > - `bitwise.uand()` performs the bitwise operation `a AND b` with - [unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + `bitwise.uand()` performs the bitwise operation, `a AND b`, with unsigned integers. menu: flux_0_x_ref: name: bitwise.uand - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/uint/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/uand +weight: 201 --- -`bitwise.uand()` performs the bitwise operation, `a AND b`, with -[unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + + +`bitwise.uand()` performs the bitwise operation, `a AND b`, with unsigned integers. + + + +##### Function type signature + +```js +(a: uint, b: uint) => uint +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Right hand operand. + + + + +## Examples + +- [Perform a bitwise AND operation](#perform-a-bitwise-and-operation) +- [Perform a bitwise AND operation on a stream of tables](#perform-a-bitwise-and-operation-on-a-stream-of-tables) + +### Perform a bitwise AND operation ```js import "experimental/bitwise" -bitwise.uand(a: uint(v: 12), b: uint(v: 21)) +bitwise.uand(a: uint(v: 1234), b: uint(v: 4567))// Returns 210 (uint) -// Returns 4 (uint) ``` -## Parameters -### a {data-type="uint"} -Left operand. +### Perform a bitwise AND operation on a stream of tables -### b {data-type="uint"} -Right operand. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.uint() + |> map(fn: (r) => ({r with _value: bitwise.uand(a: r._value, b: uint(v: 3))})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2 | t1 | +| 2021-01-01T00:00:10Z | 2 | t1 | +| 2021-01-01T00:00:20Z | 3 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 3 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 3 | t2 | +| 2021-01-01T00:00:10Z | 0 | t2 | +| 2021-01-01T00:00:20Z | 1 | t2 | +| 2021-01-01T00:00:30Z | 3 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/uclear.md b/content/flux/v0.x/stdlib/experimental/bitwise/uclear.md index 14d1e7dd3..2d415cd08 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/uclear.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/uclear.md @@ -1,33 +1,126 @@ --- title: bitwise.uclear() function description: > - `bitwise.uclear()` performs the bitwise operation `a AND NOT b` with - [unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + `bitwise.uclear()` performs the bitwise operation `a AND NOT b`, with unsigned integers. menu: flux_0_x_ref: name: bitwise.uclear - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/uint/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/uclear +weight: 201 --- -`bitwise.uclear()` performs the bitwise operation, `a AND NOT b`, with -[unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + + +`bitwise.uclear()` performs the bitwise operation `a AND NOT b`, with unsigned integers. + + + +##### Function type signature + +```js +(a: uint, b: uint) => uint +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Bits to clear. + + + + +## Examples + +- [Perform a bitwise AND NOT operation](#perform-a-bitwise-and-not-operation) +- [Perform a bitwise AND NOT operation on a stream of tables](#perform-a-bitwise-and-not-operation-on-a-stream-of-tables) + +### Perform a bitwise AND NOT operation ```js import "experimental/bitwise" -bitwise.uclear(a: uint(v: 12), b: uint(v: 21)) +bitwise.uclear(a: uint(v: 1234), b: uint(v: 4567))// Returns 1024 (uint) -// Returns 8 (uint) ``` -## Parameters -### a {data-type="uint"} -Left operand. +### Perform a bitwise AND NOT operation on a stream of tables -### b {data-type="uint"} -Right operand. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.uint() + |> map(fn: (r) => ({r with _value: bitwise.uclear(a: r._value, b: uint(v: 3))})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551612 | t1 | +| 2021-01-01T00:00:10Z | 8 | t1 | +| 2021-01-01T00:00:20Z | 4 | t1 | +| 2021-01-01T00:00:30Z | 16 | t1 | +| 2021-01-01T00:00:40Z | 12 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 16 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551612 | t2 | +| 2021-01-01T00:00:30Z | 16 | t2 | +| 2021-01-01T00:00:40Z | 12 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/ulshift.md b/content/flux/v0.x/stdlib/experimental/bitwise/ulshift.md index 8ff36cbcf..f3022f7f6 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/ulshift.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/ulshift.md @@ -1,33 +1,128 @@ --- title: bitwise.ulshift() function description: > - `bitwise.ulshift()` shifts bits in `a` left by `b` bits. - Both `a` and `b` are [unsigned integers](/flux/v0.x/data-types/basic/uint/). + `bitwise.ulshift()` shifts the bits in `a` left by `b` bits. + Both `a` and `b` are unsigned integers. menu: flux_0_x_ref: name: bitwise.ulshift - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/uint/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/ulshift +weight: 201 --- -`bitwise.ulshift()` shifts bits in `a` left by `b` bits. -Both `a` and `b` are [unsigned integers](/flux/v0.x/data-types/basic/uint/). + + +`bitwise.ulshift()` shifts the bits in `a` left by `b` bits. +Both `a` and `b` are unsigned integers. + + + +##### Function type signature + +```js +(a: uint, b: uint) => uint +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Number of bits to shift. + + + + +## Examples + +- [Shift bits left in an unsigned integer](#shift-bits-left-in-an-unsigned-integer) +- [Shift bits left in unsigned integers in a stream of tables](#shift-bits-left-in-unsigned-integers-in-a-stream-of-tables) + +### Shift bits left in an unsigned integer ```js import "experimental/bitwise" -bitwise.ulshift(a: uint(v: 12), b: uint(v: 21)) +bitwise.ulshift(a: uint(v: 1234), b: uint(v: 2))// Returns 4936 (uint) -// Returns 25165824 (uint) ``` -## Parameters -### a {data-type="uint"} -Left operand. +### Shift bits left in unsigned integers in a stream of tables -### b {data-type="uint"} -Number of bits to shift. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.uint() + |> map(fn: (r) => ({r with _value: bitwise.ulshift(a: r._value, b: uint(v: 3))})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551600 | t1 | +| 2021-01-01T00:00:10Z | 80 | t1 | +| 2021-01-01T00:00:20Z | 56 | t1 | +| 2021-01-01T00:00:30Z | 136 | t1 | +| 2021-01-01T00:00:40Z | 120 | t1 | +| 2021-01-01T00:00:50Z | 32 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 152 | t2 | +| 2021-01-01T00:00:10Z | 32 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551592 | t2 | +| 2021-01-01T00:00:30Z | 152 | t2 | +| 2021-01-01T00:00:40Z | 104 | t2 | +| 2021-01-01T00:00:50Z | 8 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/unot.md b/content/flux/v0.x/stdlib/experimental/bitwise/unot.md index 7726b0dc4..706c5a8cc 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/unot.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/unot.md @@ -1,30 +1,120 @@ --- title: bitwise.unot() function description: > - `bitwise.unot()` inverts every bit in `a`, an - [unsigned integer](/flux/v0.x/data-types/basic/uint/) value. + `bitwise.unot()` inverts every bit in `a`, an unsigned integer. menu: flux_0_x_ref: name: bitwise.unot - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/uint/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/unot +weight: 201 --- -`bitwise.unot()` inverts every bit in `a`, an -[unsigned integer](/flux/v0.x/data-types/basic/uint/) value. + + +`bitwise.unot()` inverts every bit in `a`, an unsigned integer. + + + +##### Function type signature + +```js +(a: uint) => uint +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Unsigned integer to invert. + + + + +## Examples + +- [Invert bits in an unsigned integer](#invert-bits-in-an-unsigned-integer) +- [Invert bits in unsigned integers in a stream of tables](#invert-bits-in-unsigned-integers-in-a-stream-of-tables) + +### Invert bits in an unsigned integer ```js import "experimental/bitwise" -bitwise.unot(a: uint(v: 12)) +bitwise.unot(a: uint(v: 1234))// Returns 18446744073709550381 (uint) -// Returns 18446744073709551603 (uint) ``` -## Parameters -### a {data-type="uint"} -Unsigned integer to invert. \ No newline at end of file +### Invert bits in unsigned integers in a stream of tables + +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.uint() + |> map(fn: (r) => ({r with _value: bitwise.unot(a: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 18446744073709551605 | t1 | +| 2021-01-01T00:00:20Z | 18446744073709551608 | t1 | +| 2021-01-01T00:00:30Z | 18446744073709551598 | t1 | +| 2021-01-01T00:00:40Z | 18446744073709551600 | t1 | +| 2021-01-01T00:00:50Z | 18446744073709551611 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551596 | t2 | +| 2021-01-01T00:00:10Z | 18446744073709551611 | t2 | +| 2021-01-01T00:00:20Z | 2 | t2 | +| 2021-01-01T00:00:30Z | 18446744073709551596 | t2 | +| 2021-01-01T00:00:40Z | 18446744073709551602 | t2 | +| 2021-01-01T00:00:50Z | 18446744073709551614 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/uor.md b/content/flux/v0.x/stdlib/experimental/bitwise/uor.md index 904de179c..da4d329f1 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/uor.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/uor.md @@ -1,33 +1,126 @@ --- title: bitwise.uor() function description: > - `bitwise.uor()` performs the bitwise operation `a OR b` with - [unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + `bitwise.uor()` performs the bitwise operation, `a OR b`, with unsigned integers. menu: flux_0_x_ref: name: bitwise.uor - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/uint/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/uor +weight: 201 --- -`bitwise.uor()` performs the bitwise operation, `a OR b`, with -[unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + + +`bitwise.uor()` performs the bitwise operation, `a OR b`, with unsigned integers. + + + +##### Function type signature + +```js +(a: uint, b: uint) => uint +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Right hand operand. + + + + +## Examples + +- [Perform a bitwise OR operation](#perform-a-bitwise-or-operation) +- [Perform a bitwise OR operation on a stream of tables](#perform-a-bitwise-or-operation-on-a-stream-of-tables) + +### Perform a bitwise OR operation ```js import "experimental/bitwise" -bitwise.uor(a: uint(v: 12), b: uint(v: 21)) +bitwise.uor(a: uint(v: 1234), b: uint(v: 4567))// Returns 5591 (uint) -// Returns 29 (uint) ``` -## Parameters -### a {data-type="uint"} -Left operand. +### Perform a bitwise OR operation on a stream of tables -### b {data-type="uint"} -Right operand. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.uint() + |> map(fn: (r) => ({r with _value: bitwise.uor(a: r._value, b: uint(v: 3))})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551615 | t1 | +| 2021-01-01T00:00:10Z | 11 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 19 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 7 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 7 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551615 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 15 | t2 | +| 2021-01-01T00:00:50Z | 3 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/urshift.md b/content/flux/v0.x/stdlib/experimental/bitwise/urshift.md index 78ff29c0c..5f4471631 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/urshift.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/urshift.md @@ -1,33 +1,128 @@ --- title: bitwise.urshift() function description: > - `bitwise.urshift()` shifts bits in `a` right by `b` bits. - Both `a` and `b` are [unsigned integers](/flux/v0.x/data-types/basic/uint/). + `bitwise.urshift()` shifts the bits in `a` right by `b` bits. + Both `a` and `b` are unsigned integers. menu: flux_0_x_ref: name: bitwise.urshift - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/uint/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/urshift +weight: 201 --- -`bitwise.urshift()` shifts bits in `a` right by `b` bits. -Both `a` and `b` are [unsigned integers](/flux/v0.x/data-types/basic/uint/). + + +`bitwise.urshift()` shifts the bits in `a` right by `b` bits. +Both `a` and `b` are unsigned integers. + + + +##### Function type signature + +```js +(a: uint, b: uint) => uint +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Number of bits to shift. + + + + +## Examples + +- [Shift bits right in an unsigned integer](#shift-bits-right-in-an-unsigned-integer) +- [Shift bits right in unsigned integers in a stream of tables](#shift-bits-right-in-unsigned-integers-in-a-stream-of-tables) + +### Shift bits right in an unsigned integer ```js import "experimental/bitwise" -bitwise.urshift(a: uint(v: 21), b: uint(v: 4)) +bitwise.urshift(a: uint(v: 1234), b: uint(v: 2))// Returns 308 (uint) -// Returns 1 (uint) ``` -## Parameters -### a {data-type="uint"} -Left operand. +### Shift bits right in unsigned integers in a stream of tables -### b {data-type="uint"} -Number of bits to shift. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.uint() + |> map(fn: (r) => ({r with _value: bitwise.urshift(a: r._value, b: uint(v: 3))})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 2305843009213693951 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 0 | t1 | +| 2021-01-01T00:00:30Z | 2 | t1 | +| 2021-01-01T00:00:40Z | 1 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 2 | t2 | +| 2021-01-01T00:00:10Z | 0 | t2 | +| 2021-01-01T00:00:20Z | 2305843009213693951 | t2 | +| 2021-01-01T00:00:30Z | 2 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/uxor.md b/content/flux/v0.x/stdlib/experimental/bitwise/uxor.md index e362a4fc0..a591a2a75 100644 --- a/content/flux/v0.x/stdlib/experimental/bitwise/uxor.md +++ b/content/flux/v0.x/stdlib/experimental/bitwise/uxor.md @@ -1,33 +1,126 @@ --- title: bitwise.uxor() function description: > - `bitwise.uxor()` performs the bitwise operation `a XOR b` with - [unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + `bitwise.uxor()` performs the bitwise operation, `a XOR b`, with unsigned integers. menu: flux_0_x_ref: name: bitwise.uxor - parent: bitwise -weight: 401 -related: - - /flux/v0.x/data-types/basic/uint/ -flux/v0.x/tags: [bitwise] + parent: experimental/bitwise + identifier: experimental/bitwise/uxor +weight: 201 --- -`bitwise.uxor()` performs the bitwise operation, `a XOR b`, with -[unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + + +`bitwise.uxor()` performs the bitwise operation, `a XOR b`, with unsigned integers. + + + +##### Function type signature + +```js +(a: uint, b: uint) => uint +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### a +({{< req >}}) +Left hand operand. + + + +### b +({{< req >}}) +Right hand operand. + + + + +## Examples + +- [Perform a bitwise XOR operation](#perform-a-bitwise-xor-operation) +- [Perform a bitwise XOR operation on a stream of tables](#perform-a-bitwise-xor-operation-on-a-stream-of-tables) + +### Perform a bitwise XOR operation ```js import "experimental/bitwise" -bitwise.uxor(a: uint(v: 12), b: uint(v: 21)) +bitwise.uxor(a: uint(v: 1234), b: uint(v: 4567))// Returns 5381 (uint) -// Returns 25 (uint) ``` -## Parameters -### a {data-type="uint"} -Left operand. +### Perform a bitwise XOR operation on a stream of tables -### b {data-type="uint"} -Right operand. \ No newline at end of file +```js +import "experimental/bitwise" +import "sampledata" + +sampledata.uint() + |> map(fn: (r) => ({r with _value: bitwise.uxor(a: r._value, b: uint(v: 3))})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551613 | t1 | +| 2021-01-01T00:00:10Z | 9 | t1 | +| 2021-01-01T00:00:20Z | 4 | t1 | +| 2021-01-01T00:00:30Z | 18 | t1 | +| 2021-01-01T00:00:40Z | 12 | t1 | +| 2021-01-01T00:00:50Z | 7 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 16 | t2 | +| 2021-01-01T00:00:10Z | 7 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551614 | t2 | +| 2021-01-01T00:00:30Z | 16 | t2 | +| 2021-01-01T00:00:40Z | 14 | t2 | +| 2021-01-01T00:00:50Z | 2 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/chain.md b/content/flux/v0.x/stdlib/experimental/chain.md index 5c1e4e02d..77603ad95 100644 --- a/content/flux/v0.x/stdlib/experimental/chain.md +++ b/content/flux/v0.x/stdlib/experimental/chain.md @@ -1,63 +1,88 @@ --- title: experimental.chain() function description: > - The `experimental.chain()` function runs two queries in a single Flux script - sequentially and outputs the results of the second query. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/chain/ - - /influxdb/cloud/reference/flux/stdlib/experimental/chain/ + `experimental.chain()` runs two queries in a single Flux script sequentially and outputs the + results of the second query. menu: flux_0_x_ref: name: experimental.chain parent: experimental -weight: 302 + identifier: experimental/chain +weight: 101 + introduced: 0.68.0 --- -The `experimental.chain()` function runs two queries in a single Flux script -sequentially and outputs the results of the second query. + + +`experimental.chain()` runs two queries in a single Flux script sequentially and outputs the +results of the second query. + Flux typically executes multiple queries in a single script in parallel. -Running the queries sequentially ensures any dependencies the second query has on -the results of the first query are met. +Running the queries sequentially ensures any dependencies the second query +has on the results of the first query are met. ##### Applicable use cases -- Writing to a bucket and querying the written data in a single Flux script or - [InfluxDB task](/influxdb/cloud/process-data/get-started/). +- Write to a bucket and query the written data in a single Flux script. - Execute queries sequentially in testing scenarios. -```js -import "experimental" +##### Function type signature -experimental.chain( - first: query1, - second: query2, -) +```js +(first: stream[A], second: stream[B]) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### first {data-type="stream of tables"} -The first query to execute. +### first +({{< req >}}) +First query to execute. + + + +### second +({{< req >}}) +Second query to execute. + + -### second {data-type="stream of tables"} -The second query to execute. ## Examples ### Write to a bucket and query the written data + ```js import "experimental" -downsampled_max = from(bucket: "example-bucket-1") - |> range(start: -1d) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> aggregateWindow(every: 1h, fn: max) - |> to(bucket: "downsample-1h-max", org: "example-org") +downsampled_max = + from(bucket: "example-bucket-1") + |> range(start: -1d) + |> filter(fn: (r) => r._measurement == "example-measurement") + |> aggregateWindow(every: 1h, fn: max) + |> to(bucket: "downsample-1h-max", org: "example-org") -average_max = from(bucket: "downsample-1h-max") - |> range(start: -1d) - |> filter(fn: (r) => r.measurement == "example-measurement") - |> mean() +average_max = + from(bucket: "downsample-1h-max") + |> range(start: -1d) + |> filter(fn: (r) => r.measurement == "example-measurement") + |> mean() experimental.chain(first: downsampled_max, second: average_max) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/count.md b/content/flux/v0.x/stdlib/experimental/count.md index 95563a663..c72d09349 100644 --- a/content/flux/v0.x/stdlib/experimental/count.md +++ b/content/flux/v0.x/stdlib/experimental/count.md @@ -1,57 +1,110 @@ --- title: experimental.count() function description: > - The `experimental.count()` function outputs the number of records in each input table - and returns the count in the `_value` column. + `experimental.count()` returns the number of records in each input table. menu: flux_0_x_ref: name: experimental.count parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/count/ - - /influxdb/cloud/reference/flux/stdlib/experimental/count/ -related: - - /flux/v0.x/stdlib/universe/count/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#count, InfluxQL – COUNT() + identifier: experimental/count +weight: 101 flux/v0.x/tags: [transformations, aggregates] introduced: 0.107.0 --- -The `experimental.count()` function outputs the number of records in each input table -and returns the count in the `_value` column. -This function counts both null and non-null records. -_`experimental.count()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`experimental.count()` returns the number of records in each input table. + +The count is returned in the `_value` column and counts both null and non-null records. + +#### Counts on empty tables +`experimental.count()` returns 0 for empty tables. +To keep empty tables in your data, set the following parameters when using +the following functions: + +``` +filter(onEmpty: "keep") +window(createEmpty: true) +aggregateWindow(createEmpty: true) ``` -{{% note %}} -#### Empty tables -`experimental.count()` returns `0` for empty tables. -To keep empty tables in your data, set the following parameters for the following functions: +##### Function type signature -| Function | Parameter | -|:-------- |:--------- | -| [filter()](/flux/v0.x/stdlib/universe/filter/) | `onEmpty: "keep"` | -| [window()](/flux/v0.x/stdlib/universe/window/) | `createEmpty: true` | -| [aggregateWindow()](/flux/v0.x/stdlib/universe/aggregatewindow/) | `createEmpty: true` | -{{% /note %}} +```js +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: int}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Count the number of rows in a table + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket") - |> range(start: -5m) +sampledata.int() |> experimental.count() ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 6 | + +| *tag | _value | +| ---- | ------- | +| t2 | 6 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/csv/_index.md b/content/flux/v0.x/stdlib/experimental/csv/_index.md index a68884480..88d51b89b 100644 --- a/content/flux/v0.x/stdlib/experimental/csv/_index.md +++ b/content/flux/v0.x/stdlib/experimental/csv/_index.md @@ -1,29 +1,44 @@ --- -title: Flux experimental csv package -list_title: csv package -seotitle: Flux Experimental CSV package +title: csv package description: > - The Flux Experimental CSV package provides functions for retrieving annotated CSV. - Import the `experimental/csv` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/csv/ - - /influxdb/cloud/reference/flux/stdlib/experimental/csv/ + The `csv` package provides functions for retrieving annotated CSV. menu: flux_0_x_ref: - name: csv - identifier: csv-exp + name: csv parent: experimental -weight: 301 -flux/v0.x/tags: [functions, csv, package] -introduced: 0.64.0 + identifier: experimental/csv +weight: 21 +cascade: + flux/v0.x/tags: [csv] + introduced: 0.64.0 --- -The Flux experimental `csv` package provides functions for retrieving annotated CSV. + + +The `csv` package provides functions for retrieving annotated CSV. Import the `experimental/csv` package: ```js import "experimental/csv" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/csv/from.md b/content/flux/v0.x/stdlib/experimental/csv/from.md index 65ee82ccf..9d4d7b9cd 100644 --- a/content/flux/v0.x/stdlib/experimental/csv/from.md +++ b/content/flux/v0.x/stdlib/experimental/csv/from.md @@ -1,47 +1,60 @@ --- title: csv.from() function -seotitle: Experimental csv.from() function -list_title: csv.from() (experimental) description: > - The experimental `csv.from()` function retrieves annotated CSV from a URL. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/csv/from/ - - /influxdb/cloud/reference/flux/stdlib/experimental/csv/from/ + `csv.from()` retrieves [annotated CSV](https://docs.influxdata.com/influxdb/latest/reference/syntax/annotated-csv/) **from a URL**. menu: flux_0_x_ref: - name: csv.from * - parent: csv-exp -weight: 401 -flux/v0.x/tags: [inputs] -introduced: 0.64.0 + name: csv.from + parent: experimental/csv + identifier: experimental/csv/from +weight: 201 --- -The experimental `csv.from()` function retrieves -[annotated CSV](/{{< latest "influxdb" >}}/reference/syntax/annotated-csv/) **from a URL**. + + +`csv.from()` retrieves [annotated CSV](https://docs.influxdata.com/influxdb/latest/reference/syntax/annotated-csv/) **from a URL**. + +**Note:** Experimental `csv.from()` is an alternative to the standard +`csv.from()` function. + +##### Function type signature -{{< keep-url >}} ```js -import "experimental/csv" - -csv.from(url: "http://localhost:8086/") +(url: string) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -The URL to retrieve annotated CSV from. +### url +({{< req >}}) +URL to retrieve annotated CSV from. + + + ## Examples -##### Query annotated CSV data from a remote URL +### Query annotated CSV data from a URL + ```js import "experimental/csv" csv.from(url: "http://example.com/csv/example.csv") - |> filter(fn: (r) => r._measurement == "example-measurement") ``` + diff --git a/content/flux/v0.x/stdlib/experimental/distinct.md b/content/flux/v0.x/stdlib/experimental/distinct.md index 5d439dfca..652a50154 100644 --- a/content/flux/v0.x/stdlib/experimental/distinct.md +++ b/content/flux/v0.x/stdlib/experimental/distinct.md @@ -1,81 +1,110 @@ --- title: experimental.distinct() function description: > - The `experimental.distinct()` function returns unique values from the `_value` column. + `experimental.distinct()` returns unique values from the `_value` column. menu: flux_0_x_ref: name: experimental.distinct parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/distinct/ - - /influxdb/cloud/reference/flux/stdlib/experimental/distinct/ -related: - - /flux/v0.x/stdlib/universe/distinct/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#distinct, InfluxQL – DISTINCT() -introduced: 0.112.0 + identifier: experimental/distinct +weight: 101 flux/v0.x/tags: [transformations, selectors] +introduced: 0.112.0 --- -The `experimental.distinct()` function returns unique values from the `_value` column. + + +`experimental.distinct()` returns unique values from the `_value` column. + The `_value` of each output record is set to a distinct value in the specified column. `null` is considered a distinct value. -_`experimental.distinct()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + +`experimental.distinct()` drops all columns **not** in the group key and +drops empty tables. + +##### Function type signature ```js -import "experimental" - -experimental.distinct() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B}] ``` -#### Output schema -`experimental.distinct()` outputs a single table for each input table and does -the following: - -- Outputs a single record for each distinct value. -- Drops all columns **not** in the group key. - -{{% warn %}} -#### Empty tables -`experimental.distinct()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -#### Return distinct values for each input table +### Return distinct values from each input table + ```js import "experimental" +import "sampledata" -data +sampledata.int(includeNull: true) |> experimental.distinct() ``` -{{< flex >}} -{{% flex-content "two-thirds" %}} -##### Input data -| _time | _field | _value | -|:----- |:------ | ------:| -| 2021-01-01T00:00:00Z | ver | v1 | -| 2021-01-01T00:01:00Z | ver | v1 | -| 2021-01-01T00:02:00Z | ver | v2 | -| 2021-01-01T00:03:00Z | ver | | -| 2021-01-01T00:04:00Z | ver | v3 | -| 2021-01-01T00:05:00Z | ver | v3 | -{{% /flex-content %}} -{{% flex-content "third" %}} -##### Output data -| _value | -| ------:| -| v1 | -| v2 | -| | -| v3 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | -2 | +| t1 | | +| t1 | 7 | +| t1 | 4 | + +| *tag | _value | +| ---- | ------- | +| t2 | | +| t2 | 4 | +| t2 | -3 | +| t2 | 19 | +| t2 | 1 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/fill.md b/content/flux/v0.x/stdlib/experimental/fill.md index b0426f952..c3bdb6485 100644 --- a/content/flux/v0.x/stdlib/experimental/fill.md +++ b/content/flux/v0.x/stdlib/experimental/fill.md @@ -1,125 +1,182 @@ --- title: experimental.fill() function description: > - The `experimental.fill()` function replaces all null values in the `_value` - column with a non-null value. + `experimental.fill()` replaces all null values in the `_value` column with a non-null value. menu: flux_0_x_ref: name: experimental.fill parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/fill/ - - /influxdb/cloud/reference/flux/stdlib/experimental/fill/ -related: - - /influxdb/v2.0/query-data/flux/fill/ - - /flux/v0.x/stdlib/universe/fill - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#group-by-time-intervals-and-fill, InfluxQL – FILL + identifier: experimental/fill +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.112.0 --- -The `experimental.fill()` function replaces all null values in the `_value` -column with a non-null value. + + +`experimental.fill()` replaces all null values in the `_value` column with a non-null value. + + + +##### Function type signature ```js -import "experimental" - -experimental.fill(value: 0.0) - -// OR - -experimental.fill(usePrevious: true) +(<-tables: stream[{B with _value: A}], ?usePrevious: bool, ?value: A) => stream[{B with _value: A}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -{{% note %}} -`value` and `usePrevious` are mutually exclusive. -{{% /note %}} +### value -### value {data-type="string, bool, int, uint, float, time"} Value to replace null values with. Data type must match the type of the `_value` column. -### usePrevious {data-type="bool"} -When `true`, replaces null values with the value of the previous non-null row. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). + +### usePrevious + +Replace null values with the value of the previous non-null row. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples - [Fill null values with a specified non-null value](#fill-null-values-with-a-specified-non-null-value) - [Fill null values with the previous non-null value](#fill-null-values-with-the-previous-non-null-value) ---- +### Fill null values with a specified non-null value -#### Fill null values with a specified non-null value ```js import "experimental" +import "sampledata" -data - |> experimental.fill(value: 0.0) +sampledata.int(includeNull: true) + |> experimental.fill(value: 0) ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T00:01:00Z | | -| 2021-01-01T00:02:00Z | 2.3 | -| 2021-01-01T00:03:00Z | | -| 2021-01-01T00:04:00Z | 2.8 | -| 2021-01-01T00:05:00Z | 1.1 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T00:01:00Z | 0.0 | -| 2021-01-01T00:02:00Z | 2.3 | -| 2021-01-01T00:03:00Z | 0.0 | -| 2021-01-01T00:04:00Z | 2.8 | -| 2021-01-01T00:05:00Z | 1.1 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} ---- +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 0 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 0 | t1 | +| 2021-01-01T00:00:40Z | 0 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 0 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Fill null values with the previous non-null value -#### Fill null values with the previous non-null value ```js import "experimental" +import "sampledata" -data +sampledata.int(includeNull: true) |> experimental.fill(usePrevious: true) ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T00:01:00Z | | -| 2021-01-01T00:02:00Z | 2.3 | -| 2021-01-01T00:03:00Z | | -| 2021-01-01T00:04:00Z | 2.8 | -| 2021-01-01T00:05:00Z | 1.1 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T00:01:00Z | 1.2 | -| 2021-01-01T00:02:00Z | 2.3 | -| 2021-01-01T00:03:00Z | 2.3 | -| 2021-01-01T00:04:00Z | 2.8 | -| 2021-01-01T00:05:00Z | 1.1 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | -2 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 7 | t1 | +| 2021-01-01T00:00:40Z | 7 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 19 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/first.md b/content/flux/v0.x/stdlib/experimental/first.md index 5a0f420bf..0051c5ef5 100644 --- a/content/flux/v0.x/stdlib/experimental/first.md +++ b/content/flux/v0.x/stdlib/experimental/first.md @@ -1,69 +1,101 @@ --- title: experimental.first() function description: > - The `experimental.first()` function returns the first record with a non-null - value in the `_value` column. + `experimental.first()` returns the first record with a non-null value in the `_value` column + for each input table. menu: flux_0_x_ref: name: experimental.first parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/first/ - - /influxdb/cloud/reference/flux/stdlib/experimental/first/ -related: - - /{{< latest "inflxudb" >}}/query-data/flux/first-last/ - - /flux/v0.x/stdlib/universe/first/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#first, InfluxQL – FIRST() + identifier: experimental/first +weight: 101 flux/v0.x/tags: [transformations, selectors] introduced: 0.112.0 --- -The `experimental.first()` function returns the first record with a non-null -value in the `_value` column. -_`experimental.first()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`experimental.first()` returns the first record with a non-null value in the `_value` column +for each input table. + +`experimental.first()` drops empty tables. + +##### Function type signature ```js -import "experimental" - -experimental.first() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B}] ``` -{{% warn %}} -#### Empty tables -`experimental.first()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -#### Return the first non-null value +### Return the first non-null value in each input table + ```js import "experimental" +import "sampledata" -data +sampledata.int(includeNull: true) |> experimental.first() ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T00:01:00Z | 0.6 | -| 2021-01-01T00:02:00Z | 2.3 | -| 2021-01-01T00:03:00Z | 0.9 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 4 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/geo/_index.md b/content/flux/v0.x/stdlib/experimental/geo/_index.md index 3bb01fa45..2c2fcfd05 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/_index.md +++ b/content/flux/v0.x/stdlib/experimental/geo/_index.md @@ -1,56 +1,48 @@ --- -title: Flux geo package -list_title: geo package +title: geo package description: > - The Flux `geo` package provides tools for working with geo-temporal data, - such as filtering and grouping by geographic location. - Import the `experimental/geo` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/ + The `geo` package provides tools for working with geotemporal data, such as + filtering and grouping by geographic location. menu: flux_0_x_ref: - name: geo + name: geo parent: experimental -weight: 301 -flux/v0.x/tags: [functions, package, geo] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + identifier: experimental/geo +weight: 21 +cascade: + flux/v0.x/tags: [geotemporal] + introduced: 0.63.0 --- -The Flux `geo` package provides tools for working with geo-temporal data, -such as filtering and grouping by geographic location. + + +The `geo` package provides tools for working with geotemporal data, such as +filtering and grouping by geographic location. Import the `experimental/geo` package: ```js import "experimental/geo" ``` -## Options -```js -import "experimental/geo" - -option geo.units = {distance: "km"} -``` - -### units {data-type="record"} -Units of distances used in geotemporal operations. -Default is `km`. - -**Supported units:** - -- `km` (kilometers) -- `mile` (miles) - -## Functions -{{< children type="functions" show="pages" >}} - ## Geo schema requirements The Geo package uses the Go implementation of the [S2 Geometry Library](https://s2geometry.io/). -Functions in the Geo package require the following: +Functions in the `geo` package require the following: -- a **`s2_cell_id` tag** containing an **S2 cell ID as a token** (more information [below](#s2-cell-ids)) +- a **`s2_cell_id` tag** containing an **S2 cell ID as a token** - a **`lat` field** containing the **latitude in decimal degrees** (WGS 84) - a **`lon` field** containing the **longitude in decimal degrees** (WGS 84) @@ -59,7 +51,7 @@ Functions in the Geo package require the following: - a tag that identifies the point type (for example: `start`, `stop`, `via`) - a field that identifies the track or route (for example: `id`, `tid`) -##### Examples of geo-temporal line protocol +##### Examples of geotemporal line protocol ``` taxi,pt=start,s2_cell_id=89c2594 tip=3.75,dist=14.3,lat=40.744614,lon=-73.979424,tid=1572566401123234345i 1572566401947779410 bike,id=biker-007,pt=via,s2_cell_id=89c25dc lat=40.753944,lon=-73.992035,tid=1572588100i 1572567115 @@ -70,10 +62,8 @@ Use **latitude** and **longitude** with the `s2.CellID.ToToken` endpoint of the Geometry Library to generate `s2_cell_id` tags. Specify your [S2 Cell ID level](https://s2geometry.io/resources/s2cell_statistics.html). -{{% note %}} -To filter more quickly, use higher S2 Cell ID levels, -but know that that higher levels increase [series cardinality](/{{< latest "influxdb" >}}/reference/glossary/#series-cardinality). -{{% /note %}} +**Note:** To filter more quickly, use higher S2 Cell ID levels, but know that +higher levels increase [series cardinality](https://docs.influxdata.com/influxdb/latest/reference/glossary/#series-cardinality). Language-specific implementations of the S2 Geometry Library provide methods for generating S2 Cell ID tokens. For example: @@ -82,17 +72,17 @@ generating S2 Cell ID tokens. For example: - **Python:** [`s2sphere.CellId.to_token()`](https://s2sphere.readthedocs.io/en/latest/api.html#s2sphere.CellId) - **Javascript:** [`s2.cellid.toToken()`](https://github.com/mapbox/node-s2/blob/master/API.md#cellidtotoken---string) -### Add S2 Cell IDs to existing geo-temporal data -Use the [`geo.shapeData()` function](/flux/v0.x/stdlib/experimental/geo/shapedata/) -to add `s2_cell_id` tags to data that includes fields with latitude and longitude values. +### Add S2 Cell IDs to existing geotemporal data +Use `geo.shapeData()` to add `s2_cell_id` tags to data that includes fields +with latitude and longitude values. -```js +```no_run //... - |> shapeData( - latField: "latitude", - lonField: "longitude", - level: 10, - ) + |> shapeData( + latField: "latitude", + lonField: "longitude", + level: 10 + ) ``` ## Latitude and longitude values @@ -121,12 +111,12 @@ Define a box-shaped region by specifying a record containing the following prope - **maxLon:** maximum longitude in decimal degrees (WGS 84) _(Float)_ ##### Example box-shaped region -```js +```no_run { - minLat: 40.51757813, - maxLat: 40.86914063, - minLon: -73.65234375, - maxLon: -72.94921875, + minLat: 40.51757813, + maxLat: 40.86914063, + minLon: -73.65234375, + maxLon: -72.94921875 } ``` @@ -138,11 +128,11 @@ Define a circular region by specifying a record containing the following propert - **radius**: radius of the circle in kilometers (km) _(Float)_ ##### Example circular region -```js +```no_run { - lat: 40.69335938, - lon: -73.30078125, - radius: 20.0, + lat: 40.69335938, + lon: -73.30078125, + radius: 20.0 } ``` @@ -153,10 +143,10 @@ Define a point region by specifying a record containing the following properties - **lon**: longitude in decimal degrees (WGS 84) _(Float)_ ##### Example point region -```js +```no_run { - lat: 40.671659, - lon: -73.936631, + lat: 40.671659, + lon: -73.936631 } ``` @@ -171,13 +161,13 @@ Define a custom polygon region using a record containing the following propertie - **lon**: longitude in decimal degrees (WGS 84) _(Float)_ ##### Example polygonal region -```js +```no_run { - points: [ - {lat: 40.671659, lon: -73.936631}, - {lat: 40.706543, lon: -73.749177}, - {lat: 40.791333, lon: -73.880327}, - ], + points: [ + {lat: 40.671659, lon: -73.936631}, + {lat: 40.706543, lon: -73.749177}, + {lat: 40.791333, lon: -73.880327} + ] } ``` @@ -194,22 +184,41 @@ Define a geographic linestring path using a record containing the following prop - **linestring**: string containing comma-separated longitude and latitude coordinate pairs (`lon lat,`): -```js -{linestring: "39.7515 14.01433, 38.3527 13.9228, 36.9978 15.08433"} +```no_run +{ + linestring: "39.7515 14.01433, 38.3527 13.9228, 36.9978 15.08433" +} ``` ## Distance units -The Geo package supports the following units of measurement for distance: +The `geo` package supports the following units of measurement for distance: - `m` - meters - `km` - kilometers _(default)_ - `mile` - miles ### Define distance units -Use the Geo package `units` option to define custom units of measurement: +Use the `units` option to define custom units of measurement: -```js +```no_run import "experimental/geo" option geo.units = {distance: "mile"} ``` + +## Options + +```js +option geo.units = {distance: "km"} +``` + +### units + +`units` defines the unit of measurment used in geotemporal operations. + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/geo/astracks.md b/content/flux/v0.x/stdlib/experimental/geo/astracks.md index d1a8023d6..7ec4e8848 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/astracks.md +++ b/content/flux/v0.x/stdlib/experimental/geo/astracks.md @@ -1,58 +1,105 @@ --- title: geo.asTracks() function description: > - The geo.asTracks() function groups rows into tracks (sequential, related data points). -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/astracks/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/astracks/ + `geo.asTracks()` groups rows into tracks (sequential, related data points). menu: flux_0_x_ref: name: geo.asTracks - parent: geo -weight: 401 -flux/v0.x/tags: [transformations, geotemporal, geo] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/asTracks +weight: 201 +flux/v0.x/tags: [transformations, geotemporal] --- -The `geo.asTracks()` function groups rows into tracks (sequential, related data points). + + +`geo.asTracks()` groups rows into tracks (sequential, related data points). + + + +##### Function type signature + +```js +(<-tables: stream[A], ?groupBy: [string], ?orderBy: [string]) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### groupBy + +Columns to group by. These columns should uniquely identify each track. +Default is `["id","tid"]`. + + + +### orderBy + +Columns to order results by. Default is `["_time"]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +### Group geotemporal data into tracks ```js import "experimental/geo" -geo.asTracks( - groupBy: ["id","tid"], - orderBy: ["_time"], -) -``` - -## Parameters - -### groupBy {data-type="array of strings"} -Columns to group by. -These columns should uniquely identify each track. -Default is `["id","tid"]`. - -### orderBy {data-type="array of strings"} -Column to order results by. -Default is `["_time"]`. - -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). - -## Examples - -##### Group tracks in a box-shaped region -```js - -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.gridFilter(region: region) - |> geo.toRows(correlationKey: ["_time", "id"]) +data |> geo.asTracks() ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | id | lat | lon | +| -------------------- | ----- | -------- | -------- | +| 2021-01-01T00:00:00Z | a213b | 14.01433 | -14.5464 | +| 2021-01-02T01:00:00Z | a213b | 13.9228 | -13.3338 | +| 2021-01-03T02:00:00Z | a213b | 15.08433 | -12.0433 | +| 2021-01-01T00:00:00Z | b546c | 14.01433 | 39.7515 | +| 2021-01-02T01:00:00Z | b546c | 13.9228 | 38.3527 | +| 2021-01-03T02:00:00Z | b546c | 15.08433 | 36.9978 | + + +#### Output data + +| _time | *id | lat | lon | +| -------------------- | ----- | -------- | -------- | +| 2021-01-01T00:00:00Z | a213b | 14.01433 | -14.5464 | +| 2021-01-02T01:00:00Z | a213b | 13.9228 | -13.3338 | +| 2021-01-03T02:00:00Z | a213b | 15.08433 | -12.0433 | + +| _time | *id | lat | lon | +| -------------------- | ----- | -------- | ------- | +| 2021-01-01T00:00:00Z | b546c | 14.01433 | 39.7515 | +| 2021-01-02T01:00:00Z | b546c | 13.9228 | 38.3527 | +| 2021-01-03T02:00:00Z | b546c | 15.08433 | 36.9978 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/geo/filterrows.md b/content/flux/v0.x/stdlib/experimental/geo/filterrows.md index 1889b3ccf..48516615e 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/filterrows.md +++ b/content/flux/v0.x/stdlib/experimental/geo/filterrows.md @@ -1,169 +1,126 @@ --- title: geo.filterRows() function description: > - The geo.filterRows() function filters data by a specified geographic region with - the option of strict filtering. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/filterrows/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/filterrows/ + `geo.filterRows()` filters data by a specified geographic region with the option of strict filtering. menu: flux_0_x_ref: name: geo.filterRows - parent: geo -weight: 401 -flux/v0.x/tags: [transformations, filters, geotemporal, geo] -related: - - /flux/v0.x/stdlib/experimental/geo/gridfilter/ - - /flux/v0.x/stdlib/experimental/geo/strictfilter/ - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/filterRows +weight: 201 +flux/v0.x/tags: [transformations, filters, geotemporal] --- -The `geo.filterRows()` function filters data by a specified geographic region with -the option of strict filtering. -This function is a combination of [`geo.gridFilter()`](/flux/v0.x/stdlib/experimental/geo/gridfilter/) -and [`geo.strictFilter()`](/flux/v0.x/stdlib/experimental/geo/strictfilter/). + + +`geo.filterRows()` filters data by a specified geographic region with the option of strict filtering. + +This function is a combination of `geo.gridFilter()` and `geo.strictFilter()`. +Input data must include an `s2_cell_id` column that is **part of the group key**. + +##### Function type signature ```js -import "experimental/geo" - -geo.filterRows( - region: {lat: 40.69335938, lon: -73.30078125, radius: 20.0}, - minSize: 24, - maxSize: -1, - level: -1, - s2cellIDLevel: -1, - correlationKey: ["_time"], - strict: true, -) +( + <-tables: stream[{B with s2_cell_id: string, lon: D, lat: C}], + region: A, + ?level: int, + ?maxSize: int, + ?minSize: int, + ?s2cellIDLevel: int, + ?strict: bool, +) => stream[{B with s2_cell_id: string, lon: D, lat: C}] where A: Record ``` -{{% note %}} -#### s2_cell_id must be part of the group key -To filter geo-temporal data with `geo.filterRows()`, `s2_cell_id` must be part -of the [group key](/flux/v0.x/get-started/data-model/#group-key). -To add `s2_cell_id` to the group key, use [`experimental.group`](/flux/v0.x/stdlib/experimental/group/): - -```js -import "experimental" - -// ... - |> experimental.group(columns: ["s2_cell_id"], mode: "extend") -``` -{{% /note %}} - -### Strict and non-strict filtering -In most cases, the specified geographic region does not perfectly align with S2 grid cells. - -- **Non-strict filtering** returns points that may be outside of the specified region but - inside S2 grid cells partially covered by the region. -- **Strict filtering** returns only points inside the specified region. - - S2 grid cell - Filter region - Returned point - -{{< flex >}} -{{% flex-content %}} -**Strict filtering** -{{< svg "/static/svgs/geo-strict.svg" >}} -{{% /flex-content %}} -{{% flex-content %}} -**Non-strict filtering** -{{< svg "/static/svgs/geo-non-strict.svg" >}} -{{% /flex-content %}} -{{< /flex >}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### region {data-type="record"} -The region containing the desired data points. -Specify record properties for the shape. -_See [Region definitions](/flux/v0.x/stdlib/experimental/geo/#region-definitions)._ +### region +({{< req >}}) +Region containing the desired data points. + +Specify record properties for the shape. + +### minSize -### minSize {data-type="int"} Minimum number of cells that cover the specified region. Default is `24`. -### maxSize {data-type="int"} + + +### maxSize + Maximum number of cells that cover the specified region. -Default is `-1`. +Default is `-1` (unlimited). -### level {data-type="int"} -[S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html) of grid cells. -Default is `-1`. -{{% warn %}} -`level` is mutually exclusive with `minSize` and `maxSize` and must be less than -or equal to `s2cellIDLevel`. -{{% /warn %}} -### s2cellIDLevel {data-type="int"} -[S2 Cell level](https://s2geometry.io/resources/s2cell_statistics.html) used in `s2_cell_id` tag. -Default is `-1`. +### level -{{% note %}} -When set to `-1`, `geo.filterRows()` attempts to automatically detect the S2 Cell ID level. -{{% /note %}} +[S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html) +of grid cells. Default is `-1`. + +**Note:** `level` is mutually exclusive with `minSize` and `maxSize` and +must be less than or equal to `s2cellIDLevel`. + +### s2cellIDLevel + +[S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html) +used in the `s2_cell_id` tag. Default is `-1` (detects S2 cell level from the `s2_cell_id` tag). + + + +### strict + +Enable strict geographic data filtering. Default is `true`. + +Strict filtering returns only points with coordinates in the defined region. +Non-strict filtering returns all points from S2 grid cells that are partially +covered by the defined region. + +### tables + +Input data. Default is piped-forward data (`<-`). -### correlationKey {data-type="array of strings"} -List of columns used to uniquely identify a row for output. -Default is `["_time"]`. -### strict {data-type="bool"} -Enable strict geographic data filtering which filters points by longitude (`lon`) and latitude (`lat`). -For S2 grid cells that are partially covered by the defined region, only points -with coordinates in the defined region are returned. -Default is `true`. -_See [Strict and non-strict filtering](#strict-and-non-strict-filtering) above._ -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -- [Strictly filter data in a box-shaped region](#strictly-filter-data-in-a-box-shaped-region) -- [Approximately filter data in a circular region](#approximately-filter-data-in-a-circular-region) -- [Filter data in a polygonal region](#filter-data-in-a-polygonal-region) +- [Strictly filter geotemporal data by region](#strictly-filter-geotemporal-data-by-region) +- [Approximately filter geotemporal data by region](#approximately-filter-geotemporal-data-by-region) -##### Strictly filter data in a box-shaped region -```js -import "experimental/geo" - -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.filterRows(region: region) -``` - -##### Approximately filter data in a circular region -The following example returns points with coordinates located in S2 grid cells partially -covered by the defined region even though some points my be located outside of the region. +### Strictly filter geotemporal data by region ```js import "experimental/geo" -region = {lat: 40.69335938, lon: -73.30078125, radius: 20.0} - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.filterRows(region: region, strict: false) +data + |> geo.filterRows(region: {lat: 40.69335938, lon: -73.30078125, radius: 100.0}) ``` -##### Filter data in a polygonal region + +### Approximately filter geotemporal data by region + ```js import "experimental/geo" -region = { - points: [{lat: 40.671659, lon: -73.936631}, {lat: 40.706543, lon: -73.749177}, {lat: 40.791333, lon: -73.880327}], -} - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.filterRows(region: region) +data + |> geo.filterRows(region: {lat: 40.69335938, lon: -73.30078125, radius: 100.0}, strict: false) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/geo/getgrid.md b/content/flux/v0.x/stdlib/experimental/geo/getgrid.md new file mode 100644 index 000000000..1c3157e9a --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/geo/getgrid.md @@ -0,0 +1,87 @@ +--- +title: geo.getGrid() function +description: > + `geo.getGrid()` calculates a grid or set of cell ID tokens for a specified region. +menu: + flux_0_x_ref: + name: geo.getGrid + parent: experimental/geo + identifier: experimental/geo/getGrid +weight: 201 +--- + + + +`geo.getGrid()` calculates a grid or set of cell ID tokens for a specified region. + +**Note**: S2 grid cells may not perfectly align with the defined region, +so results include S2 grid cells fully and partially covered by the region. + +##### Function type signature + +```js +( + region: A, + units: {distance: string}, + ?level: int, + ?maxLevel: int, + ?maxSize: int, + ?minSize: int, +) => {set: [string], level: int} where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### region +({{< req >}}) +Region used to return S2 cell ID tokens. +Specify record properties for the region shape. + + + +### minSize + +Minimum number of cells that cover the specified region. + + + +### maxSize + +Minimum number of cells that cover the specified region. + + + +### level + +S2 cell level of grid cells. + + + +### maxLevel + +Maximumn S2 cell level of grid cells. + + + +### units +({{< req >}}) +Record that defines the unit of measurement for distance. + + + diff --git a/content/flux/v0.x/stdlib/experimental/geo/getlevel.md b/content/flux/v0.x/stdlib/experimental/geo/getlevel.md new file mode 100644 index 000000000..436bf61c3 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/geo/getlevel.md @@ -0,0 +1,61 @@ +--- +title: geo.getLevel() function +description: > + `geo.getLevel()` returns the S2 cell level of specified cell ID token. +menu: + flux_0_x_ref: + name: geo.getLevel + parent: experimental/geo + identifier: experimental/geo/getLevel +weight: 201 +flux/v0.x/tags: [geotemporal] +--- + + + +`geo.getLevel()` returns the S2 cell level of specified cell ID token. + + + +##### Function type signature + +```js +(token: string) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### token +({{< req >}}) +S2 cell ID token. + + + + +## Examples + +### Return the S2 cell level of an S2 cell ID token + +```js +import "experimental/geo" + +geo.getLevel(token: "166b59")// Returns 10 + +``` + diff --git a/content/flux/v0.x/stdlib/experimental/geo/gridfilter.md b/content/flux/v0.x/stdlib/experimental/geo/gridfilter.md index 8722458c0..bf8a30ae0 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/gridfilter.md +++ b/content/flux/v0.x/stdlib/experimental/geo/gridfilter.md @@ -1,159 +1,143 @@ --- title: geo.gridFilter() function description: > - The geo.gridFilter() function filters data by a specified geographic region. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/gridfilter/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/gridfilter/ + `geo.gridFilter()` filters data by a specified geographic region. menu: flux_0_x_ref: name: geo.gridFilter - parent: geo -weight: 401 -flux/v0.x/tags: [transformations, filters, geotemporal, geo] -related: - - /flux/v0.x/stdlib/experimental/geo/strictfilter/ - - /flux/v0.x/stdlib/experimental/geo/filterRows/ - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/gridFilter +weight: 201 +flux/v0.x/tags: [transformations, filters, geotemporal] --- -The `geo.gridFilter()` function filters data by a specified geographic region. -It compares input data to a set of S2 Cell ID tokens located in the specified [region](#region). + + +`geo.gridFilter()` filters data by a specified geographic region. + +The function compares input data to a set of S2 cell ID tokens located in the specified region. +Input data must include an `s2_cell_id` column that is **part of the group key**. + +**Note**: S2 Grid cells may not perfectly align with the defined region, +so results may include data with coordinates outside the region, but inside +S2 grid cells partially covered by the region. +Use `geo.toRows()` and `geo.strictFilter()` after `geo.gridFilter()` to precisely filter points. + +##### Function type signature ```js -import "experimental/geo" - -geo.gridFilter( - region: {lat: 40.69335938, lon: -73.30078125, radius: 20.0} - minSize: 24, - maxSize: -1, - level: -1, - s2cellIDLevel: -1, -) +( + <-tables: stream[{B with s2_cell_id: string}], + region: A, + ?level: int, + ?maxSize: int, + ?minSize: int, + ?s2cellIDLevel: int, + ?units: {distance: string}, +) => stream[{B with s2_cell_id: string}] where A: Record ``` -{{% note %}} -#### s2_cell_id must be part of the group key -To filter geo-temporal data with `geo.gridFilter()`, `s2_cell_id` must be part -of the [group key](/flux/v0.x/get-started/data-model/#group-key). -To add `s2_cell_id` to the group key, use [`experimental.group`](/flux/v0.x/stdlib/experimental/group/): - -```js -import "experimental" - -// ... - |> experimental.group(columns: ["s2_cell_id"], mode: "extend") -``` -{{% /note %}} - -### Non-strict and strict filtering -In most cases, the specified geographic region does not perfectly align with S2 grid cells. - -- **Non-strict filtering** returns points that may be outside of the specified region but - inside S2 grid cells partially covered by the region. -- **Strict filtering** returns only points inside the specified region. - - S2 grid cell - Filter region - Returned point - -{{< flex >}} -{{% flex-content %}} -**Non-strict filtering** -{{< svg "/static/svgs/geo-non-strict.svg" >}} -{{% /flex-content %}} -{{% flex-content %}} -**Strict filtering** -{{< svg "/static/svgs/geo-strict.svg" >}} -{{% /flex-content %}} -{{< /flex >}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### region {data-type="record"} -The region containing the desired data points. -Specify record properties for the shape. -_See [Region definitions](/flux/v0.x/stdlib/experimental/geo/#region-definitions)._ +### region +({{< req >}}) +Region containing the desired data points. + +Specify record properties for the shape. + +### minSize -### minSize {data-type="int"} Minimum number of cells that cover the specified region. Default is `24`. -### maxSize {data-type="int"} + + +### maxSize + Maximum number of cells that cover the specified region. -Default is `-1`. +Default is `-1` (unlimited). -### level {data-type="int"} -[S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html) of grid cells. -Default is `-1`. -{{% warn %}} -`level` is mutually exclusive with `minSize` and `maxSize` and must be less than -or equal to `s2cellIDLevel`. -{{% /warn %}} -### s2cellIDLevel {data-type="int"} -[S2 Cell level](https://s2geometry.io/resources/s2cell_statistics.html) used in `s2_cell_id` tag. -Default is `-1`. +### level + +[S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html) +of grid cells. Default is `-1`. + +**Note:** `level` is mutually exclusive with `minSize` and `maxSize` and +must be less than or equal to `s2cellIDLevel`. + +### s2cellIDLevel + +[S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html) +used in the `s2_cell_id` tag. Default is `-1` (detects S2 cell level from the S2 cell ID token). + + + +### units + +Record that defines the unit of measurement for distance. +Default is the `geo.units` option. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + -{{% note %}} -When set to `-1`, `gridFilter()` attempts to automatically detect the S2 Cell ID level. -{{% /note %}} -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -- [Filter data in a box-shaped region](#filter-data-in-a-box-shaped-region) -- [Filter data in a circular region](#filter-data-in-a-circular-region) -- [Filter data in a custom polygon region](#filter-data-in-a-custom-polygon-region) +### Filter data to a specified region -##### Filter data in a box-shaped region ```js import "experimental/geo" -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.gridFilter(region: region) +data + |> geo.gridFilter(region: {lat: 40.69335938, lon: -73.30078125, radius: 20.0}) ``` -##### Filter data in a circular region -```js -import "experimental/geo" +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -region = {lat: 40.69335938, lon: -73.30078125, radius: 20.0} +#### Input data -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.gridFilter(region: region) -``` +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | -------- | -------- | ----------- | +| 2021-01-03T02:00:00Z | a213b | 39.08433 | -75.9978 | 89b875 | -##### Filter data in a custom polygon region -```js -import "experimental/geo" +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | -------- | -------- | ----------- | +| 2021-01-01T00:00:00Z | a213b | 41.01433 | -70.7515 | 89e55d | -region = { - points: [{lat: 40.671659, lon: -73.936631}, {lat: 40.706543, lon: -73.749177}, {lat: 40.791333, lon: -73.880327}], -} +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | ------- | -------- | ----------- | +| 2021-01-02T01:00:00Z | a213b | 40.9228 | -73.3527 | 89e825 | -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.gridFilter(region: region) -``` + +#### Output data + +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | ------- | -------- | ----------- | +| 2021-01-02T01:00:00Z | a213b | 40.9228 | -73.3527 | 89e825 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/geo/groupbyarea.md b/content/flux/v0.x/stdlib/experimental/geo/groupbyarea.md index 1d94fc576..f70677cbb 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/groupbyarea.md +++ b/content/flux/v0.x/stdlib/experimental/geo/groupbyarea.md @@ -1,67 +1,120 @@ --- title: geo.groupByArea() function description: > - The geo.groupByArea() function groups rows by geographic area. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/groupbyarea/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/groupbyarea/ + `geo.groupByArea()` groups rows by geographic area. menu: flux_0_x_ref: name: geo.groupByArea - parent: geo -weight: 401 -flux/v0.x/tags: [transformations, geotemporal, geo] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/groupByArea +weight: 201 +flux/v0.x/tags: [transformations, geotemporal] --- -The `geo.groupByArea()` function groups rows by geographic area. -Area sizes are determined by the specified [`level`](#level). -Each geographic area is assigned a unique identifier which is stored in the [`newColumn`](#newcolumn). + + +`geo.groupByArea()` groups rows by geographic area. + +Area sizes are determined by the specified `level`. +Each geographic area is assigned a unique identifier (the S2 cell ID token) +which is stored in the `newColumn`. Results are grouped by `newColumn`. -```js -import "experimental/geo" +##### Function type signature -geo.groupByArea( - newColumn: "geoArea", - level: 3, - s2cellIDLevel: -1, -) +```js +( + <-tables: stream[{A with s2_cell_id: string, lon: float, lat: float}], + level: int, + newColumn: string, + ?s2cellIDLevel: int, +) => stream[B] where B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### newColumn {data-type="string"} -Name of the new column that stores the unique identifier for a geographic area. +### newColumn +({{< req >}}) +Name of the new column for the unique identifier for each geographic area. -### level {data-type="int"} -[S2 Cell level](https://s2geometry.io/resources/s2cell_statistics.html) used -to determine the size of each geographic area. -### s2cellIDLevel {data-type="int"} -[S2 Cell level](https://s2geometry.io/resources/s2cell_statistics.html) used in `s2_cell_id` tag. -Default is `-1`. -{{% note %}} -When set to `-1`, `geo.groupByArea()` attempts to automatically detect the S2 Cell ID level. -{{% /note %}} +### level +({{< req >}}) +[S2 Cell level](https://s2geometry.io/resources/s2cell_statistics.html) +used to determine the size of each geographic area. + + + +### s2cellIDLevel + +[S2 Cell level](https://s2geometry.io/resources/s2cell_statistics.html) +used in the `s2_cell_id` tag. Default is `-1` (detects S2 cell level from the `s2_cell_id` tag). + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples + +### Group geotemporal data by geographic area + ```js import "experimental/geo" -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.gridFilter(region: region) - |> geo.toRows() - |> geo.groupByArea(newColumn: "geoArea", level: 3) +data + |> geo.groupByArea(newColumn: "foo", level: 4) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | -------- | -------- | ----------- | +| 2021-01-03T02:00:00Z | a213b | 39.08433 | -75.9978 | 89bc | + +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | -------- | -------- | ----------- | +| 2021-01-01T00:00:00Z | a213b | 41.01433 | -70.7515 | 89e4 | + +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | ------- | -------- | ----------- | +| 2021-01-02T01:00:00Z | a213b | 40.9228 | -73.3527 | 89ec | + + +#### Output data + +| *foo | _time | id | lat | lon | s2_cell_id | +| ---- | -------------------- | ----- | -------- | -------- | ----------- | +| 89b | 2021-01-03T02:00:00Z | a213b | 39.08433 | -75.9978 | 89bc | + +| *foo | _time | id | lat | lon | s2_cell_id | +| ---- | -------------------- | ----- | -------- | -------- | ----------- | +| 89f | 2021-01-01T00:00:00Z | a213b | 41.01433 | -70.7515 | 89e4 | +| 89f | 2021-01-02T01:00:00Z | a213b | 40.9228 | -73.3527 | 89ec | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/geo/s2cellidtoken.md b/content/flux/v0.x/stdlib/experimental/geo/s2cellidtoken.md index ec0631b2c..955fbb357 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/s2cellidtoken.md +++ b/content/flux/v0.x/stdlib/experimental/geo/s2cellidtoken.md @@ -1,69 +1,158 @@ --- title: geo.s2CellIDToken() function description: > - The `geo.s2CellIDToken()` function returns an S2 cell ID token. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/s2cellidtoken/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/s2cellidtoken/ + `geo.s2CellIDToken()` returns and S2 cell ID token for given cell or point at a + specified S2 cell level. menu: flux_0_x_ref: name: geo.s2CellIDToken - parent: geo -weight: 401 -flux/v0.x/tags: [geotemporal, geo] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/s2CellIDToken +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.64.0 --- -The `geo.s2CellIDToken()` function returns an S2 cell ID token. + + +`geo.s2CellIDToken()` returns and S2 cell ID token for given cell or point at a +specified S2 cell level. + + + +##### Function type signature ```js -import "experimental/geo" - -geo.s2CellIDToken( - point: {lat: 37.7858229, lon: -122.4058124}, - level: 10, -) +(level: int, ?point: {lon: float, lat: float}, ?token: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### point {data-type="record"} -Longitude and latitude in **decimal degrees** (WGS 84) to use when generating -the S2 cell ID token. -Record must contain `lat` and `lon` properties. +### token -### token {data-type="string"} S2 cell ID token to update. + Useful for changing the S2 cell level of an existing S2 cell ID token. -{{% note %}} -`point` and `token` are mutually exclusive. -{{% /note %}} +### point + +Record with `lat` and `lon` properties that specify the latitude and +longitude in decimal degrees (WGS 84) of a point. + + + +### level +({{< req >}}) +S2 cell level to use when generating the S2 cell ID token. + + -### level {data-type="int"} -[S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html) to use -when generating the S2 cell ID token. ## Examples -##### Use latitude and longitude values to generate S2 cell ID tokens +- [Use latitude and longitude values to generate S2 cell ID tokens](#use-latitude-and-longitude-values-to-generate-s2-cell-id-tokens) +- [Update S2 cell ID token level](#update-s2-cell-id-token-level) + +### Use latitude and longitude values to generate S2 cell ID tokens + ```js import "experimental/geo" -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") +data |> map(fn: (r) => ({r with s2_cell_id: geo.s2CellIDToken(point: {lat: r.lat, lon: r.lon}, level: 10)})) ``` -##### Update S2 cell ID token level +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *id | lon | lat | +| -------------------- | ----- | ------- | -------- | +| 2021-01-01T00:00:00Z | a213b | 39.7515 | 14.01433 | +| 2021-01-02T01:00:00Z | a213b | 38.3527 | 13.9228 | +| 2021-01-03T02:00:00Z | a213b | 36.9978 | 15.08433 | + +| _time | *id | lon | lat | +| -------------------- | ----- | ------- | -------- | +| 2021-01-01T00:00:00Z | b546c | 24.0069 | -14.5464 | +| 2021-01-02T01:00:00Z | b546c | 25.1304 | -13.3338 | +| 2021-01-03T02:00:00Z | b546c | 26.7899 | -12.0433 | + + +#### Output data + +| _time | *id | lat | lon | s2_cell_id | +| -------------------- | ----- | -------- | ------- | ----------- | +| 2021-01-01T00:00:00Z | a213b | 14.01433 | 39.7515 | 166b59 | +| 2021-01-02T01:00:00Z | a213b | 13.9228 | 38.3527 | 16696d | +| 2021-01-03T02:00:00Z | a213b | 15.08433 | 36.9978 | 166599 | + +| _time | *id | lat | lon | s2_cell_id | +| -------------------- | ----- | -------- | ------- | ----------- | +| 2021-01-01T00:00:00Z | b546c | -14.5464 | 24.0069 | 1960d7 | +| 2021-01-02T01:00:00Z | b546c | -13.3338 | 25.1304 | 1965c7 | +| 2021-01-03T02:00:00Z | b546c | -12.0433 | 26.7899 | 1971dd | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Update S2 cell ID token level + ```js import "experimental/geo" -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> map(fn: (r) => ({r with s2_cell_id: geo.s2CellIDToken(token: r.s2_cell_id, level: 10)})) +data + |> map(fn: (r) => ({r with s2_cell_id: geo.s2CellIDToken(token: r.s2_cell_id, level: 5)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *id | s2_cell_id | +| -------------------- | ----- | ----------- | +| 2021-01-01T00:00:00Z | a213b | 166b59 | +| 2021-01-02T01:00:00Z | a213b | 16696d | +| 2021-01-03T02:00:00Z | a213b | 166599 | + +| _time | *id | s2_cell_id | +| -------------------- | ----- | ----------- | +| 2021-01-01T00:00:00Z | b546c | 1960d7 | +| 2021-01-02T01:00:00Z | b546c | 1965c7 | +| 2021-01-03T02:00:00Z | b546c | 1971dd | + + +#### Output data + +| _time | *id | s2_cell_id | +| -------------------- | ----- | ----------- | +| 2021-01-01T00:00:00Z | a213b | 166c | +| 2021-01-02T01:00:00Z | a213b | 166c | +| 2021-01-03T02:00:00Z | a213b | 1664 | + +| _time | *id | s2_cell_id | +| -------------------- | ----- | ----------- | +| 2021-01-01T00:00:00Z | b546c | 1964 | +| 2021-01-02T01:00:00Z | b546c | 1964 | +| 2021-01-03T02:00:00Z | b546c | 1974 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/geo/s2celllatlon.md b/content/flux/v0.x/stdlib/experimental/geo/s2celllatlon.md index 2a982491b..79995d920 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/s2celllatlon.md +++ b/content/flux/v0.x/stdlib/experimental/geo/s2celllatlon.md @@ -1,34 +1,62 @@ --- title: geo.s2CellLatLon() function description: > - The `geo.s2CellLatLon()` function returns the latitude and longitude of the - center of an S2 cell. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/s2celllatlon/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/s2celllatlon/ + `geo.s2CellLatLon()` returns the latitude and longitude of the center of an S2 cell. menu: flux_0_x_ref: name: geo.s2CellLatLon - parent: geo -weight: 401 -flux/v0.x/tags: [geotemporal, geo] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/s2CellLatLon +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.78.0 --- -The `geo.s2CellLatLon()` function returns the latitude and longitude of the -center of an S2 cell. + + +`geo.s2CellLatLon()` returns the latitude and longitude of the center of an S2 cell. + + + +##### Function type signature + +```js +(token: string) => {lon: float, lat: float} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### token +({{< req >}}) +S2 cell ID token. + + + + +## Examples + +### Return the center coordinates of an S2 cell ```js import "experimental/geo" -geo.s2CellLatLon(token: "89c284") +geo.s2CellLatLon(token: "89c284")// Returns {lat: 40.812535546624574, lon: -73.55941282728273} -// Returns {lat: 40.812535546624574, lon: -73.55941282728273} ``` -## Parameters - -### token {data-type="string"} -S2 cell ID token. diff --git a/content/flux/v0.x/stdlib/experimental/geo/shapedata.md b/content/flux/v0.x/stdlib/experimental/geo/shapedata.md index c503d633d..29293ef8f 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/shapedata.md +++ b/content/flux/v0.x/stdlib/experimental/geo/shapedata.md @@ -1,109 +1,78 @@ --- title: geo.shapeData() function description: > - The `geo.shapeData()` function renames existing latitude and longitude fields to - **lat** and **lon** and adds an **s2_cell_id** tag. - Use `geo.shapeData()` to ensure geo-temporal data meets the requirements of the Geo package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/shapedata/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/shapedata/ + `geo.shapeData()` renames existing latitude and longitude fields to **lat** and **lon** + and adds an **s2\_cell\_id** tag. menu: flux_0_x_ref: name: geo.shapeData - parent: geo -weight: 401 -flux/v0.x/tags: [transformations, geotemporal, geo] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.65.0 + parent: experimental/geo + identifier: experimental/geo/shapeData +weight: 201 --- -The `geo.shapeData()` function renames existing latitude and longitude fields to -**lat** and **lon** and adds an **s2_cell_id** tag. -Use `geo.shapeData()` to ensure geo-temporal data meets the -[requirements of the Geo package](/flux/v0.x/stdlib/experimental/geo/#geo-schema-requirements): + + +`geo.shapeData()` renames existing latitude and longitude fields to **lat** and **lon** +and adds an **s2\_cell\_id** tag. + +Use `geo.shapeData()` to ensure geotemporal data meets the requirements of the Geo package: 1. Rename existing latitude and longitude fields to `lat` and `lon`. -2. Pivot data into row-wise sets based on `_time`. -3. Generate `s2_cell_id` tags using `lat` and `lon` values and a specified - [S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html). +2. Pivot fields into columns based on `_time`. +3. Generate `s2_cell_id` tags using `lat` and `lon` values and a specified [S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html). + +##### Function type signature ```js -import "experimental/geo" - -geo.shapeData( - latField: "latitude", - lonField: "longitude", - level: 10, -) +( + <-tables: stream[{C with _field: string}], + latField: A, + level: int, + lonField: B, +) => stream[{D with s2_cell_id: string, lon: float, lat: float}] where A: Equatable, B: Equatable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### latField {data-type="string"} -Name of the existing field that contains the latitude value in **decimal degrees** (WGS 84). +### latField +({{< req >}}) +Name of the existing field that contains the latitude value in decimal degrees (WGS 84). + Field is renamed to `lat`. -### lonField {data-type="string"} -Name of the existing field that contains the longitude value in **decimal degrees** (WGS 84). +### lonField +({{< req >}}) +Name of the existing field that contains the longitude value in decimal degrees (WGS 84). + Field is renamed to `lon`. -### level {data-type="int"} -[S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html) to use -when generating the S2 cell ID token. +### level +({{< req >}}) +[S2 cell level](https://s2geometry.io/resources/s2cell_statistics.html) +to use when generating the S2 cell ID token. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Examples -##### Shape data to meet the requirements of the Geo package -```js -import "experimental/geo" +### tables -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.shapeData(latField: "latitude", lonField: "longitude", level: 10) -``` +Input data. Default is piped-forward data (`<-`). -### geo.shapeData input and output -{{< flex >}} -{{% flex-content %}} -**Given the following input:** -| _time | _field | _value | -|:----- |:------: | ------:| -| 0001 | latitude | 30.0 | -| 0002 | latitude | 30.5 | -| 0003 | latitude | 30.7 | -| 0004 | latitude | 31.1 | -| • • • | • • • | • • • | -| 0001 | longitude | 20.0 | -| 0002 | longitude | 19.8 | -| 0003 | longitude | 19.2 | -| 0004 | longitude | 19.5 | -{{% /flex-content %}} -{{% flex-content %}} - -**The following would output:** - -```js -data - |> geo.shapeData( - latField: "latitude", - lonField: "longitude", - level: 5, - ) -``` - -| _time | lat | lon | s2_cell_id | -|:----- |:--------:|:---------:| ----------:| -| 0001 | 30.0 | 20.0 | 138c | -| 0002 | 30.5 | 19.8 | 1384 | -| 0003 | 30.7 | 19.2 | 139c | -| 0004 | 31.1 | 19.5 | 139c | -{{% /flex-content %}} -{{< /flex >}} diff --git a/content/flux/v0.x/stdlib/experimental/geo/st_contains.md b/content/flux/v0.x/stdlib/experimental/geo/st_contains.md index b7260e593..bee997d54 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/st_contains.md +++ b/content/flux/v0.x/stdlib/experimental/geo/st_contains.md @@ -1,70 +1,65 @@ --- title: geo.ST_Contains() function description: > - The `geo.ST_Contains()` function tests if the specified region contains the specified - GIS geometry and returns `true` or `false`. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_contains/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_contains/ + `geo.ST_Contains()` returns boolean indicating whether the defined region contains a + specified GIS geometry. menu: flux_0_x_ref: name: geo.ST_Contains - parent: geo -weight: 401 -flux/v0.x/tags: [geotemporal, geo, GIS, tests] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/ST_Contains +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.78.0 --- -The `geo.ST_Contains()` function tests if the specified region contains the specified -geographic information system (GIS) geometry and returns `true` or `false`. + + +`geo.ST_Contains()` returns boolean indicating whether the defined region contains a +specified GIS geometry. + + + +##### Function type signature ```js -import "experimental/geo" - -geo.ST_Contains( - region: {lat: 40.7, lon: -73.3, radius: 20.0}, - geometry: {lon: 39.7515, lat: 15.08433}, -) - -// Returns false +(geometry: A, region: B, ?units: {distance: string}) => bool where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### region {data-type="record"} -The region to test. -Specify record properties for the shape. -_See [Region definitions](/flux/v0.x/stdlib/experimental/geo/#region-definitions)._ +### region +({{< req >}}) +Region to test. Specify record properties for the shape. -### geometry {data-type="record"} -The GIS geometry to test. -Can be either point or linestring geometry. -_See [GIS geometry definitions](/flux/v0.x/stdlib/experimental/geo/#gis-geometry-definitions)._ -## Examples -##### Test if geographic points are inside of a region -```js -iimport "experimental/geo" +### geometry +({{< req >}}) +GIS geometry to test. Can be either point or linestring geometry. -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} -data - |> geo.toRows() - |> map(fn: (r) => ({r with st_contains: geo.ST_Contains(region: region, geometry: {lat: r.lat, lon: r.lon})})) -``` -##### Test if tracks are inside of a region -```js -import "experimental/geo" +### units + +Record that defines the unit of measurement for distance. +Default is the `geo.units` option. + -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} -data - |> geo.toRows() - |> geo.asTracks() - |> geo.ST_LineString() - |> map(fn: (r) => ({r with st_contains: geo.ST_Contains(region: region, geometry: {linestring: r.st_linestring})})) -``` diff --git a/content/flux/v0.x/stdlib/experimental/geo/st_distance.md b/content/flux/v0.x/stdlib/experimental/geo/st_distance.md index 5cc637306..d75214374 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/st_distance.md +++ b/content/flux/v0.x/stdlib/experimental/geo/st_distance.md @@ -1,70 +1,63 @@ --- title: geo.ST_Distance() function description: > - The `geo.ST_Distance()` function returns the distance between the specified region - and specified GIS geometry. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_distance/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_distance/ + `geo.ST_Distance()` returns the distance from a given region to a specified GIS geometry. menu: flux_0_x_ref: name: geo.ST_Distance - parent: geo -weight: 401 -flux/v0.x/tags: [geotemporal, geo, GIS] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/ST_Distance +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.78.0 --- -The `geo.ST_Distance()` function returns the distance between the specified region -and specified geographic information system (GIS) geometry. -Define distance units with the [`geo.units` option](/flux/v0.x/stdlib/experimental/geo/#define-distance-units). + + +`geo.ST_Distance()` returns the distance from a given region to a specified GIS geometry. + + + +##### Function type signature ```js -import "experimental/geo" - -geo.ST_Distance( - region: {lat: 40.7, lon: -73.3, radius: 20.0}, - geometry: {lon: 39.7515, lat: 15.08433}, -) - -// Returns 10734.184618677662 (km) +(geometry: A, region: B, ?units: {distance: string}) => float where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### region {data-type="record"} -The region to test. -Specify record properties for the shape. -_See [Region definitions](/flux/v0.x/stdlib/experimental/geo/#region-definitions)._ +### region +({{< req >}}) +Region to test. Specify record properties for the shape. -### geometry {data-type="record"} -The GIS geometry to test. -Can be either point or linestring geometry. -_See [GIS geometry definitions](/flux/v0.x/stdlib/experimental/geo/#gis-geometry-definitions)._ -## Examples -##### Calculate the distance between geographic points and a region -```js -import "experimental/geo" +### geometry +({{< req >}}) +GIS geometry to test. Can be either point or linestring geometry. -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} -data - |> geo.toRows() - |> map(fn: (r) => ({r with st_distance: ST_Distance(region: region, geometry: {lat: r.lat, lon: r.lon})})) -``` -##### Find the point nearest to a geographic location -```js -import "experimental/geo" +### units + +Record that defines the unit of measurement for distance. +Default is the `geo.units` option. + -fixedLocation = {lat: 40.7, lon: -73.3} -data - |> geo.toRows() - |> map(fn: (r) => ({r with _value: geo.ST_Distance(region: {lat: r.lat, lon: r.lon}, geometry: fixedLocation)})) - |> min() -``` diff --git a/content/flux/v0.x/stdlib/experimental/geo/st_dwithin.md b/content/flux/v0.x/stdlib/experimental/geo/st_dwithin.md index 26ae6ff5c..23b2bb24a 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/st_dwithin.md +++ b/content/flux/v0.x/stdlib/experimental/geo/st_dwithin.md @@ -1,67 +1,72 @@ --- title: geo.ST_DWithin() function description: > - The `geo.ST_DWithin()` function tests if the specified region is within a defined - distance from the specified geographic information system (GIS) geometry and - returns `true` or `false`. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_dwithin/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_dwithin/ + `geo.ST_DWithin()` tests if the specified region is within a defined distance from + the specified GIS geometry and returns `true` or `false`. menu: flux_0_x_ref: name: geo.ST_DWithin - parent: geo -weight: 401 -flux/v0.x/tags: [geotemporal, geo, GIS, tests] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/ST_DWithin +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.78.0 --- -The `geo.ST_DWithin()` function tests if the specified region is within a defined -distance from the specified geographic information system (GIS) geometry and -returns `true` or `false`. + + +`geo.ST_DWithin()` tests if the specified region is within a defined distance from +the specified GIS geometry and returns `true` or `false`. + + + +##### Function type signature ```js -import "experimental/geo" - -geo.ST_DWithin( - region: {lat: 40.7, lon: -73.3, radius: 20.0}, - geometry: {lon: 39.7515, lat: 15.08433}, - distance: 1000.0, -) - -// Returns false +(distance: A, geometry: B, region: C, ?units: {distance: string}) => bool where A: Comparable + Equatable, B: Record, C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### region {data-type="record"} -The region to test. -Specify record properties for the shape. -_See [Region definitions](/flux/v0.x/stdlib/experimental/geo/#region-definitions)._ +### region +({{< req >}}) +Region to test. Specify record properties for the shape. -### geometry {data-type="record"} -The GIS geometry to test. -Can be either point or linestring geometry. -_See [GIS geometry definitions](/flux/v0.x/stdlib/experimental/geo/#gis-geometry-definitions)._ -### distance {data-type="float"} + +### geometry +({{< req >}}) +GIS geometry to test. Can be either point or linestring geometry. + + + +### distance +({{< req >}}) Maximum distance allowed between the region and geometry. -_Define distance units with the [`geo.units` option](/flux/v0.x/stdlib/experimental/geo/#define-distance-units)._ +Define distance units with the `geo.units` option. -## Examples -##### Test if geographic points are within a distance from a region -```js -import "experimental/geo" -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} +### units + +Record that defines the unit of measurement for distance. +Default is the `geo.units` option. + + -data - |> geo.toRows() - |> map( - fn: (r) => - ({r with st_within: geo.ST_DWithin(region: box, geometry: {lat: r.lat, lon: r.lon}, distance: 15.0)}), - ) -``` diff --git a/content/flux/v0.x/stdlib/experimental/geo/st_intersects.md b/content/flux/v0.x/stdlib/experimental/geo/st_intersects.md index e3478eb54..be72b3cc9 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/st_intersects.md +++ b/content/flux/v0.x/stdlib/experimental/geo/st_intersects.md @@ -1,57 +1,65 @@ --- title: geo.ST_Intersects() function description: > - The `geo.ST_Intersects()` function tests if the specified geographic information - system (GIS) geometry intersects with the specified region and returns `true` or `false`. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_intersects/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_intersects/ + `geo.ST_Intersects()` tests if the specified GIS geometry intersects with the + specified region and returns `true` or `false`. menu: flux_0_x_ref: name: geo.ST_Intersects - parent: geo -weight: 401 -flux/v0.x/tags: [geotemporal, geo, GIS, tests] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/ST_Intersects +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.78.0 --- -The `geo.ST_Intersects()` function tests if the specified geographic information -system (GIS) geometry intersects with the specified region and returns `true` or `false`. + + +`geo.ST_Intersects()` tests if the specified GIS geometry intersects with the +specified region and returns `true` or `false`. + + + +##### Function type signature ```js -import "experimental/geo" - -geo.ST_Intersects( - region: {lat: 40.7, lon: -73.3, radius: 20.0}, - geometry: {linestring: "39.7515 14.01433, 38.3527 13.9228, 36.9978 15.08433"}, -) - -// Returns false +(geometry: A, region: B, ?units: {distance: string}) => bool where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### region {data-type="record"} -The region to test. -Specify record properties for the shape. -_See [Region definitions](/flux/v0.x/stdlib/experimental/geo/#region-definitions)._ +### region +({{< req >}}) +Region to test. Specify record properties for the shape. -### geometry {data-type="record"} -The GIS geometry to test. -Can be either point or linestring geometry. -_See [GIS geometry definitions](/flux/v0.x/stdlib/experimental/geo/#gis-geometry-definitions)._ -## Examples -##### Test if geographic points intersect with a region -```js -import "experimental/geo" +### geometry +({{< req >}}) +GIS geometry to test. Can be either point or linestring geometry. + + + +### units + +Record that defines the unit of measurement for distance. +Default is the `geo.units` option. + -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} -data - |> geo.toRows() - |> map(fn: (r) => ({r with st_within: geo.ST_Intersects(region: box, geometry: {lat: r.lat, lon: r.lon})})) -``` diff --git a/content/flux/v0.x/stdlib/experimental/geo/st_length.md b/content/flux/v0.x/stdlib/experimental/geo/st_length.md index 4af99385d..5563abea3 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/st_length.md +++ b/content/flux/v0.x/stdlib/experimental/geo/st_length.md @@ -1,55 +1,59 @@ --- title: geo.ST_Length() function description: > - The `geo.ST_Length()` function returns the [spherical length or distance](https://mathworld.wolfram.com/SphericalDistance.html) - of the specified geographic information system (GIS) geometry. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_length/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_length/ + `geo.ST_Length()` returns the [spherical length or distance](https://mathworld.wolfram.com/SphericalDistance.html) + of the specified GIS geometry. menu: flux_0_x_ref: name: geo.ST_Length - parent: geo -weight: 401 -flux/v0.x/tags: [geotemporal, geo, GIS] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/ST_Length +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.78.0 --- -The `geo.ST_Length()` function returns the [spherical length or distance](https://mathworld.wolfram.com/SphericalDistance.html) -of the specified geographic information system (GIS) geometry. -Define distance units with the [`geo.units` option](/flux/v0.x/stdlib/experimental/geo/#define-distance-units). + + +`geo.ST_Length()` returns the [spherical length or distance](https://mathworld.wolfram.com/SphericalDistance.html) +of the specified GIS geometry. + + + +##### Function type signature ```js -import "experimental/geo" - -geo.ST_Length( - geometry: {linestring: "39.7515 14.01433, 38.3527 13.9228, 36.9978 15.08433"}, -) - -// Returns 346.1023974652474 (km) +(geometry: A, ?units: {distance: string}) => float where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### geometry {data-type="record"} -The GIS geometry to measure. -Can be either point or linestring geometry. -Points will always return `0.0`. -_See [GIS geometry definitions](/flux/v0.x/stdlib/experimental/geo/#gis-geometry-definitions)._ +### geometry +({{< req >}}) +GIS geometry to test. Can be either point or linestring geometry. +Point geometry will always return `0.0`. -## Examples -##### Calculate the length of geographic paths -```js -import "experimental/geo" -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} +### units + +Record that defines the unit of measurement for distance. + + -data - |> geo.toRows() - |> geo.asTracks() - |> geo.ST_LineString() - |> map(fn: (r) => ({r with st_length: geo.ST_Length(geometry: {linestring: r.st_linestring})})) -``` diff --git a/content/flux/v0.x/stdlib/experimental/geo/st_linestring.md b/content/flux/v0.x/stdlib/experimental/geo/st_linestring.md index 7d12dd928..f1780051d 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/st_linestring.md +++ b/content/flux/v0.x/stdlib/experimental/geo/st_linestring.md @@ -1,48 +1,61 @@ --- title: geo.ST_LineString() function description: > - The `geo.ST_LineString()` function converts a series of geographic points into - [linestring](/flux/v0.x/stdlib/experimental/geo/#linestring). -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_linestring/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_linestring/ + `geo.ST_LineString()` converts a series of geographic points into linestring. menu: flux_0_x_ref: name: geo.ST_LineString - parent: geo -weight: 401 -flux/v0.x/tags: [transformations, geotemporal, geo, aggregates] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/ST_LineString +weight: 201 +flux/v0.x/tags: [geotemporal, transformations, aggregates] +introduced: 0.78.0 --- -The `geo.ST_LineString()` function converts a series of geographic points into -[linestring](/flux/v0.x/stdlib/experimental/geo/#linestring). + + +`geo.ST_LineString()` converts a series of geographic points into linestring. + Group data into meaningful, ordered paths to before converting to linestring. Rows in each table must have `lat` and `lon` columns. -Output tables contain a single row with a `st_linestring` column containing the resulting linestring. -_`geo.ST_LineString()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ +Output tables contain a single row with a `st_linestring` column containing +the resulting linestring. + +##### Function type signature ```js -import "experimental/geo" - -geo.ST_LineString() +(<-tables: stream[{A with lon: C, lat: B}]) => stream[D] where D: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + ## Examples ### Convert a series of geographic points into linestring -##### Input data - -| _time | id | lon | lat | -|:----- |:--: | ---: | ---: | -| 2020-01-01T00:00:00Z | a213b | 39.7515 | 14.01433 | -| 2020-01-02T00:00:00Z | a213b | 38.3527 | 13.9228 | -| 2020-01-03T00:00:00Z | a213b | 36.9978 | 15.08433 | - - ```js import "experimental/geo" @@ -50,8 +63,33 @@ data |> geo.ST_LineString() ``` -##### Output data +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| id | st_linestring | -|:-- |:------------- | +#### Input data + +| _time | *id | lon | lat | +| -------------------- | ----- | ------- | -------- | +| 2021-01-01T00:00:00Z | a213b | 39.7515 | 14.01433 | +| 2021-01-02T01:00:00Z | a213b | 38.3527 | 13.9228 | +| 2021-01-03T02:00:00Z | a213b | 36.9978 | 15.08433 | + +| _time | *id | lon | lat | +| -------------------- | ----- | ------- | -------- | +| 2021-01-01T00:00:00Z | b546c | 24.0069 | -14.5464 | +| 2021-01-02T01:00:00Z | b546c | 25.1304 | -13.3338 | +| 2021-01-03T02:00:00Z | b546c | 26.7899 | -12.0433 | + + +#### Output data + +| *id | st_linestring | +| ----- | --------------------------------------------------- | | a213b | 39.7515 14.01433, 38.3527 13.9228, 36.9978 15.08433 | + +| *id | st_linestring | +| ----- | ---------------------------------------------------- | +| b546c | 24.0069 -14.5464, 25.1304 -13.3338, 26.7899 -12.0433 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/geo/stcontains.md b/content/flux/v0.x/stdlib/experimental/geo/stcontains.md new file mode 100644 index 000000000..0c3c137e1 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/geo/stcontains.md @@ -0,0 +1,62 @@ +--- +title: geo.stContains() function +description: > + `geo.stContains()` returns boolean indicating whether the defined region contains a specified GIS geometry. +menu: + flux_0_x_ref: + name: geo.stContains + parent: experimental/geo + identifier: experimental/geo/stContains +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.78.0 +--- + + + +`geo.stContains()` returns boolean indicating whether the defined region contains a specified GIS geometry. + +`geo.stContains` is used as a helper function for `geo.ST_Contains()`. + +##### Function type signature + +```js +(geometry: A, region: B, units: {distance: string}) => bool where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### region +({{< req >}}) +Region to test. Specify record properties for the shape. + + + +### geometry +({{< req >}}) +GIS geometry to test. Can be either point or linestring geometry. + + + +### units +({{< req >}}) +Record that defines the unit of measurement for distance. + + + diff --git a/content/flux/v0.x/stdlib/experimental/geo/stdistance.md b/content/flux/v0.x/stdlib/experimental/geo/stdistance.md new file mode 100644 index 000000000..54b0352e2 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/geo/stdistance.md @@ -0,0 +1,62 @@ +--- +title: geo.stDistance() function +description: > + `geo.stDistance()` returns the distance from a given region to a specified GIS geometry. +menu: + flux_0_x_ref: + name: geo.stDistance + parent: experimental/geo + identifier: experimental/geo/stDistance +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.78.0 +--- + + + +`geo.stDistance()` returns the distance from a given region to a specified GIS geometry. + +`geo.stDistance` is used as a helper function for `geo.ST_Distance()`. + +##### Function type signature + +```js +(geometry: A, region: B, units: {distance: string}) => float where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### region +({{< req >}}) +Region to test. Specify record properties for the shape. + + + +### geometry +({{< req >}}) +GIS geometry to test. Can be either point or linestring geometry. + + + +### units +({{< req >}}) +Record that defines the unit of measurement for distance. + + + diff --git a/content/flux/v0.x/stdlib/experimental/geo/stlength.md b/content/flux/v0.x/stdlib/experimental/geo/stlength.md new file mode 100644 index 000000000..d891df9ec --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/geo/stlength.md @@ -0,0 +1,59 @@ +--- +title: geo.stLength() function +description: > + `geo.stLength()` returns the [spherical length or distance](https://mathworld.wolfram.com/SphericalDistance.html) + of the specified GIS geometry. +menu: + flux_0_x_ref: + name: geo.stLength + parent: experimental/geo + identifier: experimental/geo/stLength +weight: 201 +flux/v0.x/tags: [geotemporal] +introduced: 0.78.0 +--- + + + +`geo.stLength()` returns the [spherical length or distance](https://mathworld.wolfram.com/SphericalDistance.html) +of the specified GIS geometry. + +`geo.stLength` is used as a helper function for `geo.ST_Length()`. + +##### Function type signature + +```js +(geometry: A, units: {distance: string}) => float where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### geometry +({{< req >}}) +GIS geometry to test. Can be either point or linestring geometry. +Point geometry will always return `0.0`. + + + +### units +({{< req >}}) +Record that defines the unit of measurement for distance. + + + diff --git a/content/flux/v0.x/stdlib/experimental/geo/strictfilter.md b/content/flux/v0.x/stdlib/experimental/geo/strictfilter.md index e39482870..0c3676d91 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/strictfilter.md +++ b/content/flux/v0.x/stdlib/experimental/geo/strictfilter.md @@ -1,115 +1,95 @@ --- title: geo.strictFilter() function description: > - The geo.strictFilter() function filters data by latitude and longitude. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/strictfilter/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/strictfilter/ + `geo.strictFilter()` filters data by latitude and longitude in a specified region. menu: flux_0_x_ref: name: geo.strictFilter - parent: geo -weight: 401 -flux/v0.x/tags: [transformations, filters, geotemporal, geo] -related: - - /flux/v0.x/stdlib/experimental/geo/gridfilter/ - - /flux/v0.x/stdlib/experimental/geo/filterRows/ - - /flux/v0.x/stdlib/experimental/geo/toRows/ - - /{{< latest "influxdb" >}}/query-data/flux/geo/ -introduced: 0.63.0 + parent: experimental/geo + identifier: experimental/geo/strictFilter +weight: 201 +flux/v0.x/tags: [transformations, filters, geotemporal] --- -The `geo.strictFilter()` function filters data by latitude and longitude in a specified region. -This filter is more strict than [`geo.gridFilter()`](/flux/v0.x/stdlib/experimental/geo/gridfilter/), -but for the best performance, use `geo.strictFilter()` **after** `geo.gridFilter()`. -_See [Strict and non-strict filtering](#strict-and-non-strict-filtering) below._ + + +`geo.strictFilter()` filters data by latitude and longitude in a specified region. + +This filter is more strict than `geo.gridFilter()`, but for the best performance, +use `geo.strictFilter()` after `geo.gridFilter()`. +Input rows must have `lat` and `lon` columns. + +##### Function type signature ```js -import "experimental/geo" - -geo.strictFilter( - region: {lat: 40.69335938, lon: -73.30078125, radius: 20.0}, -) +(<-tables: stream[{B with lon: D, lat: C}], region: A) => stream[{B with lon: D, lat: C}] where A: Record ``` -{{% note %}} -`geo.strictFilter()` requires `lat` and `lon` columns in each row. -Use [`geo.toRows()`](/flux/v0.x/stdlib/experimental/geo/gridfilter/) -to pivot `lat` and `lon` fields into each row **before** using `geo.strictFilter()`. -{{% /note %}} - -### Strict and non-strict filtering -In most cases, the specified geographic region does not perfectly align with S2 grid cells. - -- **Strict filtering** returns only points inside the specified region. -- **Non-strict filtering** returns points that may be outside of the specified region but - inside S2 grid cells partially covered by the region. - - S2 grid cell - Filter region - Returned point - -{{< flex >}} -{{% flex-content %}} -**Strict filtering** -{{< svg "/static/svgs/geo-strict.svg" >}} -{{% /flex-content %}} -{{% flex-content %}} -**Non-strict filtering** -{{< svg "/static/svgs/geo-non-strict.svg" >}} -{{% /flex-content %}} -{{< /flex >}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### region {data-type="record"} -The region containing the desired data points. -Specify record properties for the shape. -_See [Region definitions](/flux/v0.x/stdlib/experimental/geo/#region-definitions)._ +### region +({{< req >}}) +Region containing the desired data points. + +Specify record properties for the shape. + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -##### Filter data in a box-shaped region +### Strictly filter data to a specified region + ```js import "experimental/geo" -region = {minLat: 40.51757813, maxLat: 40.86914063, minLon: -73.65234375, maxLon: -72.94921875} - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.toRows() - |> geo.strictFilter(region: region) +data + |> geo.strictFilter(region: {lat: 40.69335938, lon: -73.30078125, radius: 50.0}) ``` -##### Filter data in a circular region -```js -import "experimental/geo" +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -region = {lat: 40.69335938, lon: -73.30078125, radius: 20.0} +#### Input data -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.toRows() - |> geo.strictFilter(region: region) -``` +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | -------- | -------- | ----------- | +| 2021-01-03T02:00:00Z | a213b | 39.08433 | -75.9978 | 89bc | -##### Filter data in a custom polygon region -```js -import "experimental/geo" +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | -------- | -------- | ----------- | +| 2021-01-01T00:00:00Z | a213b | 41.01433 | -70.7515 | 89e4 | -region = { - points: [{lat: 40.671659, lon: -73.936631}, {lat: 40.706543, lon: -73.749177}, {lat: 40.791333, lon: -73.880327}], -} +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | ------- | -------- | ----------- | +| 2021-01-02T01:00:00Z | a213b | 40.9228 | -73.3527 | 89ec | -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") - |> geo.toRows() - |> geo.strictFilter(region: region) -``` + +#### Output data + +| _time | *id | lat | lon | *s2_cell_id | +| -------------------- | ----- | ------- | -------- | ----------- | +| 2021-01-02T01:00:00Z | a213b | 40.9228 | -73.3527 | 89ec | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/geo/torows.md b/content/flux/v0.x/stdlib/experimental/geo/torows.md index 2cdd5653d..72c783427 100644 --- a/content/flux/v0.x/stdlib/experimental/geo/torows.md +++ b/content/flux/v0.x/stdlib/experimental/geo/torows.md @@ -1,44 +1,91 @@ --- title: geo.toRows() function description: > - The geo.toRows() function pivots data into row-wise sets base on time. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/torows/ - - /influxdb/cloud/reference/flux/stdlib/experimental/geo/torows/ + `geo.toRows()` pivots fields into columns based on time. menu: flux_0_x_ref: name: geo.toRows - parent: geo -weight: 401 -flux/v0.x/tags: [transformations, geotemporal, geo] -related: - - /{{< latest "influxdb" >}}/query-data/flux/geo/ - - /flux/v0.x/stdlib/universe/pivot/ -introduced: 0.63.1 + parent: experimental/geo + identifier: experimental/geo/toRows +weight: 201 +flux/v0.x/tags: [transformations, geotemporal] --- -The `geo.toRows()` function pivots data into row-wise sets base on time. -For geo-temporal datasets, output rows include `lat` and `lon` columns required by -many Geo package functions. + + +`geo.toRows()` pivots fields into columns based on time. + +Latitude and longitude should be stored as fields in InfluxDB. +Because most `geo` package transformation functions require rows to have +`lat` and `lon` columns, `lat` and `lot` fields must be pivoted into columns. + +##### Function type signature ```js -import "experimental/geo" - -geo.toRows() +(<-tables: stream[A]) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Pivot lat and lon fields into columns + ```js import "experimental/geo" -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "example-measurement") +data |> geo.toRows() ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *id | *_field | _value | +| -------------------- | ----- | ------- | -------- | +| 2021-01-01T00:00:00Z | a213b | lat | 14.01433 | +| 2021-01-02T01:00:00Z | a213b | lat | 13.9228 | +| 2021-01-03T02:00:00Z | a213b | lat | 15.08433 | + +| _time | *id | *_field | _value | +| -------------------- | ----- | ------- | ------- | +| 2021-01-01T00:00:00Z | a213b | lon | 39.7515 | +| 2021-01-02T01:00:00Z | a213b | lon | 38.3527 | +| 2021-01-03T02:00:00Z | a213b | lon | 36.9978 | + + +#### Output data + +| _time | *id | lat | lon | +| -------------------- | ----- | -------- | ------- | +| 2021-01-01T00:00:00Z | a213b | 14.01433 | 39.7515 | +| 2021-01-02T01:00:00Z | a213b | 13.9228 | 38.3527 | +| 2021-01-03T02:00:00Z | a213b | 15.08433 | 36.9978 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/group.md b/content/flux/v0.x/stdlib/experimental/group.md index 655b772b6..2d9afabe7 100644 --- a/content/flux/v0.x/stdlib/experimental/group.md +++ b/content/flux/v0.x/stdlib/experimental/group.md @@ -1,63 +1,118 @@ --- title: experimental.group() function description: > - The `experimental.group()` function introduces an `extend` mode to the existing - `group()` function. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/group/ - - /influxdb/cloud/reference/flux/stdlib/experimental/group/ + `experimental.group()` introduces an `extend` mode to the existing `group()` function. menu: flux_0_x_ref: name: experimental.group parent: experimental -weight: 302 + identifier: experimental/group +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/group/ -introduced: 0.39.0 --- -The `experimental.group()` function introduces an `extend` mode to the existing -[`group()`](/flux/v0.x/stdlib/universe/group/) function. + + +`experimental.group()` introduces an `extend` mode to the existing `group()` function. + + + +##### Function type signature ```js -import "experimental" - -experimental.group(columns: ["host", "_measurement"], mode:"extend") +(<-tables: stream[A], columns: [string], mode: string) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### columns {data-type="array of strings"} -List of columns to use in the grouping operation. -Defaults to `[]`. +### columns +({{< req >}}) +List of columns to use in the grouping operation. Default is `[]`. -### mode {data-type="string"} -The mode used to group columns. -{{% note %}} -`extend` is the only mode available to `experimental.group()`. -{{% /note %}} -#### extend -Appends columns defined in the [`columns` parameter](#columns) to all existing -[group keys](/flux/v0.x/get-started/data-model/#group-key). +### mode +({{< req >}}) +Grouping mode. `extend` is the only mode available to `experimental.group()`. + +#### Grouping modes +- **extend**: Appends columns defined in the `columns` parameter to group keys. + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). ## Examples -###### Include the value column in each groups' group key +### Add a column to the group key + ```js import "experimental" -from(bucket: "example-bucket") - |> range(start: -1m) - |> experimental.group(columns: ["_value"], mode: "extend") +data + |> experimental.group(columns: ["region"], mode: "extend") ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *host | region | _value | +| -------------------- | ----- | ------- | ------- | +| 2021-01-01T00:00:00Z | host1 | east | 41 | +| 2021-01-01T00:01:00Z | host1 | east | 48 | +| 2021-01-01T00:00:00Z | host1 | west | 34 | +| 2021-01-01T00:01:00Z | host1 | west | 12 | + +| _time | *host | region | _value | +| -------------------- | ----- | ------- | ------- | +| 2021-01-01T00:00:00Z | host2 | east | 56 | +| 2021-01-01T00:01:00Z | host2 | east | 72 | +| 2021-01-01T00:00:00Z | host2 | west | 43 | +| 2021-01-01T00:01:00Z | host2 | west | 22 | + + +#### Output data + +| _time | *host | *region | _value | +| -------------------- | ----- | ------- | ------- | +| 2021-01-01T00:00:00Z | host1 | east | 41 | +| 2021-01-01T00:01:00Z | host1 | east | 48 | + +| _time | *host | *region | _value | +| -------------------- | ----- | ------- | ------- | +| 2021-01-01T00:00:00Z | host1 | west | 34 | +| 2021-01-01T00:01:00Z | host1 | west | 12 | + +| _time | *host | *region | _value | +| -------------------- | ----- | ------- | ------- | +| 2021-01-01T00:00:00Z | host2 | east | 56 | +| 2021-01-01T00:01:00Z | host2 | east | 72 | + +| _time | *host | *region | _value | +| -------------------- | ----- | ------- | ------- | +| 2021-01-01T00:00:00Z | host2 | west | 43 | +| 2021-01-01T00:01:00Z | host2 | west | 22 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/histogram.md b/content/flux/v0.x/stdlib/experimental/histogram.md index e687de929..5cfe9230d 100644 --- a/content/flux/v0.x/stdlib/experimental/histogram.md +++ b/content/flux/v0.x/stdlib/experimental/histogram.md @@ -1,124 +1,145 @@ --- title: experimental.histogram() function description: > - The `experimental.histogram()` function approximates the cumulative distribution - of a dataset by counting data frequencies for a list of bins. + `experimental.histogram()` approximates the cumulative distribution of a dataset by counting + data frequencies for a list of bins. menu: flux_0_x_ref: name: experimental.histogram parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/histogram/ - - /influxdb/cloud/reference/flux/stdlib/experimental/histogram/ -related: - - /influxdb/v2.0/query-data/flux/histograms/ - - /flux/v0.x/stdlib/universe/histogram/ + identifier: experimental/histogram +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.112.0 --- -The `experimental.histogram()` function approximates the cumulative distribution -of a dataset by counting data frequencies for a list of bins. -A bin is defined by an upper bound where all data points that are less than or -equal to the bound are counted in the bin. + + +`experimental.histogram()` approximates the cumulative distribution of a dataset by counting +data frequencies for a list of bins. + +A bin is defined by an upper bound where all data points that are less than +or equal to the bound are counted in the bin. Bin counts are cumulative. -```js -import "experimental" - -experimental.histogram( - bins: [50.0, 75.0, 90.0], - normalize: false, -) -``` - -#### Output schema -`experimental.histogram()` outputs a single table for each input table. -Each output table represents a unique histogram. -Output tables have the same group key as the corresponding input table. - -The function does the following: - +#### Function behavior +- Outputs a single table for each input table. +- Each output table represents a unique histogram. +- Output tables have the same group key as the corresponding input table. - Drops columns that are not part of the group key. - Adds an `le` column to store upper bound values. - Stores bin counts in the `_value` column. +##### Function type signature + +```js +(<-tables: stream[{A with _value: float}], bins: [float], ?normalize: bool) => stream[{A with le: float, _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bins {data-type="array of floats"} +### bins ({{< req >}}) -A list of upper bounds to use when computing the histogram frequencies, including the maximum value of the data set. -This value can be set to positive infinity if no maximum is known. +List of upper bounds to use when computing histogram frequencies, +including the maximum value of the data set. -#### Bin helper functions +This value can be set to positive infinity (`float(v: "+Inf")`) if no maximum is known. +##### Bin helper functions The following helper functions can be used to generated bins. +- `linearBins()` +- `logarithmicBins()` -[linearBins()](/flux/v0.x/stdlib/universe/linearbins) -[logarithmicBins()](/flux/v0.x/stdlib/universe/logarithmicbins) +### normalize -### normalize {data-type="bool"} Convert count values into frequency values between 0 and 1. Default is `false`. -{{% note %}} -Normalized histograms cannot be aggregated by summing their counts. -{{% /note %}} +**Note**: Normalized histograms cannot be aggregated by summing their counts. + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). ## Examples -#### Histogram with dynamically generated bins +### Create a histgram from input data + ```js import "experimental" +import "sampledata" -data - |> experimental.histogram(bins: linearBins(start: 0.0, width: 20.0, count: 5)) +sampledata.float() + |> experimental.histogram( + bins: [ + 0.0, + 5.0, + 10.0, + 15.0, + 20.0, + ], + ) ``` -##### Input data -{{< flex >}} -{{% flex-content %}} -| _time | host | _value | -|:----- |:---- | ------:| -| 2021-01-01T00:00:00Z | host1 | 33.4 | -| 2021-01-01T00:01:00Z | host1 | 57.2 | -| 2021-01-01T00:02:00Z | host1 | 78.1 | -| 2021-01-01T00:03:00Z | host1 | 79.6 | -{{% /flex-content %}} -{{% flex-content %}} -| _time | host | _value | -|:----- |:---- | ------:| -| 2021-01-01T00:00:00Z | host2 | 10.3 | -| 2021-01-01T00:01:00Z | host2 | 19.8 | -| 2021-01-01T00:02:00Z | host2 | 54.6 | -| 2021-01-01T00:03:00Z | host2 | 56.9 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Output data -{{< flex >}} -{{% flex-content %}} -| host | le | _value | -|:---- | --: | ------:| -| host1 | 0 | 0 | -| host1 | 20 | 0 | -| host1 | 40 | 1 | -| host1 | 60 | 2 | -| host1 | 80 | 4 | -| host1 | +Inf | 4 | -{{% /flex-content %}} -{{% flex-content %}} -| host | le | _value | -|:---- | --: | ------:| -| host2 | 0 | 0 | -| host2 | 20 | 2 | -| host2 | 40 | 2 | -| host2 | 60 | 4 | -| host2 | 80 | 4 | -| host2 | +Inf | 4 | -{{% /flex-content %}} -{{< /flex >}} +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| *tag | le | _value | +| ---- | --- | ------- | +| t1 | 0 | 1 | +| t1 | 5 | 2 | +| t1 | 10 | 3 | +| t1 | 15 | 4 | +| t1 | 20 | 6 | + +| *tag | le | _value | +| ---- | --- | ------- | +| t2 | 0 | 1 | +| t2 | 5 | 3 | +| t2 | 10 | 3 | +| t2 | 15 | 4 | +| t2 | 20 | 6 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/histogramquantile.md b/content/flux/v0.x/stdlib/experimental/histogramquantile.md index a5f1b07ea..3ba226e89 100644 --- a/content/flux/v0.x/stdlib/experimental/histogramquantile.md +++ b/content/flux/v0.x/stdlib/experimental/histogramquantile.md @@ -1,28 +1,40 @@ --- title: experimental.histogramQuantile() function description: > - The `experimental.histogramQuantile()` function approximates a quantile given a - histogram with the cumulative distribution of the dataset. + `experimental.histogramQuantile()` approximates a quantile given a histogram with the + cumulative distribution of the dataset. menu: flux_0_x_ref: name: experimental.histogramQuantile parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/histogramquantile/ - - /influxdb/cloud/reference/flux/stdlib/experimental/histogramquantile/ -related: - - /flux/v0.x/stdlib/universe/histogramquantile/ + identifier: experimental/histogramQuantile +weight: 101 flux/v0.x/tags: [transformations, aggregates] introduced: 0.107.0 --- -The `experimental.histogramQuantile()` function approximates a quantile given a -histogram with the cumulative distribution of the dataset. + + +`experimental.histogramQuantile()` approximates a quantile given a histogram with the +cumulative distribution of the dataset. + Each input table represents a single histogram. -Each input table represents a single histogram. -Input tables must have two columns—a count column (`_value`) and an upper bound -column (`le`), and neither column can be part of the group key. +Input tables must have two columns: a count column (`_value`) and an upper bound +column (`le`). Neither column can be part of the group key. The count is the number of values that are less than or equal to the upper bound value (`le`). Input tables can have an unlimited number of records; each record represents an entry in the histogram. @@ -37,46 +49,78 @@ The output table has the same group key as the input table. The function returns the value of the specified quantile from the histogram in the `_value` column and drops all columns not part of the group key. -```js -import "experimental" +##### Function type signature -experimental.histogramQuantile( - quantile: 0.5, - minValue: 0.0, -) +```js +( + <-tables: stream[{A with le: float, _value: float}], + ?minValue: float, + ?quantile: float, +) => stream[{A with _value: float}] ``` -_`experimental.histogramQuantile()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### quantile {data-type="float"} -A value between 0 and 1 indicating the desired quantile to compute. +### quantile + +Quantile to compute (`[0.0 - 1.0]`). + + + +### minValue + +Assumed minimum value of the dataset. Default is `0.0`. + +When the quantile falls below the lowest upper bound, the function +interpolates values between `minValue` and the lowest upper bound. +If `minValue` is equal to negative infinity, the lowest upper bound is used. + +### tables + +Input data. Default is piped-forward data (`<-`). -### minValue {data-type="float"} -The assumed minimum value of the dataset. -When the quantile falls below the lowest upper bound, interpolation is performed between `minValue` and the lowest upper bound. -When `minValue` is equal to negative infinity, the lowest upper bound is used. -Defaults to `0.0`. -{{% note %}} -When the quantile falls below the lowest upper bound (`le`), -interpolation is performed between `minValue` and the lowest upper bound. -When `minValue` is equal to negative infinity, the lowest upper bound is used. -{{% /note %}} -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). ## Examples -##### Compute the 90th quantile +### Compute the 90th percentile of a histogram + ```js import "experimental" -from(bucket: "example-bucket") - |> range(start: -1d) - |> filter(fn: (r) => r._meausrement == "example-measurement" and r._field == "example-field") +histogramData |> experimental.histogramQuantile(quantile: 0.9) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| *_field | _time | _value | le | +| ----------------- | -------------------- | ------- | ----- | +| example_histogram | 2021-01-01T00:00:00Z | 6873 | 0.005 | +| example_histogram | 2021-01-01T00:00:00Z | 9445 | 0.01 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | 0.025 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | 0.05 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | 0.1 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | 0.25 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | 0.5 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | 1 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | 2.5 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | 5 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | 10 | +| example_histogram | 2021-01-01T00:00:00Z | 9487 | +Inf | + + +#### Output data + +| *_field | _value | +| ----------------- | -------------------- | +| example_histogram | 0.008237363919129085 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/http/_index.md b/content/flux/v0.x/stdlib/experimental/http/_index.md index e89958462..a0cd427fb 100644 --- a/content/flux/v0.x/stdlib/experimental/http/_index.md +++ b/content/flux/v0.x/stdlib/experimental/http/_index.md @@ -1,30 +1,48 @@ --- -title: Flux experimental http package -list_title: http package +title: http package description: > - The Flux experimental HTTP package provides functions for transferring data - using HTTP protocol. - Import the `experimental/http` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/http/ - - /influxdb/cloud/reference/flux/stdlib/experimental/http/ + The `http` package provides functions for transferring data using HTTP protocol. menu: flux_0_x_ref: - name: http - identifier: http-exp + name: http parent: experimental -weight: 301 -flux/v0.x/tags: [functions, http, package] -introduced: 0.39.0 + identifier: experimental/http +weight: 21 +cascade: + flux/v0.x/tags: [http] + introduced: 0.39.0 --- -The Flux experimental HTTP package provides functions for transferring data -using HTTP protocol. + + +The `http` package provides functions for transferring data using HTTP protocol. Import the `experimental/http` package: ```js import "experimental/http" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} + +## Packages + +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/experimental/http/get.md b/content/flux/v0.x/stdlib/experimental/http/get.md index aec5d314d..f2a212a77 100644 --- a/content/flux/v0.x/stdlib/experimental/http/get.md +++ b/content/flux/v0.x/stdlib/experimental/http/get.md @@ -1,98 +1,82 @@ --- title: http.get() function description: > - The `http.get()` function submits an HTTP GET request to the specified URL and - returns the HTTP status code, response body, and response headers. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/http/get/ - - /influxdb/cloud/reference/flux/stdlib/experimental/http/get/ + `http.get()` submits an HTTP GET request to the specified URL and returns the HTTP + status code, response body, and response headers. menu: flux_0_x_ref: name: http.get - parent: http-exp -weight: 401 -introduced: 0.39.0 + parent: experimental/http + identifier: experimental/http/get +weight: 201 +flux/v0.x/tags: [http, inputs] --- -The `http.get()` function submits an HTTP GET request to the specified URL and -returns the HTTP status code, response body, and response headers. + + +`http.get()` submits an HTTP GET request to the specified URL and returns the HTTP +status code, response body, and response headers. + +## Response format +`http.get()` returns a record with the following properties: + +- **statusCode**: HTTP status code returned by the GET request (int). +- **body**: HTTP response body (bytes). +- **headers**: HTTP response headers (record). + +##### Function type signature + +```js +(url: string, ?headers: A, ?timeout: duration) => {statusCode: int, headers: B, body: bytes} where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### url +({{< req >}}) +URL to send the GET request to. + + + +### headers + +Headers to include with the GET request. + + + +### timeout + +Timeout for the GET request. Default is `30s`. + + + + +## Examples + +### Get the status of an InfluxDB OSS instance ```js import "experimental/http" http.get( - url: "http://localhost:8086/", - headers: {x:"a", y:"b", z:"c"}, - timeout: 30s + url: "http://localhost:8086/health", + headers: {Authorization: "Token mY5up3RS3crE7t0k3N", Accept: "application/json"}, ) ``` -## Parameters - -### url {data-type="string"} -The URL to send the GET request to. - -### headers {data-type="record"} -Headers to include with the GET request. - -### timeout {data-type="duration"} -Timeout for the GET request. -Default is `30s`. - -## Response format -`http.get` returns a record that contains the following: - -- [statusCode](#statuscode) -- [body](#body) -- [headers](#headers) - -### statusCode {data-type="int"} -The HTTP status code returned by the GET request. - -### body {data-type="bytes"} -The response body. - -### headers {data-type="record"} -Headers included with the response. - -## Examples - -##### Get the status of InfluxDB OSS -{{< keep-url >}} -```js -import "influxdata/influxdb/secrets" -import "experimental/http" -import "csv" - -token = secrets.get(key: "READONLY_TOKEN") - -response = http.get(url: "http://localhost:8086/health", headers: {Authorization: "Token ${token}"}) - -httpStatus = response.statusCode -responseBody = string(v: response.body) -responseHeaders = response.headers - -// Response header data -date = responseHeaders.Date -contentLenth = responseHeaders["Content-Length"] -contentType = responseHeaders["Content-Type"] - -// Use the returned data in a stream of tables -csvData = "#datatype,string,long,string -#group,false,false,false -#default,,, -,result,table,column -,,0,* -" - -csv.from(csv: csvData) - |> map( - fn: (r) => ({ - httpStatus: httpStatus, - responseBody: responseBody, - date: date, - contentLenth: contentLenth, - contentType: contentType, - }), - ) -``` diff --git a/content/flux/v0.x/stdlib/experimental/http/requests/_index.md b/content/flux/v0.x/stdlib/experimental/http/requests/_index.md index cf8965d70..c2c381796 100644 --- a/content/flux/v0.x/stdlib/experimental/http/requests/_index.md +++ b/content/flux/v0.x/stdlib/experimental/http/requests/_index.md @@ -1,91 +1,63 @@ --- -title: Flux experimental http requests package -list_title: requests package +title: requests package description: > - The Flux experimental HTTP requests package provides functions for transferring data - using HTTP protocol. - Import the `experimental/http/requests` package. + The `requests` package provides functions for transferring data using the HTTP protocol. menu: flux_0_x_ref: - name: requests - parent: http-exp -weight: 301 -flux/v0.x/tags: [functions, http, package] -introduced: 0.152.0 + name: requests + parent: experimental/http + identifier: experimental/http/requests +weight: 31 +cascade: + flux/v0.x/tags: [http] + introduced: 0.152.0 --- -The Flux experimental HTTP requests package provides functions for transferring data -using HTTP protocol. + + +The `requests` package provides functions for transferring data using the HTTP protocol. Import the `experimental/http/requests` package: ```js import "experimental/http/requests" ``` + + ## Options -The `experimental/http/requests` package includes the following options: ```js -import "experimental/http/requests" - option requests.defaultConfig = { + // Timeout on the request. If the timeout is zero no timeout is applied + timeout: 0s, + // insecureSkipVerify If true, TLS verification will not be performed. This is insecure. insecureSkipVerify: false, - timeout: 0ns, } ``` - + ### defaultConfig -Global default for all HTTP requests using the `experimental/http/requests` package. -Changing this option affects all other packages using the `experimental/http/requests` package. -To change configuration options for a single request, pass a new configuration -record directly into the corresponding function. -The `requests.defaultConfig` record contains the following properties: +`defaultConfig` is the global default for all http requests using the requests package. +Changing this config will affect all other packages using the requests package. +To change the config for a single request, pass a new config directly into the corresponding function. + -- **insecureSkipVerify**: Skip TLS verification _(boolean)_. Default is `false`. -- **timeout**: HTTP request timeout _(duration)_. Default is `0ns` (no timeout). -_See examples [below](#examples)._ ## Functions {{< children type="functions" show="pages" >}} - -## Examples - -### Change HTTP configuration options globally -Modify the `requests.defaultConfig` option to change all consumers of the -`experimental/http/requests` package. - -```js -import "experimental/http/requests" - -option requests.defaultConfig = { - // Set a default timeout of 5s for all requests - timeout: 0ns, - insecureSkipVerify: true, -} -``` - -### Change configuration for a single request -To change the configuration for a single request, extending the default -configuration with only the configuration values you need to customize. - -```js -import "experimental/http/requests" - -// NOTE: Flux syntax does not yet let you specify anything but an identifier as -// the record to extend. As a workaround, this example rebinds the default -// configuration to a new name, "config". -// See https://github.com/influxdata/flux/issues/3655 -defaultConfig = requests.defaultConfig -config = {defaultConfig with - // Change the timeout to 60s for this request - // NOTE: We don't have to specify any other properites of the config because we're - // extending the default. - timeout: 60s, -} -response = requests.get(url:"http://example.com", config: config) - -requests.peek(response: response) -``` \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/http/requests/do.md b/content/flux/v0.x/stdlib/experimental/http/requests/do.md index c4ff02280..ca551f878 100644 --- a/content/flux/v0.x/stdlib/experimental/http/requests/do.md +++ b/content/flux/v0.x/stdlib/experimental/http/requests/do.md @@ -1,163 +1,138 @@ --- title: requests.do() function description: > - `requests.do()` makes an HTTP request using the specified request method. + `requests.do()` makes an http request. menu: flux_0_x_ref: name: requests.do - parent: requests -weight: 401 -flux/v0.x/tags: [http, inputs, outputs] -introduced: 0.152.0 + parent: experimental/http/requests + identifier: experimental/http/requests/do +weight: 301 +flux/v0.x/tags: [http, inputs] --- -`requests.do()` makes an HTTP request using the specified request method. + + +`requests.do()` makes an http request. + + + +The returned response contains the following properties: + +- statusCode: HTTP status code returned from the request. +- body: Contents of the request. A maximum size of 100MB will be read from the response body. +- headers: Headers present on the response. +- duration: Duration of request. + +##### Function type signature ```js -import "experimental/http/requests" - -requests.do( - method: "GET", - url: "http://example.com", - params: ["example-param": ["example-param-value"]], - headers: ["Example-Header": "example-header-value"], - body: bytes(v: ""), - config: requests.defaultConfig, -) +( + method: string, + url: string, + ?body: bytes, + ?config: {A with timeout: duration, insecureSkipVerify: bool}, + ?headers: [string:string], + ?params: [string:[string]], +) => {statusCode: int, headers: [string:string], duration: duration, body: bytes} ``` -`requests.do()` returns a record with the following properties: - -- **statusCode**: HTTP status code of the request _(as an [integer](/flux/v0.x/data-types/basic/int/))_. -- **body**: Response body _(as [bytes](/flux/v0.x/data-types/basic/bytes/))_. - A maximum size of 100MB is read from the response body. -- **headers**: Response headers _(as a [dictionary](/flux/v0.x/data-types/composite/dict/))_. -- **duration**: Request duration _(as a [duration](/flux/v0.x/data-types/basic/duration/))_. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### method {data-type="string"} -HTTP request method. +### method +({{< req >}}) +method of the http request. +Supported methods: DELETE, GET, HEAD, PATCH, POST, PUT. -**Supported methods**: -- DELETE -- GET -- HEAD -- PATCH -- POST -- PUT -### url {data-type="string"} -URL to send the request to. -{{% note %}} -The URL should not include any query parameters. -Use [`params`](#params) to specify query parameters. -{{% /note %}} +### url +({{< req >}}) +URL to request. This should not include any query parameters. -### params {data-type="dict"} -Set of key-value pairs to add to the URL as query parameters. -Query parameters are URL-encoded. -All values for a key are appended to the query. -### headers {data-type="dict"} -Set of key values pairs to include as request headers. -### body {data-type="bytes"} +### params + +Set of key value pairs to add to the URL as query parameters. +Query parameters will be URL encoded. +All values for a key will be appended to the query. + + + +### headers + +Set of key values pairs to include on the request. + + + +### body + Data to send with the request. -### config {data-type="record"} -Set of request configuration options. -_See [HTTP configuration option examples](/flux/v0.x/stdlib/experimental/http/requests/#examples)._ + + +### config + +Set of options to control how the request should be performed. + + + ## Examples - [Make a GET request](#make-a-get-request) -- [Make a GET request with authorization](#make-a-get-request-with-authorization) +- [Make a GET request that needs authorization](#make-a-get-request-that-needs-authorization) - [Make a GET request with query parameters](#make-a-get-request-with-query-parameters) -- [Make a GET request and decode the JSON response](#make-a-get-request-and-decode-the-json-response) -- [Make a POST request with a JSON body](#make-a-post-request-with-a-json-body) -- [Output HTTP response data in a table](#output-http-response-data-in-a-table) ### Make a GET request + ```js import "experimental/http/requests" -requests.do(url:"http://example.com", method: "GET") +response = requests.do(url: "http://example.com", method: "GET") + +requests.peek(response: response) ``` -### Make a GET request with authorization + +### Make a GET request that needs authorization + ```js import "experimental/http/requests" import "influxdata/influxdb/secrets" -token = secrets.get(key:"TOKEN") +token = secrets.get(key: "TOKEN") -requests.do( - method: "GET", - url: "http://example.com", - headers: ["Authorization": "Token ${token}"], -) -``` - -### Make a GET request with query parameters -```js -import "experimental/http/requests" - -requests.do(method: "GET", url: "http://example.com", params: ["start": ["100"]]) -``` - -### Make a GET request and decode the JSON response -To decode a JSON response, import the [`experimental/json` package](/flux/v0.x/stdlib/experimental/json/) -and use [`json.parse()`](/flux/v0.x/stdlib/experimental/json/parse/) to parse -the response into a [Flux type](/flux/v0.x/data-types/). - -```js -import "experimental/http/requests" -import "experimental/json" -import "array" - -response = requests.do(method: "GET", url: "https://api.agify.io", params: ["name": ["nathaniel"]]) - -// api.agify.io returns JSON with the form -// -// { -// name: string, -// age: number, -// count: number, -// } -// -// Define a data variable that parses the JSON response body into a Flux record. -data = json.parse(data: response.body) - -// Use array.from() to construct a table with one row containing our response data. -array.from(rows: [{name: data.name, age: data.age, count: data.count}]) -``` - -### Make a POST request with a JSON body -Use [`json.encode()`](/flux/v0.x/stdlib/json/encode/) to encode a Flux record as -a JSON object. - -```js -import "experimental/http/requests" -import "json" - -requests.do( - method: "POST", - url: "https://goolnk.com/api/v1/shorten", - body: json.encode(v: {url: "http://www.influxdata.com"}), - headers: ["Content-Type": "application/json"], -) -``` - -### Output HTTP response data in a table -To quickly inspect HTTP response data, use [`requests.peek()`](/flux/v0.x/stdlib/experimental/http/requests/peek/) -to output HTTP response data in a table. - -```js -import "experimental/http/requests" - -response = requests.do(method: "GET", url: "http://example.com") +response = requests.do(method: "GET", url: "http://example.com", headers: ["Authorization": "token ${token}"]) requests.peek(response: response) -``` \ No newline at end of file +``` + + +### Make a GET request with query parameters + +```js +import "experimental/http/requests" + +response = requests.do(method: "GET", url: "http://example.com", params: ["start": ["100"]]) + +requests.peek(response: response) +``` + diff --git a/content/flux/v0.x/stdlib/experimental/http/requests/get.md b/content/flux/v0.x/stdlib/experimental/http/requests/get.md index db7fef574..d30037565 100644 --- a/content/flux/v0.x/stdlib/experimental/http/requests/get.md +++ b/content/flux/v0.x/stdlib/experimental/http/requests/get.md @@ -1,96 +1,109 @@ --- title: requests.get() function description: > - `requests.get()` makes an HTTP request using the GET request method. + `requests.get()` makes a http GET request. This identical to calling `request.do(method: "GET", ...)`. menu: flux_0_x_ref: name: requests.get - parent: requests -weight: 401 -flux/v0.x/tags: [http, inputs, outputs] -introduced: 0.152.0 + parent: experimental/http/requests + identifier: experimental/http/requests/get +weight: 301 +flux/v0.x/tags: [http, inputs] --- -`requests.get()` makes an HTTP request using the GET request method. + + +`requests.get()` makes a http GET request. This identical to calling `request.do(method: "GET", ...)`. + + + +##### Function type signature ```js -import "experimental/http/requests" - -requests.get( - url: "http://example.com", - params: ["example-param": ["example-param-value"]], - headers: ["Example-Header": "example-header-value"], - body: bytes(v: ""), - config: requests.defaultConfig, -) +( + url: string, + ?body: bytes, + ?config: {A with timeout: duration, insecureSkipVerify: bool}, + ?headers: [string:string], + ?params: [string:[string]], +) => {statusCode: int, headers: [string:string], duration: duration, body: bytes} ``` -`requests.get()` returns a record with the following properties: - -- **statusCode**: HTTP status code of the request. -- **body**: Response body. A maximum size of 100MB is read from the response body. -- **headers**: Response headers. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### url {data-type="string"} -URL to send the request to. +### url +({{< req >}}) +URL to request. This should not include any query parameters. -{{% note %}} -The URL should not include any query parameters. -Use [`params`](#params) to specify query parameters. -{{% /note %}} -### params {data-type="dict"} -Set of key-value pairs to add to the URL as query parameters. -Query parameters are URL-encoded. -All values for a key are appended to the query. -### headers {data-type="dict"} -Set of key values pairs to include as request headers. +### params + +Set of key value pairs to add to the URL as query parameters. +Query parameters will be URL encoded. +All values for a key will be appended to the query. + + + +### headers + +Set of key values pairs to include on the request. + + + +### body -### body {data-type="bytes"} Data to send with the request. -### config {data-type="record"} -Set of request configuration options. -_See [HTTP configuration option examples](/flux/v0.x/stdlib/experimental/http/requests/#examples)._ + + +### config + +Set of options to control how the request should be performed. + + + ## Examples - [Make a GET request](#make-a-get-request) -- [Make a GET request with authorization](#make-a-get-request-with-authorization) - [Make a GET request and decode the JSON response](#make-a-get-request-and-decode-the-json-response) -- [Output HTTP response data in a table](#output-http-response-data-in-a-table) ### Make a GET request + ```js import "experimental/http/requests" -requests.get(url:"http://example.com") +response = requests.get(url: "http://example.com") + +requests.peek(response: response) ``` -### Make a GET request with authorization -```js -import "experimental/http/requests" -import "influxdata/influxdb/secrets" - -token = secrets.get(key: "TOKEN") - -requests.get(url: "http://example.com", headers: ["Authorization": "Bearer ${token}"]) -``` ### Make a GET request and decode the JSON response -To decode a JSON response, import the [`experimental/json` package](/flux/v0.x/stdlib/experimental/json/) -and use [`json.parse()`](/flux/v0.x/stdlib/experimental/json/parse/) to parse -the response into a [Flux type](/flux/v0.x/data-types/). ```js import "experimental/http/requests" import "experimental/json" import "array" -response = requests.get(url: "https://api.agify.io", params: ["name": ["john"]]) +response = requests.get(url: "https://api.agify.io", params: ["name": ["nathaniel"]]) // api.agify.io returns JSON with the form // @@ -104,17 +117,18 @@ response = requests.get(url: "https://api.agify.io", params: ["name": ["john"]]) data = json.parse(data: response.body) // Use array.from() to construct a table with one row containing our response data. -array.from(rows: [{name: data.name, age: data.age, count: data.count}]) +// We do not care about the count so only include name and age. +array.from(rows: [{name: data.name, age: data.age}]) ``` -### Output HTTP response data in a table -To quickly inspect HTTP response data, use [`requests.peek()`](/flux/v0.x/stdlib/experimental/http/requests/peek/) -to output HTTP response data in a table. +{{< expand-wrapper >}} +{{% expand "View example output" %}} -```js -import "experimental/http/requests" +#### Output data -response = requests.get(url: "http://example.com") +| name | age | +| --------- | ---- | +| nathaniel | 30 | -requests.peek(response: response) -``` +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/http/requests/peek.md b/content/flux/v0.x/stdlib/experimental/http/requests/peek.md index 950df2b45..dcac28703 100644 --- a/content/flux/v0.x/stdlib/experimental/http/requests/peek.md +++ b/content/flux/v0.x/stdlib/experimental/http/requests/peek.md @@ -5,70 +5,89 @@ description: > menu: flux_0_x_ref: name: requests.peek - parent: requests -weight: 401 -flux/v0.x/tags: [http] -introduced: 0.154.0 + parent: experimental/http/requests + identifier: experimental/http/requests/peek +weight: 301 --- + + `requests.peek()` converts an HTTP response into a table for easy inspection. -```js -import "experimental/http/requests" - -requests.peek( - response: requests.get(url: "http://example.com") -) -``` - The output table includes the following columns: + - **body** with the response body as a string + - **statusCode** with the returned status code as an integer + - **headers** with a string representation of the headers + - **duration** the duration of the request as a number of nanoseconds -- **body**: response body as a string -- **statusCode**: returned status code as an integer -- **headers**: string representation of response headers -- **duration**: request duration in nanoseconds - -{{% note %}} To customize how the response data is structured in a table, use `array.from()` with a function like `json.parse()`. Parse the response body into a set of values and then use `array.from()` to construct a table from those values. -{{% /note %}} +##### Function type signature + +```js +( + response: {A with statusCode: E, headers: D, duration: C, body: B}, +) => stream[{statusCode: E, headers: string, duration: int, body: string}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### response {data-type="record"} +### response +({{< req >}}) Response data from an HTTP request. + + + ## Examples ### Inspect the response of an HTTP request + ```js import "experimental/http/requests" -response = requests.get(url: "https://api.agify.io", params: ["name": ["natalie"]]) - -requests.peek(response: response) +requests.peek(response: requests.get(url: "https://api.agify.io", params: ["name": ["natalie"]])) ``` -| statusCode | body | headers | duration | -| :--------- | :--- | :------ | -------: | -| 200 | {"name":"natalie","age":34,"count":20959} | _See [returned headers](#returned-headers) string below_ | 1212263875 | +{{< expand-wrapper >}} +{{% expand "View example output" %}} -##### Returned headers -``` -[ - Access-Control-Allow-Headers: Content-Type, X-Genderize-Source, - Access-Control-Allow-Methods: GET, - Access-Control-Allow-Origin: *, - Connection: keep-alive, - Content-Length: 41, - Content-Type: application/json; charset=utf-8, - Date: Wed, 09 Feb 2022 20:00:00 GMT, - Etag: W/"29-klDahUESBLxHyQ7NiaetCn2CvCI", - Server: nginx/1.16.1, - X-Rate-Limit-Limit: 1000, - X-Rate-Limit-Remaining: 999, - X-Rate-Reset: 12203 -] -``` +#### Output data + +| body | duration | headers | statusCode | +| ----------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| {"name":"natalie","age":34,"count":20959} | 100000000 | [ + Access-Control-Allow-Headers: Content-Type, X-Genderize-Source, + Access-Control-Allow-Methods: GET, + Access-Control-Allow-Origin: *, + Connection: keep-alive, + Content-Length: 41, + Content-Type: application/json; charset=utf-8, + Date: Tue, 14 Jun 2022 15:25:06 GMT, + Etag: W/"29-klDahUESBLxHyQ7NiaetCn2CvCI", + Server: nginx/1.16.1, + X-Rate-Limit-Limit: 1000, + X-Rate-Limit-Remaining: 998, + X-Rate-Reset: 30894 +] | 200 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/http/requests/post.md b/content/flux/v0.x/stdlib/experimental/http/requests/post.md index cbac6fbf8..48000ce75 100644 --- a/content/flux/v0.x/stdlib/experimental/http/requests/post.md +++ b/content/flux/v0.x/stdlib/experimental/http/requests/post.md @@ -1,114 +1,115 @@ --- title: requests.post() function description: > - `requests.post()` makes an HTTP request using the POST request method. + `requests.post()` makes a http POST request. This identical to calling `request.do(method: "POST", ...)`. menu: flux_0_x_ref: name: requests.post - parent: requests -weight: 401 -flux/v0.x/tags: [http, inputs, outputs] -introduced: 0.152.0 + parent: experimental/http/requests + identifier: experimental/http/requests/post +weight: 301 +flux/v0.x/tags: [http, inputs] --- -`requests.post()` makes an HTTP request using the POST request method. + + +`requests.post()` makes a http POST request. This identical to calling `request.do(method: "POST", ...)`. + + + +##### Function type signature ```js -import "experimental/http/requests" - -requests.post( - url: "http://example.com", - params: ["example-param": ["example-param-value"]], - headers: ["Example-Header": "example-header-value"], - body: bytes(v: ""), - config: requests.defaultConfig, -) +( + url: string, + ?body: bytes, + ?config: {A with timeout: duration, insecureSkipVerify: bool}, + ?headers: [string:string], + ?params: [string:[string]], +) => {statusCode: int, headers: [string:string], duration: duration, body: bytes} ``` -`requests.post()` returns a record with the following properties: - -- **statusCode**: HTTP status code of the request. -- **body**: Response body. A maximum size of 100MB is read from the response body. -- **headers**: Response headers. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### url {data-type="string"} -URL to send the request to. +### url +({{< req >}}) +URL to request. This should not include any query parameters. -{{% note %}} -The URL should not include any query parameters. -Use [`params`](#params) to specify query parameters. -{{% /note %}} -### params {data-type="dict"} -Set of key-value pairs to add to the URL as query parameters. -Query parameters are URL-encoded. -All values for a key are appended to the query. -### headers {data-type="dict"} -Set of key values pairs to include as request headers. +### params + +Set of key value pairs to add to the URL as query parameters. +Query parameters will be URL encoded. +All values for a key will be appended to the query. + + + +### headers + +Set of key values pairs to include on the request. + + + +### body -### body {data-type="bytes"} Data to send with the request. -### config {data-type="record"} -Set of request configuration options. -_See [HTTP configuration option examples](/flux/v0.x/stdlib/experimental/http/requests/#examples)._ + + +### config + +Set of options to control how the request should be performed. + + + ## Examples -- [Make a POST request](#make-a-post-request) -- [Make a POST request with authorization](#make-a-post-request-with-authorization) -- [Make a POST request with a JSON body](#make-a-post-request-with-a-json-body) -- [Output HTTP POST response data in a table](#output-http-post-response-data-in-a-table) +### Make a POST request with a JSON body and decode JSON response -### Make a POST request ```js +import "experimental/http/requests" +import ejson "experimental/json" import "json" -import "experimental/http/requests" +import "array" -requests.post(url:"http://example.com", body: json.encode(v: {data: {x:1, y: 2, z:3})) +response = + requests.post( + url: "https://goolnk.com/api/v1/shorten", + body: json.encode(v: {url: "http://www.influxdata.com"}), + headers: ["Content-Type": "application/json"], + ) + +data = ejson.parse(data: response.body) + +array.from(rows: [data]) ``` -### Make a POST request with authorization -```js -import "json" -import "experimental/http/requests" -import "influxdata/influxdb/secrets" +{{< expand-wrapper >}} +{{% expand "View example output" %}} -token = secrets.get(key: "TOKEN") +#### Output data -requests.post( - url: "http://example.com", - body: json.encode(v: {data: {x: 1, y: 2, z: 3}}), - headers: ["Authorization": "Bearer ${token}"], -) -``` +| result_url | +| ------------------------- | +| https://goolnk.com/BnXAE6 | -### Make a POST request with a JSON body -Use [`json.encode()`](/flux/v0.x/stdlib/json/encode/) to encode a Flux record as -a JSON object. - -```js -import "experimental/http/requests" -import "json" - -requests.post( - url: "https://goolnk.com/api/v1/shorten", - body: json.encode(v: {url: "http://www.influxdata.com"}), - headers: ["Content-Type": "application/json"], -) -``` - -### Output HTTP POST response data in a table -To quickly inspect HTTP response data, use [`requests.peek()`](/flux/v0.x/stdlib/experimental/http/requests/peek/) -to output HTTP response data in a table. - -```js -import "experimental/http/requests" - -response = requests.post(url: "http://example.com") - -requests.peek(response: response) -``` +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/influxdb/_index.md b/content/flux/v0.x/stdlib/experimental/influxdb/_index.md index 17c0d547c..b9e36ca05 100644 --- a/content/flux/v0.x/stdlib/experimental/influxdb/_index.md +++ b/content/flux/v0.x/stdlib/experimental/influxdb/_index.md @@ -1,29 +1,44 @@ --- -title: Flux Experimental InfluxDB package -list_title: influxdb package +title: influxdb package description: > - Flux experimental InfluxDB package provides tools for working with the InfluxDB API. - Import the `experimental/influxdb` package. + The `influxdb` package provides tools for working with the InfluxDB API. menu: flux_0_x_ref: - name: influxdb - identifier: influxdb-exp + name: influxdb parent: experimental -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/influxdb/ - - /influxdb/cloud/reference/flux/stdlib/experimental/influxdb/ -weight: 301 -flux/v0.x/tags: [functions, api, package, influxdb] + identifier: experimental/influxdb +weight: 21 cascade: + introduced: 0.114.0 --- -Flux experimental InfluxDB package provides tools for working with the InfluxDB API. + + +The `influxdb` package provides tools for working with the InfluxDB API. Import the `experimental/influxdb` package: ```js import "experimental/influxdb" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/influxdb/api.md b/content/flux/v0.x/stdlib/experimental/influxdb/api.md index 28be6eebe..b2fcf7a70 100644 --- a/content/flux/v0.x/stdlib/experimental/influxdb/api.md +++ b/content/flux/v0.x/stdlib/experimental/influxdb/api.md @@ -1,89 +1,124 @@ --- title: influxdb.api() function description: > - The `influxdb.api()` function submits an HTTP request to the specified InfluxDB - API path and returns a record containing the HTTP status code, response headers, - and response body as a byte array. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/influxdb/api/ - - /influxdb/cloud/reference/flux/stdlib/experimental/influxdb/api/ + `influxdb.api()` submits an HTTP request to the specified InfluxDB API path and returns a + record containing the HTTP status code, response headers, and the response body. menu: flux_0_x_ref: name: influxdb.api - parent: influxdb-exp -weight: 401 + parent: experimental/influxdb + identifier: experimental/influxdb/api +weight: 201 --- -The `influxdb.api()` function submits an HTTP request to the specified InfluxDB -API path and returns a record containing the HTTP status code, response headers, -and response body as a byte array. + + +`influxdb.api()` submits an HTTP request to the specified InfluxDB API path and returns a +record containing the HTTP status code, response headers, and the response body. + +**Note**: `influxdb.api()` uses the authorization of the specified `token` or, if executed +from the InfluxDB UI, the authorization of the InfluxDB user that invokes the script. Authorization permissions and limits apply to each request. -```js -import "experimental/influxdb" +## Response format +`influxdb.api()` returns a record with the following properties: -influxdb.api( - method: "get", - path: "/example", - host: "http://localhost:8086", - token: "mySupeR53cre7t0k3n", - headers: ["header1": "header1Value", "header2": "header2Value"], - query: ["ex1": "example1", "ex2": "example2"], - timeout: 30s, - body: bytes(v: "Example body"), -) +- **statusCode**: HTTP status code returned by the GET request (int). +- **headers**: HTTP response headers (dict). +- **body**: HTTP response body (bytes). + +##### Function type signature + +```js +( + method: string, + path: string, + ?body: bytes, + ?headers: [string:string], + ?host: string, + ?query: [string:string], + ?timeout: duration, + ?token: string, +) => {statusCode: int, headers: [string:string], body: bytes} ``` -{{< expand-wrapper >}} -{{% expand "View response record schema" %}} -```js -{ - statusCode: int, - headers: dict, - body: bytes, -} -``` -{{% /expand %}} -{{< /expand-wrapper >}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### method {data-type="string"} -({{< req >}}) HTTP request method. +### method +({{< req >}}) +HTTP request method. -### path {data-type="string"} -({{< req >}}) InfluxDB API path. -### host {data-type="string"} -InfluxDB host URL + +### path +({{< req >}}) +InfluxDB API path. + + + +### host + +InfluxDB host URL _(Required when executed outside of InfluxDB)_. +Default is `""`. + + + +### token + +[InfluxDB API token](https://docs.influxdata.com/influxdb/cloud/security/tokens/) _(Required when executed outside of InfluxDB)_. Default is `""`. -### token {data-type="string"} -InfluxDB [API token](/{{< latest "influxdb" >}}/security/tokens/) -_(Required when executed outside of InfluxDB)_. -Default is `""`. -### headers {data-type="dict"} + +### headers + HTTP request headers. -### query {data-type="dict"} + + +### query + URL query parameters. -### timeout {data-type="duration"} -HTTP request timeout. -Default is `30s`. -### body {data-type="bytes"} -HTTP request body as [bytes](/flux/v0.x/stdlib/universe/bytes/). + +### timeout + +HTTP request timeout. Default is `30s`. + + + +### body + +HTTP request body as bytes. + + + ## Examples -##### Retrieve the health of an InfluxDB OSS instance -{{< keep-url >}} +- [Retrieve the health of an InfluxDB OSS instance](#retrieve-the-health-of-an-influxdb-oss-instance) +- [Create a bucket through the InfluxDB Cloud API](#create-a-bucket-through-the-influxdb-cloud-api) + +### Retrieve the health of an InfluxDB OSS instance + ```js import "experimental/influxdb" import "influxdata/influxdb/secrets" @@ -93,20 +128,14 @@ token = secrets.get(key: "INFLUX_TOKEN") response = influxdb.api(method: "get", path: "/health", host: "http://localhost:8086", token: token) string(v: response.body) -// Returns something similar to: -// { -// "name":"influxdb", -// "message":"ready for queries and writes", -// "status":"pass", -// "checks":[], -// "version": "dev", -// "commit": "000xX0xx0X" -// } ``` -##### Create a bucket through the InfluxDB API + +### Create a bucket through the InfluxDB Cloud API + ```js import "experimental/influxdb" +import "json" import "influxdata/influxdb/secrets" token = secrets.get(key: "INFLUX_TOKEN") @@ -114,15 +143,17 @@ token = secrets.get(key: "INFLUX_TOKEN") influxdb.api( method: "post", path: "/api/v2/buckets", - host: "http://localhost:8086", + host: "https://us-west-2-1.aws.cloud2.influxdata.com", token: token, - body: bytes( - v: "{ - \"name\": \"example-bucket\", - \"description\": \"This is an example bucket.\", - \"orgID\": \"x000X0x0xx0X00x0\", - \"retentionRules\": [] - }", - ), + body: + json.encode( + v: { + name: "example-bucket", + description: "This is an example bucket.", + orgID: "x000X0x0xx0X00x0", + retentionRules: [], + }, + ), ) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/integral.md b/content/flux/v0.x/stdlib/experimental/integral.md index b2a81821e..80573a06d 100644 --- a/content/flux/v0.x/stdlib/experimental/integral.md +++ b/content/flux/v0.x/stdlib/experimental/integral.md @@ -1,69 +1,174 @@ --- title: experimental.integral() function description: > - The `integral()` function computes the area under the curve per unit of time of subsequent non-null records. - Input tables must have `_time` and `_value` columns. + `experimental.integral()` computes the area under the curve per unit of time of subsequent non-null records. menu: flux_0_x_ref: name: experimental.integral parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/integral/ - - /influxdb/cloud/reference/flux/stdlib/experimental/integral/ -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#integral, InfluxQL – INTEGRAL() - - /flux/v0.x/stdlib/universe/integral/ + identifier: experimental/integral +weight: 101 flux/v0.x/tags: [transformations, aggregates] introduced: 0.106.0 --- -The `experimental.integral()` function computes the area under the curve per -[`unit`](#unit) of time of subsequent non-null records. + + +`experimental.integral()` computes the area under the curve per unit of time of subsequent non-null records. + The curve is defined using `_time` as the domain and record values as the range. -**Input tables must have `_time` and `_value` columns.** -_`integral()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + +Input tables must have `_start`, _stop`, `_time`, and `_value` columns. +`_start` and `_stop` must be part of the group key. + +##### Function type signature ```js -integral( - unit: 10s, - interpolate: "", -) +(<-tables: stream[{A with _value: B, _time: time}], ?interpolate: string, ?unit: duration) => stream[{A with _value: B}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### unit {data-type="duration"} -({{< req >}}) +### unit + Time duration used to compute the integral. -### interpolate {data-type="string"} -Type of interpolation to use. -Defaults to `""`. + + +### interpolate + +Type of interpolation to use. Default is `""` (no interpolation). Use one of the following interpolation options: - -- _empty string for no interpolation_ +- empty string (`""`) for no interpolation - linear -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -##### Calculate the integral +- [Calculate the integral](#calculate-the-integral) +- [Calculate the integral with linear interpolation](#calculate-the-integral-with-linear-interpolation) + +### Calculate the integral + ```js -from(bucket: "example-bucket") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_system") - |> integral(unit: 10s) +import "experimental" +import "sampledata" + +data = + sampledata.int() + |> range(start: sampledata.start, stop: sampledata.stop) + +data + |> experimental.integral(unit: 20s) ``` -##### Calculate the integral with linear interpolation +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *_start | *_stop | *tag | _value | +| -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 25 | + +| *_start | *_stop | *tag | _value | +| -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 21.5 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Calculate the integral with linear interpolation + ```js -from(bucket: "example-bucket") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_system") - |> integral(unit: 10s, interpolate: "linear") +import "experimental" +import "sampledata" + +data = + sampledata.int() + |> range(start: sampledata.start, stop: sampledata.stop) + +data + |> experimental.integral(unit: 20s, interpolate: "linear") ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *_start | *_stop | *tag | _value | +| -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 24.25 | + +| *_start | *_stop | *tag | _value | +| -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 19 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/iox/_index.md b/content/flux/v0.x/stdlib/experimental/iox/_index.md index eec189f86..ecad77cbf 100644 --- a/content/flux/v0.x/stdlib/experimental/iox/_index.md +++ b/content/flux/v0.x/stdlib/experimental/iox/_index.md @@ -1,25 +1,41 @@ --- -title: Flux Experimental IOx package -list_title: iox package +title: iox package description: > - The Flux experimental `iox` package provides functions for querying data from IOx. - Import the `experimental/iox` package. + The `iox` package provides functions for querying data from IOx. menu: flux_0_x_ref: - name: iox + name: iox parent: experimental -weight: 301 -flux/v0.x/tags: [functions, iox, package] -introduced: 0.152.0 + identifier: experimental/iox +weight: 21 --- -The experimental `iox` package provides functions for querying data from [IOx](https://github.com/influxdata/influxdb_iox). + + +The `iox` package provides functions for querying data from IOx. Import the `experimental/iox` package: ```js -import 'experimental/iox'; +import "experimental/iox" ``` + + + ## Functions {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/iox/from.md b/content/flux/v0.x/stdlib/experimental/iox/from.md index 9df1bb1f6..c4d4b4fe8 100644 --- a/content/flux/v0.x/stdlib/experimental/iox/from.md +++ b/content/flux/v0.x/stdlib/experimental/iox/from.md @@ -1,42 +1,56 @@ --- title: iox.from() function description: > - `iox.from()` queries data from the specified bucket and measurement in an IOx - storage node. + `iox.from()` reads from the selected bucket and measurement in an iox storage node. menu: flux_0_x_ref: name: iox.from - parent: iox -weight: 401 -flux/v0.x/tags: [iox, inputs] -introduced: 0.152.0 + parent: experimental/iox + identifier: experimental/iox/from +weight: 201 --- -{{% warn %}} -`iox.from()` is in active development and has not been fully implemented. -This function acts as a placeholder as the implementation is completed. -{{% /warn %}} + + +`iox.from()` reads from the selected bucket and measurement in an iox storage node. + +This function creates a source that reads data from IOx. Output data is +"pivoted" on the time column and includes columns for each returned +tag and field per time value. + +##### Function type signature ```js -import "experimental/iox" - -iox.from( - bucket: "example-bucket", - measurement: "example-measurement", -) +(bucket: string, measurement: string) => stream[{A with _time: time}] where A: Record ``` -Output data is "pivoted" on the time column and includes columns for each -returned tag and field per time value. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) IOx bucket to read data from. -### measurement {data-type="string"} + + +### measurement +({{< req >}}) Measurement to read data from. + + diff --git a/content/flux/v0.x/stdlib/experimental/join.md b/content/flux/v0.x/stdlib/experimental/join.md index 2902ca9b5..481bdc8b1 100644 --- a/content/flux/v0.x/stdlib/experimental/join.md +++ b/content/flux/v0.x/stdlib/experimental/join.md @@ -1,135 +1,145 @@ --- title: experimental.join() function description: > - The `experimental.join()` function joins two streams of tables on the - group key with the addition of the `_time` column. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/join/ - - /influxdb/cloud/reference/flux/stdlib/experimental/join/ + `experimental.join()` joins two streams of tables on the **group key and `_time` column**. menu: flux_0_x_ref: name: experimental.join parent: experimental -weight: 302 + identifier: experimental/join +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.65.0 --- -The `experimental.join()` function joins two streams of tables on the -[group key](/flux/v0.x/get-started/data-model/#group-key) and `_time` column. -Use the [`fn` parameter](#fn) to map new output tables using values from input tables. + + +`experimental.join()` joins two streams of tables on the **group key and `_time` column**. + +Use the `fn` parameter to map new output tables using values from input tables. + +**Note**: To join streams of tables with different fields or measurements, +use `group()` or `drop()` to remove `_field` and `_measurement` from the +group key before joining. + +##### Function type signature ```js -import "experimental" - -// ... - -experimental.join( - left: left, - right: right, - fn: (left, right) => ({left with lv: left._value, rv: right._value }), -) +(fn: (left: A, right: B) => C, left: stream[A], right: stream[B]) => stream[C] where A: Record, B: Record, C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### left {data-type="stream of tables"} +### left +({{< req >}}) First of two streams of tables to join. -### right {data-type="stream of tables"} + + +### right +({{< req >}}) Second of two streams of tables to join. -### fn {data-type="function"} -A function with `left` and `right` arguments that maps a new output record + + +### fn +({{< req >}}) +Function with left and right arguments that maps a new output record using values from the `left` and `right` input records. The return value must be a record. + + + ## Examples -### Input and output tables +- [Join two streams of tables](#join-two-streams-of-tables) +- [Join two streams of tables with different fields and measurements](#join-two-streams-of-tables-with-different-fields-and-measurements) -**Given the following input tables:** -{{< flex >}} -{{% flex-content %}} -##### left -| _time | _field | _value | -|:----- |:------:| ------:| -| 0001 | temp | 80.1 | -| 0002 | temp | 80.2 | -| 0003 | temp | 79.9 | -| 0004 | temp | 80.0 | -{{% /flex-content %}} -{{% flex-content %}} -##### right -| _time | _field | _value | -|:----- |:------:| ------:| -| 0001 | temp | 72.1 | -| 0002 | temp | 72.2 | -| 0003 | temp | 71.9 | -| 0004 | temp | 72.0 | -{{% /flex-content %}} -{{< /flex >}} - -**The following `experimental.join()` function would output:** +### Join two streams of tables ```js +import "array" import "experimental" +left = + array.from( + rows: [ + {_time: 2021-01-01T00:00:00Z, _field: "temp", _value: 80.1}, + {_time: 2021-01-01T01:00:00Z, _field: "temp", _value: 80.6}, + {_time: 2021-01-01T02:00:00Z, _field: "temp", _value: 79.9}, + {_time: 2021-01-01T03:00:00Z, _field: "temp", _value: 80.1}, + ], + ) +right = + array.from( + rows: [ + {_time: 2021-01-01T00:00:00Z, _field: "temp", _value: 75.1}, + {_time: 2021-01-01T01:00:00Z, _field: "temp", _value: 72.6}, + {_time: 2021-01-01T02:00:00Z, _field: "temp", _value: 70.9}, + {_time: 2021-01-01T03:00:00Z, _field: "temp", _value: 71.1}, + ], + ) + experimental.join( left: left, right: right, - fn: (left, right) => ({ left with - lv: left._value, - rv: right._value, - diff: left._value - right._value, - }) + fn: (left, right) => ({left with lv: left._value, rv: right._value, diff: left._value - right._value}), ) ``` -| _time | _field | lv | rv | diff | -|:----- |:------:|:--: |:--: | ----:| -| 0001 | temp | 80.1 | 72.1 | 8.0 | -| 0002 | temp | 80.2 | 72.2 | 8.0 | -| 0003 | temp | 79.9 | 71.9 | 8.0 | -| 0004 | temp | 80.0 | 72.0 | 8.0 | +{{< expand-wrapper >}} +{{% expand "View example output" %}} ---- +#### Output data + +| _field | _time | _value | diff | lv | rv | +| ------- | -------------------- | ------- | ----- | ---- | ---- | +| temp | 2021-01-01T00:00:00Z | 80.1 | 5 | 80.1 | 75.1 | +| temp | 2021-01-01T01:00:00Z | 80.6 | 8 | 80.6 | 72.6 | +| temp | 2021-01-01T02:00:00Z | 79.9 | 9 | 79.9 | 70.9 | +| temp | 2021-01-01T03:00:00Z | 80.1 | 9 | 80.1 | 71.1 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Join two streams of tables with different fields and measurements -###### Join two streams of tables ```js import "experimental" -s1 = from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "foo") +s1 = + from(bucket: "example-bucket") + |> range(start: -1h) + |> filter(fn: (r) => r._measurement == "foo" and r._field == "bar") + |> group(columns: ["_time", "_measurement", "_field", "_value"], mode: "except") -s2 = from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "bar") +s2 = + from(bucket: "example-bucket") + |> range(start: -1h) + |> filter(fn: (r) => r._measurement == "baz" and r._field == "quz") + |> group(columns: ["_time", "_measurement", "_field", "_value"], mode: "except") -experimental.join(left: s1, right: s2, fn: (left, right) => ({left with s1_value: left._value, s2_value: right._value})) +experimental.join( + left: s1, + right: s2, + fn: (left, right) => ({left with bar_value: left._value, quz_value: right._value}), +) ``` -###### Join two streams of tables with different fields and measurements -```js -import "experimental" - -s1 = from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "foo" and r._field == "bar") - |> group(columns: ["_time", "_measurement", "_field", "_value"], mode: "except") - -s2 = from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "baz" and r._field == "quz") - |> group(columns: ["_time", "_measurement", "_field", "_value"], mode: "except") - -experimental.join(left: s1, right: s2, fn: (left, right) => ({left with bar_value: left._value, quz_value: right._value})) -``` diff --git a/content/flux/v0.x/stdlib/experimental/json/_index.md b/content/flux/v0.x/stdlib/experimental/json/_index.md index 09bb2deb2..96a9f3e1f 100644 --- a/content/flux/v0.x/stdlib/experimental/json/_index.md +++ b/content/flux/v0.x/stdlib/experimental/json/_index.md @@ -1,28 +1,44 @@ --- -title: Flux Experimental JSON package -list_title: json package +title: json package description: > - The Flux experimental JSON package provides functions for working with JSON. - Import the `experimental/json` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/json/ - - /influxdb/cloud/reference/flux/stdlib/experimental/json/ + The `json` package provides tools for working with JSON. menu: flux_0_x_ref: - name: json - identifier: json-exp + name: json parent: experimental -weight: 301 -flux/v0.x/tags: [functions, json, package] -introduced: 0.69.0 + identifier: experimental/json +weight: 21 +cascade: + flux/v0.x/tags: [json] + introduced: 0.69.0 --- -Flux experimental JSON functions provide tools for working with JSON. + + +The `json` package provides tools for working with JSON. Import the `experimental/json` package: ```js import "experimental/json" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/json/parse.md b/content/flux/v0.x/stdlib/experimental/json/parse.md index a77f322cd..5f9fd7aaa 100644 --- a/content/flux/v0.x/stdlib/experimental/json/parse.md +++ b/content/flux/v0.x/stdlib/experimental/json/parse.md @@ -1,39 +1,68 @@ --- title: json.parse() function description: > - The `json.parse()` function takes JSON data as bytes and returns a value. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/json/parse/ - - /influxdb/cloud/reference/flux/stdlib/experimental/json/parse/ + `json.parse()` takes JSON data as bytes and returns a value. menu: flux_0_x_ref: name: json.parse - parent: json-exp -weight: 401 + parent: experimental/json + identifier: experimental/json/parse +weight: 201 flux/v0.x/tags: [type-conversions] -introduced: 0.69.0 --- -The `json.parse()` function takes JSON data as bytes and returns a value. -The function can return lists, records, strings, booleans, and float values. -All numeric values are returned as floats. + + +`json.parse()` takes JSON data as bytes and returns a value. + +JSON types are converted to Flux types as follows: + +| JSON type | Flux type | +| --------- | --------- | +| boolean | boolean | +| number | float | +| string | string | +| array | array | +| object | record | + +##### Function type signature ```js -import "experimental/json" - -json.parse( - data: bytes(v: "{\"a\":1,\"b\":2,\"c\":3}") -) +(data: bytes) => A ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### data {data-type="bytes"} -JSON data to parse. +### data +({{< req >}}) +JSON data (as bytes) to parse. + + + ## Examples -##### Parse and use JSON data to restructure a table +- [Parse and use JSON data to restructure tables](#parse-and-use-json-data-to-restructure-tables) +- [Parse JSON and use array functions to manipulate into a table](#parse-json-and-use-array-functions-to-manipulate-into-a-table) + +### Parse and use JSON data to restructure tables + ```js import "experimental/json" @@ -41,7 +70,7 @@ data |> map( fn: (r) => { jsonData = json.parse(data: bytes(v: r._value)) - + return { _time: r._time, _field: r._field, @@ -52,3 +81,123 @@ data }, ) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _field | _value | +| -------------------- | ------- | -------------------- | +| 2021-01-01T00:00:00Z | foo | {"a":1,"b":2,"c":3} | +| 2021-01-01T01:00:00Z | foo | {"a":4,"b":5,"c":6} | +| 2021-01-01T02:00:00Z | foo | {"a":7,"b":8,"c":9} | +| 2021-01-01T00:00:00Z | bar | {"a":10,"b":9,"c":8} | +| 2021-01-01T01:00:00Z | bar | {"a":7,"b":6,"c":5} | +| 2021-01-01T02:00:00Z | bar | {"a":4,"b":3,"c":2} | + + +#### Output data + +| _field | _time | a | b | c | +| ------- | -------------------- | -- | -- | -- | +| foo | 2021-01-01T00:00:00Z | 1 | 2 | 3 | +| foo | 2021-01-01T01:00:00Z | 4 | 5 | 6 | +| foo | 2021-01-01T02:00:00Z | 7 | 8 | 9 | +| bar | 2021-01-01T00:00:00Z | 10 | 9 | 8 | +| bar | 2021-01-01T01:00:00Z | 7 | 6 | 5 | +| bar | 2021-01-01T02:00:00Z | 4 | 3 | 2 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Parse JSON and use array functions to manipulate into a table + +```js +import "experimental/json" +import "experimental/array" + +jsonStr = + bytes( + v: + "{ + \"node\": { + \"items\": [ + { + \"id\": \"15612462\", + \"color\": \"red\", + \"states\": [ + { + \"name\": \"ready\", + \"duration\": 10 + }, + { + \"name\": \"closed\", + \"duration\": 13 + }, + { + \"name\": \"pending\", + \"duration\": 3 + } + ] + }, + { + \"id\": \"15612462\", + \"color\": \"blue\", + \"states\": [ + { + \"name\": \"ready\", + \"duration\": 5 + }, + { + \"name\": \"closed\", + \"duration\": 0 + }, + { + \"name\": \"pending\", + \"duration\": 16 + } + ] + } + ] + } +}", + ) + +data = json.parse(data: jsonStr) + +// Map over all items in the JSON extracting +// the id, color and pending duration of each. +// Construct a table from the final records. +array.from( + rows: + data.node.items + |> array.map( + fn: (x) => { + pendingState = + x.states + |> array.filter(fn: (x) => x.name == "pending") + pendingDur = + if length(arr: pendingState) == 1 then + pendingState[0].duration + else + 0.0 + + return {id: x.id, color: x.color, pendingDuration: pendingDur} + }, + ), +) +``` + +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| id | color | pendingDuration | +| -------- | ------ | ---------------- | +| 15612462 | red | 3 | +| 15612462 | blue | 16 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/kaufmansama.md b/content/flux/v0.x/stdlib/experimental/kaufmansama.md index 1e580ca09..133c034d7 100644 --- a/content/flux/v0.x/stdlib/experimental/kaufmansama.md +++ b/content/flux/v0.x/stdlib/experimental/kaufmansama.md @@ -1,50 +1,112 @@ --- title: experimental.kaufmansAMA() function description: > - The `experimental.kaufmansAMA()` function calculates the Kaufman's Adaptive Moving Average (KAMA) - of input tables using the `_value` column in each table. + `experimental.kaufmansAMA()` calculates the Kaufman's Adaptive Moving Average (KAMA) of input + tables using the `_value` column in each table. menu: flux_0_x_ref: name: experimental.kaufmansAMA parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/kaufmanama/ - - /influxdb/cloud/reference/flux/stdlib/experimental/kaufmanama/ -related: - - /flux/v0.x/stdlib/universe/kaufmanama/ - - /flux/v0.x/stdlib/universe/kaufmanser/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#kaufmans-adaptive-moving-average, InfluxQL KAUFMANS_ADAPTIVE_MOVING_AVERAGE() + identifier: experimental/kaufmansAMA +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.107.0 --- -The `experimental.kaufmansAMA()` function calculates the Kaufman's Adaptive Moving Average (KAMA) -of input tables using the `_value` column in each table. + + +`experimental.kaufmansAMA()` calculates the Kaufman's Adaptive Moving Average (KAMA) of input +tables using the `_value` column in each table. + +Kaufman's Adaptive Moving Average is a trend-following indicator designed to +account for market noise or volatility. + +##### Function type signature ```js -import "experimental" - -experimental.kaufmansAMA(n: 10) +(<-tables: stream[{A with _value: B}], n: int) => stream[{A with _value: float}] where B: Numeric ``` -Kaufman's Adaptive Moving Average is a trend-following indicator designed to account -for market noise or volatility. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} -The period or number of points to use in the calculation. +### n +({{< req >}}) +Period or number of points to use in the calculation. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). ## Examples + +### Calculate the KAMA of input tables + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket"): - |> range(start: -7d) - |> experimental.kaufmansAMA(n: 10) -``` \ No newline at end of file +sampledata.int() + |> experimental.kaufmansAMA(n: 3) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:30Z | 9.72641183951902 | t1 | +| 2021-01-01T00:00:40Z | 10.097401019601417 | t1 | +| 2021-01-01T00:00:50Z | 9.972614968115325 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:30Z | -2.9084287200832466 | t2 | +| 2021-01-01T00:00:40Z | -2.142970089472789 | t2 | +| 2021-01-01T00:00:50Z | -2.0940721758134693 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/last.md b/content/flux/v0.x/stdlib/experimental/last.md index bfb820999..c04b950cf 100644 --- a/content/flux/v0.x/stdlib/experimental/last.md +++ b/content/flux/v0.x/stdlib/experimental/last.md @@ -1,69 +1,101 @@ --- title: experimental.last() function description: > - The `experimental.last()` function returns the last record with a non-null - value in the `_value` column. + `experimental.last()` returns the last record with a non-null value in the `_value` column + for each input table. menu: flux_0_x_ref: name: experimental.last parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/last/ - - /influxdb/cloud/reference/flux/stdlib/experimental/last/ -related: - - /{{< latest "influxdb" >}}/query-data/flux/first-last/ - - /flux/v0.x/stdlib/universe/last - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#last, InfluxQL – LAST() + identifier: experimental/last +weight: 101 flux/v0.x/tags: [transformations, selectors] introduced: 0.112.0 --- -The `experimental.last()` function returns the last record with a non-null -value in the `_value` column. -_`experimental.last()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`experimental.last()` returns the last record with a non-null value in the `_value` column +for each input table. + +`experimental.last()` drops empty tables. + +##### Function type signature ```js -import "experimental" - -experimental.last() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B}] ``` -{{% warn %}} -#### Empty tables -`experimental.last()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -#### Return the last non-null value +### Return the last non-null value in each input table + ```js import "experimental" +import "sampledata" -data +sampledata.int(includeNull: true) |> experimental.last() ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T00:01:00Z | 0.6 | -| 2021-01-01T00:02:00Z | 2.3 | -| 2021-01-01T00:03:00Z | 0.9 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:03:00Z | 0.9 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/max.md b/content/flux/v0.x/stdlib/experimental/max.md index d91b82273..bd54915f1 100644 --- a/content/flux/v0.x/stdlib/experimental/max.md +++ b/content/flux/v0.x/stdlib/experimental/max.md @@ -1,66 +1,101 @@ --- title: experimental.max() function description: > - The `experimental.max()` function returns the record with the highest value in the - `_value` column for each input table. + `experimental.max()` returns the record with the highest value in the `_value` column for each + input table. menu: flux_0_x_ref: name: experimental.max parent: experimental -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/max/ - - /influxdb/cloud/reference/flux/stdlib/experimental/max/ -weight: 302 -related: - - /flux/v0.x/stdlib/universe/max/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#max, InfluxQL – MAX() + identifier: experimental/max +weight: 101 flux/v0.x/tags: [transformations, selectors] introduced: 0.112.0 --- -The `experimental.max()` function returns the record with the highest value in the -`_value` column for each input table. -_`experimental.max()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`experimental.max()` returns the record with the highest value in the `_value` column for each +input table. + +// `experimental.max()` drops empty tables. + +##### Function type signature ```js -import "experimental" - -experimental.max() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B}] ``` -{{% warn %}} -#### Empty tables -`experimental.max()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Return the row with the maximum value in each input table + ```js import "experimental" +import "sampledata" -data +sampledata.int() |> experimental.max() ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T00:01:00Z | 0.6 | -| 2021-01-01T00:02:00Z | 2.3 | -| 2021-01-01T00:03:00Z | 0.9 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:02:00Z | 2.3 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 17 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/mean.md b/content/flux/v0.x/stdlib/experimental/mean.md index febc97c2f..fce0e8fee 100644 --- a/content/flux/v0.x/stdlib/experimental/mean.md +++ b/content/flux/v0.x/stdlib/experimental/mean.md @@ -1,46 +1,101 @@ --- title: experimental.mean() function description: > - The `experimental.mean()` function computes the mean or average of non-null - values in the `_value` column of each input table. + `experimental.mean()` computes the mean or average of non-null values in the `_value` column + of each input table. menu: flux_0_x_ref: name: experimental.mean parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/experimental/mean - - /influxdb/cloud/reference/flux/experimental/mean -related: - - /flux/v0.x/stdlib/universe/mean - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#mean, InfluxQL – MEAN() + identifier: experimental/mean +weight: 101 flux/v0.x/tags: [transformations, aggregates] introduced: 0.107.0 --- -The `experimental.mean()` function computes the mean or average of non-null -values in the `_value` column of each input table. + + +`experimental.mean()` computes the mean or average of non-null values in the `_value` column +of each input table. + Output tables contain a single row the with the calculated mean in the `_value` column. -_`experimental.mean()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + +##### Function type signature ```js -import "experimental" - -experimental.mean() +(<-tables: stream[{A with _value: float}]) => stream[{A with _value: float}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Calculate the average value of input tables + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket") - |> filter(fn: (r) => r._measurement == "example-measurement" and r._field == "example-field") - |> range(start: -1h) +sampledata.float() |> experimental.mean() ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 8.88 | + +| *tag | _value | +| ---- | ----------------- | +| t2 | 9.426666666666668 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/min.md b/content/flux/v0.x/stdlib/experimental/min.md index 14cf72cc1..8f44f7afa 100644 --- a/content/flux/v0.x/stdlib/experimental/min.md +++ b/content/flux/v0.x/stdlib/experimental/min.md @@ -1,66 +1,101 @@ --- title: experimental.min() function description: > - The `experimental.min()` function returns the record with the lowest value in - the `_value` column for each input table. + `experimental.min()` returns the record with the lowest value in the `_value` column for each + input table. menu: flux_0_x_ref: name: experimental.min parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/min/ - - /influxdb/cloud/reference/flux/stdlib/experimental/min/ -related: - - /{{< latest "influxdb" >}}/flux/stdlib/built-in/transformations/selectors/min/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#min, InfluxQL – MIN() + identifier: experimental/min +weight: 101 flux/v0.x/tags: [transformations, selectors] introduced: 0.112.0 --- -The `experimental.min()` function returns the record with the lowest value in -the `_value` column for each input table. -_`experimental.min()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`experimental.min()` returns the record with the lowest value in the `_value` column for each +input table. + +`experimental.min()` drops empty tables. + +##### Function type signature ```js -import "experimental" - -experimental.min() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B}] ``` -{{% warn %}} -#### Empty tables -`experimental.min()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Return the row with the lowest value in each input table + ```js import "experimental" +import "sampledata" -data +sampledata.int() |> experimental.min() ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 1.2 | -| 2021-01-01T00:01:00Z | 0.6 | -| 2021-01-01T00:02:00Z | 2.3 | -| 2021-01-01T00:03:00Z | 0.9 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:01:00Z | 0.6 | -{{% /flex-content %}} -{{< /flex >}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | -3 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/mode.md b/content/flux/v0.x/stdlib/experimental/mode.md index b663d276e..6e1562207 100644 --- a/content/flux/v0.x/stdlib/experimental/mode.md +++ b/content/flux/v0.x/stdlib/experimental/mode.md @@ -1,66 +1,110 @@ --- title: experimental.mode() function description: > - The `experimental.mode()` function computes the mode or value that occurs most - often in the `_value` column in each input table. + `experimental.mode()` computes the mode or value that occurs most often in the `_value` column + in each input table. menu: flux_0_x_ref: name: experimental.mode parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/mode/ - - /influxdb/cloud/reference/flux/stdlib/experimental/mode/ -related: - - /flux/v0.x/stdlib/universe/mode/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#mode, InfluxQL – MODE() + identifier: experimental/mode +weight: 101 flux/v0.x/tags: [transformations, aggregates] -introduced: 0.107.0 --- -The `experimental.mode()` function computes the mode or value that occurs most -often in the `_value` column in each input table. -_`experimental.mode()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`experimental.mode()` computes the mode or value that occurs most often in the `_value` column +in each input table. + +`experimental.mode` only considers non-null values. +If there are multiple modes, it returns all modes in a sorted table. +If there is no mode, it returns _null_. + +#### Supported types +- string +- float +- int +- uint +- bool +- time + +##### Function type signature ```js -import "experimental" - -experimental.mode() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B}] ``` -If there are multiple modes, it returns all of them in a sorted table. -Mode only considers non-null values. -If there is no mode, `experimental.mode()` returns `null`. - -{{% warn %}} -#### Empty tables -`experimental.mode()` drops empty tables. -{{% /warn %}} - -##### Supported data types - -- String -- Float -- Integer -- UInteger -- Boolean -- Time +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -###### Return the mode of windowed data +### Compute the mode of input tables + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket") - |> filter(fn: (r) => r._measurement == "example-measurement" and r._field == "example-field") - |> range(start: -12h) - |> window(every: 10m) +sampledata.int() |> experimental.mode() ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | | + +| *tag | _value | +| ---- | ------- | +| t2 | 19 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/mqtt/_index.md b/content/flux/v0.x/stdlib/experimental/mqtt/_index.md index 3588004fa..e8ee239ca 100644 --- a/content/flux/v0.x/stdlib/experimental/mqtt/_index.md +++ b/content/flux/v0.x/stdlib/experimental/mqtt/_index.md @@ -1,27 +1,44 @@ --- -title: Flux MQTT package -list_title: mqtt package +title: mqtt package description: > - The Flux MQTT package provides functions for working with MQTT protocol. - Import the `experimental/mqtt` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/mqtt/ - - /influxdb/cloud/reference/flux/stdlib/experimental/mqtt/ + The `mqtt` package provides tools for working with Message Queuing Telemetry Transport (MQTT) protocol. menu: flux_0_x_ref: - name: mqtt + name: mqtt parent: experimental -weight: 301 -flux/v0.x/tags: [functions, mqtt, package] -introduced: 0.40.0 + identifier: experimental/mqtt +weight: 21 +cascade: + flux/v0.x/tags: [mqtt] + introduced: 0.40.0 --- -Flux MQTT functions provide tools for working with Message Queuing Telemetry Transport (MQTT) protocol. + + +The `mqtt` package provides tools for working with Message Queuing Telemetry Transport (MQTT) protocol. Import the `experimental/mqtt` package: ```js import "experimental/mqtt" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/mqtt/publish.md b/content/flux/v0.x/stdlib/experimental/mqtt/publish.md index cf3a55fea..1fbd76063 100644 --- a/content/flux/v0.x/stdlib/experimental/mqtt/publish.md +++ b/content/flux/v0.x/stdlib/experimental/mqtt/publish.md @@ -1,73 +1,122 @@ --- title: mqtt.publish() function description: > - The `mqtt.publish()` function outputs data to an MQTT broker using MQTT protocol. + `mqtt.publish()` sends data to an MQTT broker using MQTT protocol. menu: flux_0_x_ref: name: mqtt.publish - parent: mqtt -weight: 401 + parent: experimental/mqtt + identifier: experimental/mqtt/publish +weight: 201 +flux/v0.x/tags: [mqtt] introduced: 0.133.0 --- -The `mqtt.publish()` function outputs data to an MQTT broker using MQTT protocol. + + +`mqtt.publish()` sends data to an MQTT broker using MQTT protocol. + + + +##### Function type signature ```js -import "experimental/mqtt" - -mqtt.publish( - broker: "tcp://localhost:8883", - topic: "example-topic", - message: "Example message", - qos: 0, - retain: false, - clientid: "flux-mqtt", - username: "username", - password: "password", - timeout: 1s, -) +( + broker: string, + message: string, + topic: string, + ?clientid: string, + ?password: string, + ?qos: int, + ?retain: bool, + ?timeout: duration, + ?username: string, +) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### broker {data-type="string"} -The MQTT broker connection string. +### broker +({{< req >}}) +MQTT broker connection string. -### topic {data-type="string"} -The MQTT topic to send data to. -### message {data-type="string"} -The message to send to the MQTT broker. -### qos {data-type="int"} -The [MQTT Quality of Service (QoS)](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901103) level. -Values range from `[0-2]`. +### topic +({{< req >}}) +MQTT topic to send data to. + + + +### message +({{< req >}}) +Message to send to the MQTT broker. + + + +### qos + +MQTT Quality of Service (QoS) level. Values range from `[0-2]`. Default is `0`. -### retain {data-type="bool"} -The [MQTT retain](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901042) flag. -Default is `false`. -### clientid {data-type="string"} -The MQTT client ID. -### username {data-type="string"} -The username to send to the MQTT broker. +### retain + +MQTT retain flag. Default is `false`. + + + +### clientid + +MQTT client ID. + + + +### username + +Username to send to the MQTT broker. + Username is only required if the broker requires authentication. -If you provide a username, you must provide a [password](#password). +If you provide a username, you must provide a password. + +### password + +Password to send to the MQTT broker. -### password {data-type="string"} -The password to send to the MQTT broker. Password is only required if the broker requires authentication. -If you provide a password, you must provide a [username](#username). +If you provide a password, you must provide a username. + +### timeout + +MQTT connection timeout. Default is `1s`. + + -### timeout {data-type="duration"} -The MQTT connection timeout. -Default is `1s`. ## Examples -#### Send a message to an MQTT endpoint +- [Send a message to an MQTT endpoint](#send-a-message-to-an-mqtt-endpoint) +- [Send a message to an MQTT endpoint using input data](#send-a-message-to-an-mqtt-endpoint-using-input-data) + +### Send a message to an MQTT endpoint + ```js import "experimental/mqtt" @@ -80,22 +129,24 @@ mqtt.publish( ) ``` -#### Send a message to an MQTT endpoint using input data + +### Send a message to an MQTT endpoint using input data + ```js import "experimental/mqtt" -import "influxdata/influxdb/sample" +import "sampledata" -sample.data(set: "airSensor") - |> range(start: -20m) - |> last() - |> map(fn: (r) => ({ - r with - sent: mqtt.publish( - broker: "tcp://localhost:8883", - topic: "air-sensors/last/${r.sensorID}", - message: string(v: r._value), - clientid: "sensor-12a4", - ) - }) +sampledata.float() + |> map( + fn: (r) => + ({r with sent: + mqtt.publish( + broker: "tcp://localhost:8883", + topic: "sampledata/${r.id}", + message: string(v: r._value), + clientid: "sensor-12a4", + ), + }), ) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/mqtt/to.md b/content/flux/v0.x/stdlib/experimental/mqtt/to.md index a5b1ce540..38ef6eca6 100644 --- a/content/flux/v0.x/stdlib/experimental/mqtt/to.md +++ b/content/flux/v0.x/stdlib/experimental/mqtt/to.md @@ -1,102 +1,160 @@ --- title: mqtt.to() function description: > - The `mqtt.to()` function outputs data to an MQTT broker using MQTT protocol. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/mqtt/to/ - - /influxdb/cloud/reference/flux/stdlib/experimental/mqtt/to/ + `mqtt.to()` outputs data from a stream of tables to an MQTT broker using MQTT protocol. menu: flux_0_x_ref: name: mqtt.to - parent: mqtt -weight: 401 -flux/v0.x/tags: [outputs] -introduced: 0.40.0 + parent: experimental/mqtt + identifier: experimental/mqtt/to +weight: 201 +flux/v0.x/tags: [mqtt, outputs] --- -The `mqtt.to()` function outputs data to an MQTT broker using MQTT protocol. + + +`mqtt.to()` outputs data from a stream of tables to an MQTT broker using MQTT protocol. + + + +##### Function type signature ```js -import "experimental/mqtt" - -mqtt.to( - broker: "tcp://localhost:8883", - topic: "example-topic", - qos: 0, - clientid: "flux-mqtt", - username: "username", - password: "password", - name: "name-example", - timeout: 1s, - timeColumn: "_time", - tagColumns: ["tag1", "tag2"], - valueColumns: ["_value"], -) +( + <-tables: stream[A], + broker: string, + ?clientid: string, + ?name: string, + ?password: string, + ?qos: int, + ?retain: bool, + ?tagColumns: [string], + ?timeColumn: string, + ?timeout: duration, + ?topic: string, + ?username: string, + ?valueColumns: [string], +) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### broker {data-type="string"} -The MQTT broker connection string. +### broker +({{< req >}}) +MQTT broker connection string. -### topic {data-type="string"} -The MQTT topic to send data to. -### qos {data-type="int"} -The [MQTT Quality of Service (QoS)](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901103) level. -Values range from `[0-2]`. -Default is `0`. -### retain {data-type="bool"} -The [MQTT retain](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901042) flag. -Default is `false`. +### topic -### clientid {data-type="string"} -The MQTT client ID. +MQTT topic to send data to. + + + +### qos + +MQTT Quality of Service (QoS) level. Values range from `[0-2]`. Default is `0`. + + + +### retain + +MQTT retain flag. Default is `false`. + + + +### clientid + +MQTT client ID. + + + +### username + +Username to send to the MQTT broker. -### username {data-type="string"} -The username to send to the MQTT broker. Username is only required if the broker requires authentication. -If you provide a username, you must provide a [password](#password). +If you provide a username, you must provide a password. -### password {data-type="string"} -The password to send to the MQTT broker. +### password + +Password to send to the MQTT broker. Password is only required if the broker requires authentication. -If you provide a password, you must provide a [username](#username). +If you provide a password, you must provide a username. -### name {data-type="string"} -_(Optional)_ The name for the MQTT message. -### timeout {data-type="duration"} -The MQTT connection timeout. -Default is `1s`. -### timeColumn {data-type="string"} -The column to use as time values in the output line protocol. -Default is `"_time"`. +### name -### tagColumns {data-type="array of strings"} -The columns to use as tag sets in the output line protocol. -Default is `[]`. +Name for the MQTT message. -### valueColumns {data-type="array of strings"} -The columns to use as field values in the output line protocol. + + +### timeout + +MQTT connection timeout. Default is `1s`. + + + +### timeColumn + +Column to use as time values in the output line protocol. +Default is `"_time"`. + + + +### tagColumns + +Columns to use as tag sets in the output line protocol. +Default is `[]`. + + + +### valueColumns + +Columns to use as field values in the output line protocol. Default is `["_value"]`. + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + ## Examples -### Send data to an MQTT endpoint +### Send data to an MQTT broker + ```js import "experimental/mqtt" +import "sampledata" -from(bucket: "example-bucket") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "airSensor") +sampledata.float() |> mqtt.to( broker: "tcp://localhost:8883", - topic: "air-sensors", - clientid: "sensor-12a4", - tagColumns: ["sensorID"], + topic: "example-topic", + clientid: r.id, + tagColumns: ["id"], valueColumns: ["_value"], ) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/objectkeys.md b/content/flux/v0.x/stdlib/experimental/objectkeys.md index 878948bb1..b5e6fe52b 100644 --- a/content/flux/v0.x/stdlib/experimental/objectkeys.md +++ b/content/flux/v0.x/stdlib/experimental/objectkeys.md @@ -1,43 +1,64 @@ --- title: experimental.objectKeys() function description: > - The `experimental.objectKeys()` function returns an array of keys in a specified record. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/objectkeys/ - - /influxdb/cloud/reference/flux/stdlib/experimental/objectkeys/ + `experimental.objectKeys()` returns an array of property keys in a specified record. menu: flux_0_x_ref: name: experimental.objectKeys parent: experimental -weight: 302 + identifier: experimental/objectKeys +weight: 101 + introduced: 0.40.0 --- -The `experimental.objectKeys()` function returns an array of keys in a specified record. + + +`experimental.objectKeys()` returns an array of property keys in a specified record. + + + +##### Function type signature ```js -import "experimental" - -experimental.objectKeys( - o: {key1: "value1", key2: "value2"} -) - -// Returns [key1, key2] +(o: A) => [string] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### o {data-type="record"} -The record to return keys from. +### o +({{< req >}}) +Record to return property keys from. + + + ## Examples -### Return all keys in a record +### Return all property keys in a record + ```js import "experimental" user = {firstName: "John", lastName: "Doe", age: 42} -experimental.objectKeys(o: user) -// Returns [firstName, lastName, age] +experimental.objectKeys(o: user)// Returns [firstName, lastName, age] + ``` + diff --git a/content/flux/v0.x/stdlib/experimental/oee/_index.md b/content/flux/v0.x/stdlib/experimental/oee/_index.md index dddf99d66..00cec04f3 100644 --- a/content/flux/v0.x/stdlib/experimental/oee/_index.md +++ b/content/flux/v0.x/stdlib/experimental/oee/_index.md @@ -1,28 +1,44 @@ --- -title: Flux OEE package -list_title: oee package +title: oee package description: > - The Flux OEE package provides functions for calculating overall equipment effectiveness (OEE). - Import the `experimental/oee` package. + The `oee` package provides functions for calculating overall equipment effectiveness (OEE). menu: flux_0_x_ref: - name: oee + name: oee parent: experimental -weight: 301 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/oee/ - - /influxdb/cloud/reference/flux/stdlib/experimental/oee/ -influxdb/v2.0/tags: [functions, oee, package] + identifier: experimental/oee +weight: 21 cascade: + introduced: 0.112.0 --- -The Flux OEE package provides functions for calculating overall equipment effectiveness (OEE). + + +The `oee` package provides functions for calculating overall equipment effectiveness (OEE). Import the `experimental/oee` package: ```js import "experimental/oee" ``` + + + ## Functions -{{< children type="functions" show="pages" >}} \ No newline at end of file + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/oee/apq.md b/content/flux/v0.x/stdlib/experimental/oee/apq.md index 06a24acf7..748ad81e8 100644 --- a/content/flux/v0.x/stdlib/experimental/oee/apq.md +++ b/content/flux/v0.x/stdlib/experimental/oee/apq.md @@ -1,109 +1,101 @@ --- title: oee.APQ() function description: > - The `oee.APQ()` function computes availability, performance, and quality (APQ) - and overall equipment effectiveness (OEE). + `oee.APQ()` computes availability, performance, quality (APQ) and overall equipment + effectiveness (OEE) in producing parts. menu: flux_0_x_ref: name: oee.APQ - parent: oee -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/oee/apq/ - - /influxdb/cloud/reference/flux/stdlib/experimental/oee/apq/ -flux/v0.x/tags: [transformations, aggregates] -weight: 401 + parent: experimental/oee + identifier: experimental/oee/APQ +weight: 201 --- -The `oee.APQ()` function computes availability, performance, quality (APQ) -and overall equipment effectiveness (OEE) in producing parts. + + +`oee.APQ()` computes availability, performance, quality (APQ) and overall equipment +effectiveness (OEE) in producing parts. + Provide the required input schema to ensure this function successfully calculates APQ and OEE. -_`oee.APQ()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ -```js -import "experimental/oee" +### Required input schema +Input tables must include the following columns: -oee.APQ( - runningState: "running", - plannedTime: 8h, - idealCycleTime: 2m, -) -``` - -#### Required input schema -You must include the following columns in your production data input tables: - -- **_stop**: Right time boundary timestamp (typically assigned by - [`range()`](/flux/v0.x/stdlib/universe/range/) - or [`window()`](/flux/v0.x/stdlib/universe/window/)). +- **_stop**: Right time boundary timestamp (typically assigned by `range()` or `window()`). - **_time**: Timestamp of the production event. - **state**: String that represents start or stop events or the production state. - **partCount**: Cumulative total of parts produced. - **badCount**: Cumulative total of parts that do not meet quality standards. -#### Output schema -For each input table, the `oee.APQ` function outputs a table with a single row that includes the following columns: +### Output schema +For each input table, `oee.APQ` outputs a table with a single row that includes the following columns: - **_time**: Timestamp associated with the APQ calculation. - **availability**: Ratio of time production was in a running state. - **oee**: Overall equipment effectiveness. - **performance**: Ratio of production efficiency. - **quality**: Ratio of production quality. -- **runTime**: Total nanoseconds spent in the running state.. +- **runTime**: Total nanoseconds spent in the running state. + +##### Function type signature + +```js +( + <-tables: stream[D], + idealCycleTime: A, + plannedTime: B, + runningState: C, +) => stream[{ + E with + runTime: G, + quality: float, + performance: float, + oee: float, + availability: float, + _time: F, + _stop: F, +}] where C: Equatable, D: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### runningState {data-type="string"} +### runningState ({{< req >}}) State value that represents a running state. -### plannedTime {data-type="duration, int"} + + +### plannedTime ({{< req >}}) Total time that equipment is expected to produce parts. -{{% note %}} -Integer values represent nanoseconds. -{{% /note %}} -### idealCycleTime {data-type="duration, int"} + +### idealCycleTime ({{< req >}}) Ideal minimum time to produce one part. -{{% note %}} -Integer values represent nanoseconds. -{{% /note %}} -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -_See [Required input schema](#required-input-schema)._ -## Examples +### tables -The following example uses [production data](#input-data-productiondata) (`productionData`) -and `oee.APQ()` to calculate the APQ and OEE of an eight hour production window. +Input data. Default is piped-forward data (`<-`). -#### Input data (productionData) -| _start | _stop | _time | state | partCount | badCount | -|:------ |:----- |:----- |:-----: | ---------:| --------:| -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T00:00:00Z | running | 0 | 0 | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T04:03:53Z | stopped | 673 | 5 | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T04:24:53Z | running | 673 | 5 | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T08:00:00Z | running | 1298 | 13 | -#### Query -```js -import "experimental/oee" - -productionData = // ... - -productionData - |> oee.APQ(runningState: "running", plannedTime: 8h, idealCycleTime: 21s) - |> drop(columns: ["_start", "_stop"]) -``` - -#### Output data - -| _time | availability | oee | performance | quality | runTime | -|:----- | ------------: | ---: | -----------: | -------: | -------: | -| 2021-01-01T08:00:01Z | 0.9563 | 0.9370 | 0.9897 | 0.9899 | 27541000000000 | diff --git a/content/flux/v0.x/stdlib/experimental/oee/computeapq.md b/content/flux/v0.x/stdlib/experimental/oee/computeapq.md index 05bc0d93b..e1f65f749 100644 --- a/content/flux/v0.x/stdlib/experimental/oee/computeapq.md +++ b/content/flux/v0.x/stdlib/experimental/oee/computeapq.md @@ -1,39 +1,40 @@ --- title: oee.computeAPQ() function description: > - The `oee.computeAPQ()` function computes availability, performance, and quality (APQ) - and overall equipment effectiveness (OEE) using two separate input streams—production events and parts events. + `oee.computeAPQ()` computes availability, performance, and quality (APQ) + and overall equipment effectiveness (OEE) using two separate input streams: + **production events** and **part events**. menu: flux_0_x_ref: name: oee.computeAPQ - parent: oee -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/oee/computeapq/ - - /influxdb/cloud/reference/flux/stdlib/experimental/oee/computeapq/ -flux/v0.x/tags: [transformations, aggregates] -weight: 401 + parent: experimental/oee + identifier: experimental/oee/computeAPQ +weight: 201 --- -The `oee.computeAPQ()` function computes availability, performance, and quality (APQ) -and overall equipment effectiveness (OEE) using two separate input streams—[production events](#productionevents) -and [part events](#partevents). -_`oee.computeAPQ()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`oee.computeAPQ()` computes availability, performance, and quality (APQ) +and overall equipment effectiveness (OEE) using two separate input streams: +**production events** and **part events**. + +## Output schema +For each input table, `oee.computeAPQ` outputs a table with a single row and +the following columns: - **_time**: Timestamp associated with the APQ calculation. - **availability**: Ratio of time production was in a running state. @@ -42,95 +43,70 @@ and the following columns: - **quality**: Ratio of production quality. - **runTime**: Total nanoseconds spent in the running state. +##### Function type signature + +```js +( + idealCycleTime: A, + partEvents: stream[B], + plannedTime: C, + productionEvents: stream[D], + runningState: E, +) => stream[{ + F with + runTime: H, + quality: float, + performance: float, + oee: float, + availability: float, + _time: G, + _stop: G, +}] where B: Record, D: Record, E: Equatable +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### productionEvents {data-type="stream of tables"} +### productionEvents ({{< req >}}) -Production events stream that contains the production state or start and stop events. -Each row must contain the following columns: +Production events stream that contains the production +state or start and stop events. +Each row must contain the following columns: - **_stop**: Right time boundary timestamp (typically assigned by `range()` or `window()`). - **_time**: Timestamp of the production event. - **state**: String that represents start or stop events or the production state. - Use [`runningState`](#runningstate) to specify which value in the `state` - column represents a running state. +Use [`runningState`](#runningstate) to specify which value in the `state` +column represents a running state. -### partEvents {data-type="stream of tables"} +### partEvents ({{< req >}}) -Part events that contains the running totals of parts produced and parts that do not meet quality standards. -Each row must contain the following columns: +Part events that contains the running totals of parts produced and +parts that do not meet quality standards. +Each row must contain the following columns: - **_stop**: Right time boundary timestamp (typically assigned by - [`range()`](/flux/v0.x/stdlib/universe/range/) - or [`window()`](/flux/v0.x/stdlib/universe/window/)). +`range()` or `window()`). - **_time**: Timestamp of the parts event. - **partCount:** Cumulative total of parts produced. - **badCount** Cumulative total of parts that do not meet quality standards. -### runningState {data-type="string"} +### runningState ({{< req >}}) State value that represents a running state. -### plannedTime {data-type="duration, int"} + + +### plannedTime ({{< req >}}) Total time that equipment is expected to produce parts. -{{% note %}} -Integer values represent nanoseconds. -{{% /note %}} -### idealCycleTime {data-type="duration, int"} + +### idealCycleTime ({{< req >}}) Ideal minimum time to produce one part. -{{% note %}} -Integer values represent nanoseconds. -{{% /note %}} -## Examples -The following example uses two streams of data ([productionData](#productiondata) -and [partsData](#partsdata)) and `oee.APQ()` to calculate the APQ and OEE of an -eight hour production window. - -#### Input data - -##### productionData -| _start | _stop | _time | state | -|:------ |:----- |:----- |:-----: | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T00:00:00Z | running | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T04:03:53Z | stopped | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T04:24:53Z | running | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T08:00:00Z | running | - -##### partsData -| _start | _stop | _time | partCount | badCount | -|:------ |:----- |:----- | ---------:| --------:| -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T00:00:00Z | 0 | 0 | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T04:03:53Z | 673 | 5 | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T04:24:53Z | 673 | 5 | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:01Z | 2021-01-01T08:00:00Z | 1298 | 13 | - -#### Query - -```js -import "experimental/oee" - -productionData = // ... -partsData = // ... - -oee.computeAPQ( - productionEvents: productionData, - partEvents: partsData, - runningState: "running", - plannedTime: 8h, - idealCycleTime: 21s, -) - |> drop(columns: ["_start", "_stop"]) -``` - -#### Output data - -| _time | availability | oee | performance | quality | runTime | -|:----- | ------------: | ---: | -----------: | -------: | -------: | -| 2021-01-01T08:00:01Z | 0.9563 | 0.9370 | 0.9897 | 0.9899 | 27541000000000 | diff --git a/content/flux/v0.x/stdlib/experimental/preview.md b/content/flux/v0.x/stdlib/experimental/preview.md index 7448de5cf..61184be12 100644 --- a/content/flux/v0.x/stdlib/experimental/preview.md +++ b/content/flux/v0.x/stdlib/experimental/preview.md @@ -6,39 +6,72 @@ menu: flux_0_x_ref: name: experimental.preview parent: experimental -weight: 302 + identifier: experimental/preview +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.167.0 --- + + `experimental.preview()` limits the number of rows and tables in the stream. -```js -import "experimental" +Included group keys are not deterministic and depends on the order +that the engine sends them. -data - |> experimental.preview() +##### Function type signature + +```js +(<-tables: stream[A], ?nrows: int, ?ntables: int) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### nrows {data-type="int"} +### nrows + Maximum number of rows per table to return. Default is `5`. -### ntables {data-type="int"} -Maximum number of tables to return. Default is `5`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). + +### ntables + +Maximum number of tables to return. +Default is `5`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples ### Preview data output + ```js import "experimental" import "sampledata" sampledata.int() - |> experimental.preview(nrows: 3) + |> experimental.preview() ``` + diff --git a/content/flux/v0.x/stdlib/experimental/prometheus/_index.md b/content/flux/v0.x/stdlib/experimental/prometheus/_index.md index fd940e870..28f4f01be 100644 --- a/content/flux/v0.x/stdlib/experimental/prometheus/_index.md +++ b/content/flux/v0.x/stdlib/experimental/prometheus/_index.md @@ -1,22 +1,36 @@ --- -title: Flux Prometheus package -list_title: prometheus package +title: prometheus package description: > - The Flux Prometheus package provides functions for working with Prometheus-formatted metrics. - Import the `experimental/prometheus` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/prometheus/ - - /influxdb/cloud/reference/flux/stdlib/experimental/prometheus/ + The `prometheus` package provides tools for working with + [Prometheus-formatted metrics](https://prometheus.io/docs/instrumenting/exposition_formats/). menu: flux_0_x_ref: - name: prometheus + name: prometheus parent: experimental -weight: 301 -flux/v0.x/tags: [functions, prometheus, package] -introduced: 0.50.0 + identifier: experimental/prometheus +weight: 21 +cascade: + flux/v0.x/tags: [prometheus] + introduced: 0.50.0 --- -Flux Prometheus functions provide tools for working with + + +The `prometheus` package provides tools for working with [Prometheus-formatted metrics](https://prometheus.io/docs/instrumenting/exposition_formats/). Import the `experimental/prometheus` package: @@ -24,4 +38,9 @@ Import the `experimental/prometheus` package: import "experimental/prometheus" ``` + + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/prometheus/histogramquantile.md b/content/flux/v0.x/stdlib/experimental/prometheus/histogramquantile.md index 0bdf37c3b..808f4d266 100644 --- a/content/flux/v0.x/stdlib/experimental/prometheus/histogramquantile.md +++ b/content/flux/v0.x/stdlib/experimental/prometheus/histogramquantile.md @@ -1,52 +1,77 @@ --- title: prometheus.histogramQuantile() function description: > - The `prometheus.histogramQuantile()` function calculates quantiles on a set of values - assuming the given histogram data is scraped or read from a Prometheus data source. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/prometheus/histogramquantile/ - - /influxdb/cloud/reference/flux/stdlib/experimental/prometheus/histogramquantile/ + `prometheus.histogramQuantile()` calculates a quantile on a set of Prometheus histogram values. menu: flux_0_x_ref: name: prometheus.histogramQuantile - parent: prometheus -weight: 401 -flux/v0.x/tags: [transformations, prometheus, aggregates] -introduced: 0.51.0 + parent: experimental/prometheus + identifier: experimental/prometheus/histogramQuantile +weight: 201 +flux/v0.x/tags: [transformations, aggregates, prometheus] --- -The `prometheus.histogramQuantile()` function calculates quantiles on a set of values -assuming the given histogram data is scraped or read from a Prometheus data source. -_`prometheus.histogramQuantile()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`prometheus.histogramQuantile()` calculates a quantile on a set of Prometheus histogram values. + +This function supports [Prometheus metric parsing formats](https://docs.influxdata.com/influxdb/latest/reference/prometheus-metrics/) +used by `prometheus.scrape()`, the Telegraf `promtheus` input plugin, and +InfluxDB scrapers available in InfluxDB OSS. + +##### Function type signature ```js -import "experimental/prometheus" - -prometheus.histogramQuantile( - quantile: 0.99, - metricVersion: 2, -) +(<-tables: stream[{B with le: D, _field: C}], quantile: float, ?metricVersion: A) => stream[E] where A: Equatable, C: Equatable, E: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### quantile {data-type="float"} -A value between 0.0 and 1.0 indicating the desired quantile. +### quantile +({{< req >}}) +Quantile to compute. Must be a float value between 0.0 and 1.0. -### metricVersion {data-type="int"} -[Prometheus metric parsing format](/{{< latest "influxdb" >}}/reference/prometheus-metrics/) + + +### metricVersion + +[Prometheus metric parsing format](https://docs.influxdata.com/influxdb/latest/reference/prometheus-metrics/) used to parse queried Prometheus data. Available versions are `1` and `2`. Default is `2`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples +- [Compute the 0.99 quantile of a Prometheus histogram](#compute-the-099-quantile-of-a-prometheus-histogram) +- [Compute the 0.99 quantile of a Prometheus histogram parsed with metric version 1](#compute-the-099-quantile-of-a-prometheus-histogram-parsed-with-metric-version-1) + ### Compute the 0.99 quantile of a Prometheus histogram -{{< keep-url >}} + ```js import "experimental/prometheus" @@ -56,7 +81,9 @@ prometheus.scrape(url: "http://localhost:8086/metrics") |> prometheus.histogramQuantile(quantile: 0.99) ``` + ### Compute the 0.99 quantile of a Prometheus histogram parsed with metric version 1 + ```js import "experimental/prometheus" @@ -65,3 +92,4 @@ from(bucket: "example-bucket") |> filter(fn: (r) => r._measurement == "qc_all_duration_seconds") |> prometheus.histogramQuantile(quantile: 0.99, metricVersion: 1) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/prometheus/scrape.md b/content/flux/v0.x/stdlib/experimental/prometheus/scrape.md index 07b347611..b74b4ac26 100644 --- a/content/flux/v0.x/stdlib/experimental/prometheus/scrape.md +++ b/content/flux/v0.x/stdlib/experimental/prometheus/scrape.md @@ -1,46 +1,62 @@ --- title: prometheus.scrape() function description: > - The `prometheus.scrape()` function retrieves Prometheus-formatted metrics - from a specified URL. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/prometheus/scrape/ - - /influxdb/cloud/reference/flux/stdlib/experimental/prometheus/scrape/ + `prometheus.scrape()` scrapes Prometheus metrics from an HTTP-accessible endpoint and returns + them as a stream of tables. menu: flux_0_x_ref: name: prometheus.scrape - parent: prometheus -weight: 401 -flux/v0.x/tags: [inputs] -related: - - /{{< latest "influxdb" >}}/write-data/no-code/scrape-data/scrapable-endpoints/ -introduced: 0.50.0 + parent: experimental/prometheus + identifier: experimental/prometheus/scrape +weight: 201 +flux/v0.x/tags: [inputs, prometheus] --- -The `prometheus.scrape()` function retrieves [Prometheus-formatted metrics](https://prometheus.io/docs/instrumenting/exposition_formats/) -from a specified URL. -The function groups metrics (including histogram and summary values) into individual tables. + + +`prometheus.scrape()` scrapes Prometheus metrics from an HTTP-accessible endpoint and returns +them as a stream of tables. + + + +##### Function type signature -{{< keep-url >}} ```js -import "experimental/prometheus" - -prometheus.scrape( - url: "http://localhost:8086/metrics" -) +(url: string) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -The URL to scrape Prometheus-formatted metrics from. +### url +({{< req >}}) +URL to scrape Prometheus metrics from. + + + ## Examples -### Scrape Prometheus metrics and write them to InfluxDB +### Scrape InfluxDB OSS internal metrics + ```js import "experimental/prometheus" -prometheus.scrape(url: "https://example-url.com/metrics") - |> to(org: "example-org", bucket: "example-bucket") +prometheus.scrape(url: "http://localhost:8086/metrics") ``` + diff --git a/content/flux/v0.x/stdlib/experimental/quantile.md b/content/flux/v0.x/stdlib/experimental/quantile.md index 780d85a5f..ce30c85dd 100644 --- a/content/flux/v0.x/stdlib/experimental/quantile.md +++ b/content/flux/v0.x/stdlib/experimental/quantile.md @@ -1,102 +1,200 @@ --- title: experimental.quantile() function description: > - The `experimental.quantile()` function outputs non-null records with values in - the `_value` column that fall within the specified quantile or the non-null - record with the value in the `_value` column that represents the specified quantile. + `experimental.quantile()` returns non-null records with values in the `_value` column that + fall within the specified quantile or represent the specified quantile. menu: flux_0_x_ref: name: experimental.quantile parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/quantile/ - - /influxdb/cloud/reference/flux/stdlib/experimental/quantile/ -related: - - /influxdb/v2.0/query-data/flux/percentile-quantile/ - - /flux/v0.x/stdlib/universe/quantile/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#percentile, InfluxQL – PERCENTILE() + identifier: experimental/quantile +weight: 101 flux/v0.x/tags: [transformations, aggregates, selectors] introduced: 0.107.0 --- -The `experimental.quantile()` function outputs non-null records with values in -the `_value` column that fall within the specified quantile or represent the specified quantile. -Which it returns depends on the [method](#method) used. + + +`experimental.quantile()` returns non-null records with values in the `_value` column that +fall within the specified quantile or represent the specified quantile. + The `_value` column must contain float values. -_`experimental.quantile()` behaves like an [aggregate function](/flux/v0.x/function-types/#aggregates) -or a [selector function](/flux/v0.x/function-types/#selectors) depending on -the [`method`](#method) used._ - -```js -import "experimental" - -experimental.quantile( - q: 0.99, - method: "estimate_tdigest", - compression: 1000.0, -) -``` - -When using the `estimate_tdigest` or `exact_mean` methods, the function outputs -non-null records with values that fall within the specified quantile. - -When using the `exact_selector` method, it outputs the non-null record with the -value that represents the specified quantile. - -## Parameters - -### q {data-type="float"} -A value between 0 and 1 thats specifies the quantile. - -### method {data-type="string"} -Computation method. -Default is `estimate_tdigest`. - -**Available options:** - -- [estimate_tdigest](#estimate_tdigest) -- [exact_mean](#exact_mean) -- [exact_selector](#exact_selector) +## Computation methods and behavior +`experimental.quantile()` behaves like an **aggregate function** or a +**selector function** depending on the `method` parameter. +The following computation methods are available: ##### estimate_tdigest An aggregate method that uses a [t-digest data structure](https://github.com/tdunning/t-digest) to compute an accurate quantile estimate on large data sources. +When used, `experimental.quantile()` outputs non-null records with values +that fall within the specified quantile. ##### exact_mean An aggregate method that takes the average of the two points closest to the quantile value. +When used, `experimental.quantile()` outputs non-null records with values +that fall within the specified quantile. ##### exact_selector A selector method that returns the data point for which at least `q` points are less than. +When used, `experimental.quantile()` outputs the non-null record with the +value that represents the specified quantile. + +##### Function type signature + +```js +( + <-tables: stream[{A with _value: float}], + q: float, + ?compression: float, + ?method: string, +) => stream[{A with _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### q +({{< req >}}) +Quantile to compute (`[0 - 1]`). + + + +### method + +Computation method. Default is `estimate_tdigest`. + +**Supported methods**: +- estimate_tdigest +- exact_mean +- exact_selector + +### compression + +Number of centroids to use when compressing the dataset. +Default is `1000.0`. + +A larger number produces a more accurate result at the cost of increased +memory requirements. + +### tables + +Input data. Default is piped-forward data (`<-`). + -### compression {data-type="float"} -Indicates how many centroids to use when compressing the dataset. -A larger number produces a more accurate result at the cost of increased memory requirements. -Defaults to `1000.0`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). ## Examples -###### Quantile as an aggregate +- [Return values in the 50th percentile of each input table](#return-values-in-the-50th-percentile-of-each-input-table) +- [Return a value representing the 50th percentile of each input table](#return-a-value-representing-the-50th-percentile-of-each-input-table) + +### Return values in the 50th percentile of each input table + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "example-measurement" and r._field == "example-field") - |> experimental.quantile(q: 0.99, method: "estimate_tdigest", compression: 1000.0) +sampledata.float() + |> experimental.quantile(q: 0.5) ``` -###### Quantile as a selector +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 9.135 | + +| *tag | _value | +| ---- | ------- | +| t2 | 9.415 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Return a value representing the 50th percentile of each input table + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "example-measurement" and r._field == "example-field") - |> experimental.quantile(q: 0.99, method: "exact_selector") +sampledata.float() + |> experimental.quantile(q: 0.5, method: "exact_selector") ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:20Z | t1 | 7.35 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:10Z | t2 | 4.97 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/query/_index.md b/content/flux/v0.x/stdlib/experimental/query/_index.md index 1135df811..ce6a12e5a 100644 --- a/content/flux/v0.x/stdlib/experimental/query/_index.md +++ b/content/flux/v0.x/stdlib/experimental/query/_index.md @@ -1,44 +1,45 @@ --- -title: Flux Query package -list_title: query package +title: query package description: > - The Flux Query package provides functions meant to simplify common InfluxDB queries. - Import the `experimental/query` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/query/ - - /influxdb/cloud/reference/flux/stdlib/experimental/query/ + The `query` package provides functions meant to simplify common InfluxDB queries. menu: flux_0_x_ref: - name: query + name: query parent: experimental -weight: 301 -flux/v0.x/tags: [package] -introduced: 0.60.0 + identifier: experimental/query +weight: 21 +cascade: + + introduced: 0.60.0 --- -Flux Query functions provide functions meant to simplify common InfluxDB queries. + + +The `query` package provides functions meant to simplify common InfluxDB queries. Import the `experimental/query` package: ```js import "experimental/query" ``` +The primary function in this package is `query.inBucket()`, which uses all +other functions in this package. + + ## Functions + {{< children type="functions" show="pages" >}} - -## inBucket() -The primary function in this package is [`query.inBucket()`](/flux/v0.x/stdlib/experimental/query/inbucket/), -which uses all other functions in this package. - -```js -import "experimental/query" - -query.inBucket( - bucket: "example-bucket", - start: -1h, - stop: now(), - measurement: "example-measurement", - fields: ["exampleField1", "exampleField2"], - predicate: (r) => r.tagA == "foo" and r.tagB != "bar", -) -``` diff --git a/content/flux/v0.x/stdlib/experimental/query/filterfields.md b/content/flux/v0.x/stdlib/experimental/query/filterfields.md index 053773396..64c6849dc 100644 --- a/content/flux/v0.x/stdlib/experimental/query/filterfields.md +++ b/content/flux/v0.x/stdlib/experimental/query/filterfields.md @@ -1,44 +1,67 @@ --- title: query.filterFields() function description: > - The `query.filterFields()` function filters input data by field. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/query/filterfields/ - - /influxdb/cloud/reference/flux/stdlib/experimental/query/filterfields/ + `query.filterFields()` filters input data by field. menu: flux_0_x_ref: name: query.filterFields - parent: query -weight: 401 + parent: experimental/query + identifier: experimental/query/filterFields +weight: 201 flux/v0.x/tags: [transformations, filters] -introduced: 0.60.0 --- -The `query.filterFields()` function filters input data by field. + + +`query.filterFields()` filters input data by field. + + + +##### Function type signature ```js -import "experimental/query" - -query.filterFields( - fields: ["exampleField1", "exampleField2"] -) +(<-table: stream[{B with _field: A}], ?fields: [A]) => stream[{B with _field: A}] where A: Nullable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### fields {data-type="array of strings"} -Fields to filter by. -Must be exact string matches. +### fields + +Fields to filter by. Default is `[]`. + + + +### table + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples +### Query specific fields from InfluxDB + ```js import "experimental/query" query.fromRange(bucket: "telegraf", start: -1h) |> query.filterFields(fields: ["used_percent", "available_percent"]) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/query/filtermeasurement.md b/content/flux/v0.x/stdlib/experimental/query/filtermeasurement.md index 7d5c57be2..9b5db6533 100644 --- a/content/flux/v0.x/stdlib/experimental/query/filtermeasurement.md +++ b/content/flux/v0.x/stdlib/experimental/query/filtermeasurement.md @@ -1,44 +1,67 @@ --- title: query.filterMeasurement() function description: > - The `query.filterMeasurement()` function filters input data by measurement. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/query/filtermeasurement/ - - /influxdb/cloud/reference/flux/stdlib/experimental/query/filtermeasurement/ + `query.filterMeasurement()` filters input data by measurement. menu: flux_0_x_ref: name: query.filterMeasurement - parent: query -weight: 401 + parent: experimental/query + identifier: experimental/query/filterMeasurement +weight: 201 flux/v0.x/tags: [transformations, filters] -introduced: 0.60.0 --- -The `query.filterMeasurement()` function filters input data by measurement. + + +`query.filterMeasurement()` filters input data by measurement. + + + +##### Function type signature ```js -import "experimental/query" - -query.filterMeasurement( - measurement: "example-measurement" -) +(<-table: stream[{B with _measurement: C}], measurement: A) => stream[{B with _measurement: C}] where A: Equatable, C: Equatable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### measurement {data-type="string"} -The name of the measurement to filter by. -Must be an exact string match. +### measurement +({{< req >}}) +InfluxDB measurement name to filter by. + + + +### table + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples +### Query data from InfluxDB in a specific measurement + ```js import "experimental/query" query.fromRange(bucket: "example-bucket", start: -1h) |> query.filterMeasurement(measurement: "example-measurement") ``` + diff --git a/content/flux/v0.x/stdlib/experimental/query/fromrange.md b/content/flux/v0.x/stdlib/experimental/query/fromrange.md index 9710debf8..16b3002b9 100644 --- a/content/flux/v0.x/stdlib/experimental/query/fromrange.md +++ b/content/flux/v0.x/stdlib/experimental/query/fromrange.md @@ -1,58 +1,89 @@ --- title: query.fromRange() function -seotitle: Experimental query.fromRange() function description: > - The `query.fromRange()` function returns all data from a specified bucket within - given time bounds. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/query/fromrange/ - - /influxdb/cloud/reference/flux/stdlib/experimental/query/fromrange/ + `query.fromRange()` returns all data from a specified bucket within given time bounds. menu: flux_0_x_ref: name: query.fromRange - parent: query -weight: 401 -flux/v0.x/tags: [inputs] -introduced: 0.60.0 + parent: experimental/query + identifier: experimental/query/fromRange +weight: 201 +flux/v0.x/tags: [transformations, filters] --- -The `query.fromRange()` function returns all data from a specified bucket within -given time bounds. + + +`query.fromRange()` returns all data from a specified bucket within given time bounds. + + + +##### Function type signature ```js -import "experimental/query" - -query.fromRange( - bucket: "example-bucket", - start: -1h, - stop: now(), -) +( + bucket: string, + start: A, + ?stop: B, +) => stream[{ + C with + _value: D, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, +}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bucket {data-type="string"} -The name of the bucket to query. +### bucket +({{< req >}}) +InfluxDB bucket name. -### start {data-type="duration, time, int"} -The earliest time to include in results. -Results **include** points that match the specified start time. -Use a relative duration, absolute time, or integer (Unix timestamp in seconds). -For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`.. -Durations are relative to `now()`. -### stop {data-type="duration, time, int"} -The latest time to include in results. -Results **exclude** points that match the specified stop time. + +### start +({{< req >}}) +Earliest time to include in results. + +Results include points that match the specified start time. Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -Defaults to `now()`. + +### stop + +Latest time to include in results. Default is `now()`. + +Results exclude points that match the specified stop time. +Use a relative duration, absolute time, or integer (Unix timestamp in seconds).For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. +Durations are relative to `now()`. + ## Examples +### Query data from InfluxDB in a specified time range + ```js import "experimental/query" -query.fromRange(bucket: "example-bucket", start: 2020-01-01T00:00:00Z) +query.fromRange(bucket: "example-bucket", start: -1h) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/query/inbucket.md b/content/flux/v0.x/stdlib/experimental/query/inbucket.md index 6c184de9d..b57f96ded 100644 --- a/content/flux/v0.x/stdlib/experimental/query/inbucket.md +++ b/content/flux/v0.x/stdlib/experimental/query/inbucket.md @@ -1,83 +1,131 @@ --- title: query.inBucket() function -seotitle: Experimental query.inBucket() function description: > - The `query.inBucket()` function queries data from a specified bucket within given - time bounds, filters data by measurement, field, and optional predicate expressions. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/query/inbucket/ - - /influxdb/cloud/reference/flux/stdlib/experimental/query/inbucket/ + `query.inBucket()` queries data from a specified InfluxDB bucket within given time bounds, + filters data by measurement, field, and optional predicate expressions. menu: flux_0_x_ref: name: query.inBucket - parent: query -weight: 401 + parent: experimental/query + identifier: experimental/query/inBucket +weight: 201 flux/v0.x/tags: [inputs] -introduced: 0.60.0 --- -The `query.inBucket()` function queries data from a specified bucket within given -time bounds, filters data by measurement, field, and optional predicate expressions. + + +`query.inBucket()` queries data from a specified InfluxDB bucket within given time bounds, +filters data by measurement, field, and optional predicate expressions. + + + +##### Function type signature ```js -import "experimental/query" - -query.inBucket( - bucket: "example-bucket", - start: -1h, - stop: now(), - measurement: "example-measurement", - fields: ["exampleField1", "exampleField2"], - predicate: (r) => true, -) +( + bucket: string, + measurement: A, + start: B, + ?fields: [string], + ?predicate: ( + r: { + C with + _value: D, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, + ?stop: E, +) => stream[{ + C with + _value: D, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, +}] where A: Equatable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bucket {data-type="string"} -The name of the bucket to query. +### bucket +({{< req >}}) +InfluxDB bucket name. -### start {data-type="duration, time, int"} -The earliest time to include in results. -Results **include** points that match the specified start time. + + +### measurement +({{< req >}}) +InfluxDB measurement name to filter by. + + + +### start +({{< req >}}) +Earliest time to include in results. + +Results include points that match the specified start time. Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -### stop {data-type="duration, time, int"} -The latest time to include in results. -Results **exclude** points that match the specified stop time. -Use a relative duration, absolute time, or integer (Unix timestamp in seconds). -For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. +### stop + +Latest time to include in results. Default is `now()`. + +Results exclude points that match the specified stop time. +Use a relative duration, absolute time, or integer (Unix timestamp in seconds).For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -Defaults to `now()`. -### measurement {data-type="string"} -The name of the measurement to filter by. -Must be an exact string match. +### fields -### fields {data-type="array of strings"} -Fields to filter by. -Must be exact string matches. +Fields to filter by. Default is `[]`. -### predicate {data-type="function"} -A single argument function that evaluates true or false. -Records are passed to the function. -Those that evaluate to `true` are included in the output tables. -Records that evaluate to `null` or `false` are not included in the output tables. + + +### predicate + +Predicate function that evaluates column values and returns `true` or `false`. Default is `(r) => true`. +Records (`r`) are passed to the function. +Those that evaluate to `true` are included in the output tables. +Records that evaluate to null or `false` are not included in the output tables. + + ## Examples -##### Query memory data from host1 +### Query specific fields in a measurement from InfluxDB + ```js import "experimental/query" query.inBucket( - bucket: "telegraf", + bucket: "example-buckt", start: -1h, measurement: "mem", - fields: ["used_percent", "available_percent"], + fields: ["field1", "field2"], predicate: (r) => r.host == "host1", ) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/record/_index.md b/content/flux/v0.x/stdlib/experimental/record/_index.md index ade29ea55..e01e1b44c 100644 --- a/content/flux/v0.x/stdlib/experimental/record/_index.md +++ b/content/flux/v0.x/stdlib/experimental/record/_index.md @@ -1,54 +1,51 @@ --- -title: Flux experimental record package -list_title: record package +title: record package description: > - The Flux experimental `record` package provides tools for working with Flux - [records](/flux/v0.x/data-types/composite/record/). - Import the `experimental/record` package. + The `record` package provides tools for working with Flux records. menu: flux_0_x_ref: - name: record + name: record parent: experimental -weight: 301 -flux/v0.x/tags: [package] -introduced: 0.131.0 + identifier: experimental/record +weight: 21 --- -The Flux experimental `record` package provides tools for working with Flux -[records](/flux/v0.x/data-types/composite/record/). -Import the `experimental/record` package. + + +The `record` package provides tools for working with Flux records. +Import the `experimental/record` package: + +```js import "experimental/record" ``` -{{% warn %}} -#### This package is an interim solution -The `experimental/record` package is an interim solution for -[influxdata/flux#3461](https://github.com/influxdata/flux/issues/3461) -and will either be removed after this issue is resolved or promoted out of -the experimental package if other uses are found. -{{% /warn %}} - -## Constants -The `experimental/record` package provides the following constants: +**Note**: The `experimental/record` package is an interim solution for +[influxdata/flux#3461](https://github.com/influxdata/flux/issues/3461) and +will either be removed after this issue is resolved or promoted out of the +experimental package if other uses are found.## Constants ```js -record.any = {} // polymorphic record with unconstrained property types +record.any ``` -### record.any -Currently, default function parameter values constrain the parameter's type. -`record.any` is a polymorphic record value that can be used as a default -record value when input record property types are not known. +- **record.any** is a polymorphic record value that can be used as a default record value +when input record property types are not known. -```js -addFoo = (r=record.any) => ({ r with foo: "bar" }) -addFoo(r: {}) -// Returns {foo: "bar"} - -addFoo(r: {baz: "quz", int: 123}) -// {baz: "quz", int: 123, foo: "bar"} -``` +## Functions +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/record/get.md b/content/flux/v0.x/stdlib/experimental/record/get.md index e759188c0..f5489f3f6 100644 --- a/content/flux/v0.x/stdlib/experimental/record/get.md +++ b/content/flux/v0.x/stdlib/experimental/record/get.md @@ -1,59 +1,81 @@ --- title: record.get() function -seotitle: Experimental record.get() function description: > - `record.get()` returns a value from a record by key name or a default value if - the key doesn't exist in the record. + `record.get()` returns a value from a record by key name or a default value if the key + doesn’t exist in the record. menu: flux_0_x_ref: name: record.get - parent: record -weight: 401 + parent: experimental/record + identifier: experimental/record/get +weight: 201 + introduced: 0.134.0 --- -`record.get()` returns a value from a record by key name or a default value if -the key doesn't exist in the record. + + +`record.get()` returns a value from a record by key name or a default value if the key +doesn’t exist in the record. + +This is an interim solution for the exists operator’s limited use with +records outside of a stream of tables. For more information, see [influxdata/flux#4073](https://github.com/influxdata/flux/issues/4073). -{{% /note %}} + +##### Function type signature ```js -import "experimental/record" - -record.get( - r: {foo, "bar"}, - key: "foo", - default: "quz", -) +(default: A, key: string, r: B) => A where B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### r {data-type="record"} +### r ({{< req >}}) Record to retrieve the value from. -### key {data-type="string"} -({{< req >}}) -Property key to retrieve -### default {data-type="any data type"} + +### key +({{< req >}}) +Property key to retrieve. + + + +### default ({{< req >}}) Default value to return if the specified key does not exist in the record. + + + ## Examples -#### Dynamically return a value from a record +### Dynamically return a value from a recordd + ```js import "experimental/record" key = "foo" exampleRecord = {foo: 1.0, bar: "hello"} -record.get(r: exampleRecord, key: key, default: "") -// Returns 1.0 -``` \ No newline at end of file +record.get(r: exampleRecord, key: key, default: "")// Returns 1.0 + +``` + diff --git a/content/flux/v0.x/stdlib/experimental/set.md b/content/flux/v0.x/stdlib/experimental/set.md index 300e77b54..2fa15917a 100644 --- a/content/flux/v0.x/stdlib/experimental/set.md +++ b/content/flux/v0.x/stdlib/experimental/set.md @@ -1,75 +1,92 @@ --- title: experimental.set() function description: > - The `experimental.set()` function sets multiple static column values on all records. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/set/ - - /influxdb/cloud/reference/flux/stdlib/experimental/set/ + `experimental.set()` sets multiple static column values on all records. menu: flux_0_x_ref: name: experimental.set parent: experimental -weight: 302 + identifier: experimental/set +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/set/ introduced: 0.40.0 --- -The `experimental.set()` function sets multiple static column values on all records. + + +`experimental.set()` sets multiple static column values on all records. + If a column already exists, the function updates the existing value. If a column does not exist, the function adds it with the specified value. -_Once sufficiently vetted, `experimental.set()` will replace the existing -[`set()` function](/flux/v0.x/stdlib/universe/set/)._ +##### Function type signature ```js -import "experimental" - -experimental.set( - o: {column1: "value1", column2: "value2"} -) +(<-tables: stream[B], o: A) => stream[C] where A: Record, B: Record, C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### o {data-type="record"} -A record that defines the columns and values to set. +### o +({{< req >}}) +Record that defines the columns and values to set. + The key of each key-value pair defines the column name. The value of each key-value pair defines the column value. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples ### Set values for multiple columns -##### Example input table -| _time | _field | _value | -|:----- |:------ | ------:| -| 2019-09-16T12:00:00Z | temp | 71.2 | -| 2019-09-17T12:00:00Z | temp | 68.4 | -| 2019-09-18T12:00:00Z | temp | 70.8 | - -##### Example query ```js import "experimental" data - |> experimental.set(o: - { - _field: "temperature", - unit: "°F", - location: "San Francisco" - } - ) + |> experimental.set(o: {_field: "temperature", unit: "°F", location: "San Francisco"}) ``` -##### Example output table -| _time | _field | _value | unit | location | -|:----- |:------ | ------:|:----:| -------- | -| 2019-09-16T12:00:00Z | temperature | 71.2 | °F | San Francisco | -| 2019-09-17T12:00:00Z | temperature | 68.4 | °F | San Francisco | -| 2019-09-18T12:00:00Z | temperature | 70.8 | °F | San Francisco | +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _field | _value | +| -------------------- | ------- | ------- | +| 2019-09-16T12:00:00Z | temp | 71.2 | +| 2019-09-17T12:00:00Z | temp | 68.4 | +| 2019-09-18T12:00:00Z | temp | 70.8 | + + +#### Output data + +| _time | _field | _value | unit | location | +| -------------------- | ----------- | ------- | ----- | ------------- | +| 2019-09-16T12:00:00Z | temperature | 71.2 | °F | San Francisco | +| 2019-09-17T12:00:00Z | temperature | 68.4 | °F | San Francisco | +| 2019-09-18T12:00:00Z | temperature | 70.8 | °F | San Francisco | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/skew.md b/content/flux/v0.x/stdlib/experimental/skew.md index f0a6836ff..5467eeddf 100644 --- a/content/flux/v0.x/stdlib/experimental/skew.md +++ b/content/flux/v0.x/stdlib/experimental/skew.md @@ -1,44 +1,101 @@ --- title: experimental.skew() function description: > - The `experimental.skew()` function outputs the skew of non-null values in the - `_value` column for each input table. + `experimental.skew()` returns the skew of non-null values in the `_value` column for each + input table as a float. menu: flux_0_x_ref: name: experimental.skew parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/skew/ - - /influxdb/cloud/reference/flux/stdlib/experimental/skew/ -related: - - /flux/v0.x/stdlib/universe/skew/ + identifier: experimental/skew +weight: 101 flux/v0.x/tags: [transformations, aggregates] introduced: 0.107.0 --- -The `experimental.skew()` function outputs the skew of non-null values in the -`_value` column for each input table as a float. -_`experimental.skew()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`experimental.skew()` returns the skew of non-null values in the `_value` column for each +input table as a float. + + + +##### Function type signature ```js -import "experimental" - -experimental.skew() +(<-tables: stream[{A with _value: float}]) => stream[{A with _value: float}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Return the skew of input tables + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "example-measurement" and r._field == "example-field") +sampledata.float() |> experimental.skew() ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| *tag | _value | +| ---- | -------------------- | +| t1 | -0.30467248990094525 | + +| *tag | _value | +| ---- | -------------------- | +| t2 | -0.11050153536874797 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/spread.md b/content/flux/v0.x/stdlib/experimental/spread.md index 57188b1f8..02c1414de 100644 --- a/content/flux/v0.x/stdlib/experimental/spread.md +++ b/content/flux/v0.x/stdlib/experimental/spread.md @@ -1,51 +1,101 @@ --- title: experimental.spread() function description: > - The `experimental.spread()` function outputs the difference between the minimum - and maximum values in the `_value` column for each input table. + `experimental.spread()` returns the difference between the minimum and maximum values in the + `_value` column for each input table. menu: flux_0_x_ref: name: experimental.spread parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/spread/ - - /influxdb/cloud/reference/flux/stdlib/experimental/spread/ -related: - - /flux/v0.x/stdlib/universe/spread/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#spread, InfluxQL – SPREAD() + identifier: experimental/spread +weight: 101 flux/v0.x/tags: [transformations, aggregates] introduced: 0.107.0 --- -The `experimental.spread()` function outputs the difference between the minimum -and maximum values in the `_value` column for each input table. -_`experimental.spread()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`experimental.spread()` returns the difference between the minimum and maximum values in the +`_value` column for each input table. + + + +##### Function type signature ```js -import "experimental" - -experimental.spread() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B}] where B: Numeric ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Return the difference between minimum and maximum values + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "example-measurement" and r._field == "example-field") +sampledata.float() |> experimental.spread() ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 19.71 | + +| *tag | _value | +| ---- | ------- | +| t2 | 23.6 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/stddev.md b/content/flux/v0.x/stdlib/experimental/stddev.md index a10180b90..772d47a5b 100644 --- a/content/flux/v0.x/stdlib/experimental/stddev.md +++ b/content/flux/v0.x/stdlib/experimental/stddev.md @@ -1,60 +1,119 @@ --- title: experimental.stddev() function description: > - The `experimental.stddev()` function computes the standard deviation of non-null - values in the `_value` column for each input table. + `experimental.stddev()` returns the standard deviation of non-null values in the `_value` + column for each input table. menu: flux_0_x_ref: name: experimental.stddev parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/stddev/ - - /influxdb/cloud/reference/flux/stdlib/experimental/stddev/ -related: - - /flux/v0.x/stdlib/universe/stddev/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#stddev, InfluxQL – STDDEV() + identifier: experimental/stddev +weight: 101 flux/v0.x/tags: [transformations, aggregates] introduced: 0.107.0 --- -The `experimental.stddev()` function computes the standard deviation of non-null -values in the `_value` column for each input table. -_`experimental.stddev()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`experimental.stddev()` returns the standard deviation of non-null values in the `_value` +column for each input table. + +## Standard deviation modes +The following modes are avaialable when calculating the standard deviation of data. + +##### sample +Calculate the sample standard deviation where the data is considered to be +part of a larger population. + +##### population +Calculate the population standard deviation where the data is considered a +population of its own. + +##### Function type signature ```js -import "experimental" - -experimental.stddev(mode: "sample") +(<-tables: stream[{A with _value: float}], ?mode: string) => stream[{A with _value: float}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### mode {data-type="string"} -The standard deviation mode or type of standard deviation to calculate. -Defaults to `"sample"`. +### mode -**Available options:** +Standard deviation mode or type of standard deviation to calculate. +Default is `sample`. -- [sample](#sample) -- [population](#population) +**Available options**: +- sample +- population + +### tables + +Input data. Default is piped-forward data (`<-`). -##### sample -Calculate the sample standard deviation where the data is considered to be part of a larger population. -##### population -Calculate the population standard deviation where the data is considered a population of its own. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). ## Examples + +### Return the standard deviation in input tables + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_system") +sampledata.float() |> experimental.stddev() ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| *tag | _value | +| ---- | ----------------- | +| t1 | 7.263244454099008 | + +| *tag | _value | +| ---- | ---------------- | +| t2 | 9.85926704510364 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/subduration.md b/content/flux/v0.x/stdlib/experimental/subduration.md index 965663307..848856ae6 100644 --- a/content/flux/v0.x/stdlib/experimental/subduration.md +++ b/content/flux/v0.x/stdlib/experimental/subduration.md @@ -1,68 +1,107 @@ --- title: experimental.subDuration() function description: > - The `experimental.subDuration()` function subtracts a duration from a time value and - returns a the resulting time value. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/subduration/ - - /influxdb/cloud/reference/flux/stdlib/experimental/subduration/ + `experimental.subDuration()` subtracts a duration from a time value and returns the resulting time value. menu: flux_0_x_ref: name: experimental.subDuration parent: experimental -weight: 302 + identifier: experimental/subDuration +weight: 101 flux/v0.x/tags: [date/time] -related: - - /flux/v0.x/stdlib/experimental/addduration/ -introduced: 0.39.0 deprecated: 0.162.0 --- -{{% warn %}} -This function was promoted to the [`date` package](/flux/v0.x/stdlib/date/sub/) -in **Flux v0.162.0**. This experimental version has been deprecated. -{{% /warn %}} + + +`experimental.subDuration()` subtracts a duration from a time value and returns the resulting time value. + + + +##### Function type signature ```js -import "experimental" - -experimental.subDuration( - d: 12h, - from: now(), -) +(d: duration, from: A, ?location: {zone: string, offset: duration}) => time where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### d {data-type="duration"} +### from +({{< req >}}) +Time to subtract the duration from. + +Use an absolute time or a relative duration. +Durations are relative to `now()`. + +### d +({{< req >}}) Duration to subtract. -### from {data-type="time, duration"} -Time to subtract the [duration](#d) from. -Use an absolute time or a relative duration. -Durations are relative to [`now()`](/flux/v0.x/stdlib/universe/now/). + + +### location + +Location to use for the time value. + + + ## Examples +- [Subtract six hours from a timestamp](#subtract-six-hours-from-a-timestamp) +- [Subtract six hours from a relative duration](#subtract-six-hours-from-a-relative-duration) +- [Subtract two days from one hour ago](#subtract-two-days-from-one-hour-ago) + ### Subtract six hours from a timestamp + ```js import "experimental" -experimental.subDuration(d: 6h, from: 2019-09-16T12:00:00Z) +experimental.subDuration(from: 2019-09-16T12:00:00Z, d: 6h)// Returns 2019-09-16T06:00:00.000000000Z -// Returns 2019-09-16T06:00:00.000000000Z ``` + ### Subtract six hours from a relative duration + ```js import "experimental" option now = () => 2022-01-01T12:00:00Z -experimental.subDuration(d: 6h, from: -3h) +experimental.subDuration(d: 6h, from: -3h)// Returns 2022-01-01T03:00:00.000000000Z -// Returns 2022-01-01T03:00:00.000000000Z ``` + + +### Subtract two days from one hour ago + +A time may be represented as either an explicit timestamp +or as a relative time from the current `now` time. subDuration can +support either type of value. + +```js +import "experimental" + +option now = () => 2021-12-10T16:27:40Z + +experimental.subDuration(from: -1h, d: 2d)// Returns 2021-12-08T15:27:40Z + +``` + diff --git a/content/flux/v0.x/stdlib/experimental/sum.md b/content/flux/v0.x/stdlib/experimental/sum.md index 84364b397..e5211bd5d 100644 --- a/content/flux/v0.x/stdlib/experimental/sum.md +++ b/content/flux/v0.x/stdlib/experimental/sum.md @@ -1,46 +1,99 @@ --- title: experimental.sum() function -description: The `experimental.sum()` function computes the sum of non-null records in a specified column. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/sum - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/sum/ +description: > + `experimental.sum()` returns the sum of non-null values in the `_value` column for each input table. menu: flux_0_x_ref: name: experimental.sum parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/sum/ - - /influxdb/cloud/reference/flux/stdlib/experimental/sum/ -related: - - /flux/v0.x/stdlib/universe/sum/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#sum, InfluxQL – SUM() + identifier: experimental/sum +weight: 101 flux/v0.x/tags: [transformations, aggregates] introduced: 0.107.0 --- -The `experimental.sum()` function computes the sum of non-null values in the `_value` -column for each input table. -_`experimental.sum()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`experimental.sum()` returns the sum of non-null values in the `_value` column for each input table. + + + +##### Function type signature ```js -import "experimental" - -experimental.sum() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B}] where B: Numeric ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Return the sum of each input table + ```js import "experimental" +import "sampledata" -from(bucket: "example-bucket") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "example-measurement" and r._field == "example-field") +sampledata.int() |> experimental.sum() ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 51 | + +| *tag | _value | +| ---- | ------- | +| t2 | 53 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/table/_index.md b/content/flux/v0.x/stdlib/experimental/table/_index.md index a4429835e..cd07f8bce 100644 --- a/content/flux/v0.x/stdlib/experimental/table/_index.md +++ b/content/flux/v0.x/stdlib/experimental/table/_index.md @@ -1,25 +1,44 @@ --- -title: Flux Experimental table package -list_title: table package +title: table package description: > - The Flux experimental table package provides tools working with Flux tables. - Import the `experimental/table` package. + The `table` package provides tools working with Flux tables. menu: flux_0_x_ref: - name: table - identifier: table-exp + name: table parent: experimental -weight: 301 -flux/v0.x/tags: [functions, table, package] + identifier: experimental/table +weight: 21 cascade: + introduced: 0.115.0 --- -The Flux experimental table package provides tools working with Flux tables. + + +The `table` package provides tools working with Flux tables. Import the `experimental/table` package: ```js import "experimental/table" ``` + + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/table/fill.md b/content/flux/v0.x/stdlib/experimental/table/fill.md index f887c9af9..733a2a929 100644 --- a/content/flux/v0.x/stdlib/experimental/table/fill.md +++ b/content/flux/v0.x/stdlib/experimental/table/fill.md @@ -1,91 +1,102 @@ --- title: table.fill() function description: > - The `table.fill()` function adds a single row to empty tables in a stream of tables. - Columns in the group key are filled with the column value defined in the group key. - Columns not in the group key are filled with a null value. + `table.fill()` adds a single row to empty tables in a stream of tables. menu: flux_0_x_ref: name: table.fill - parent: table-exp -weight: 401 -flux/v0.x/tags: [transformations, fill] + parent: experimental/table + identifier: experimental/table/fill +weight: 201 +flux/v0.x/tags: [transformations, table] --- -The `table.fill()` function adds a single row to empty tables in a stream of tables. + + +`table.fill()` adds a single row to empty tables in a stream of tables. + Columns that are in the group key are filled with the column value defined in the group key. Columns not in the group key are filled with a null value. -```js -import "experimental/table" +##### Function type signature -table.fill() +```js +(<-tables: stream[A]) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -##### Query +### Fill empty tables + ```js import "experimental/table" +import "sampledata" + +data = + sampledata.int() + |> filter(fn: (r) => r.tag != "t2", onEmpty: "keep") data |> table.fill() ``` -{{< flex >}} -{{% flex-content %}} -##### Input data +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -

Group key = [host: "host1", _field: "f1"]

+#### Input data -| host | _field | time | _value | -| :---- | :----- | :--- | -----: | -| host1 | f1 | 0001 | 2.8 | -| host1 | f1 | 0002 | 3.2 | -| host1 | f1 | 0003 | 3.3 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -

Group key = [host: "host2", _field: "f1"]

+| _time | _value | *tag | +| ------ | ------- | ---- | -| host | _field | time | _value | -| :--- | :----- | :--- | -----: | -

Group key = [host: "host3", _field: "f1"]

+#### Output data -| host | _field | time | _value | -| :---- | :----- | :--- | -----: | -| host3 | f1 | 0001 | 1.4 | -| host3 | f1 | 0002 | 1.5 | -| host3 | f1 | 0003 | 2.7 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -

Group key = [host: "host1", _field: "f1"]

+| _time | _value | *tag | +| ------ | ------- | ---- | +| | | t2 | -| host | _field | time | _value | -| :---- | :----- | :--- | -----: | -| host1 | f1 | 0001 | 2.8 | -| host1 | f1 | 0002 | 3.2 | -| host1 | f1 | 0003 | 3.3 | - -

Group key = [host: "host2", _field: "f1"]

- -| host | _field | time | _value | -| :---- | :----- | :--- | -----: | -| host2 | f1 | | | - -

Group key = [host: "host3", _field: "f1"]

- -| host | _field | time | _value | -| :---- | :----- | :--- | -----: | -| host3 | f1 | 0001 | 1.4 | -| host3 | f1 | 0002 | 1.5 | -| host3 | f1 | 0003 | 2.7 | -{{% /flex-content %}} -{{< /flex >}} +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/to.md b/content/flux/v0.x/stdlib/experimental/to.md index 0ef74565a..570ca8c29 100644 --- a/content/flux/v0.x/stdlib/experimental/to.md +++ b/content/flux/v0.x/stdlib/experimental/to.md @@ -1,124 +1,127 @@ --- title: experimental.to() function description: > - The `experimental.to()` function writes data to an InfluxDB v2.0 bucket. - The function structures data differently than the built-in `to()` function. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/to/ - - /influxdb/cloud/reference/flux/stdlib/experimental/to/ + `experimental.to()` writes _pivoted_ data to an InfluxDB 2.x or InfluxDB Cloud bucket. menu: flux_0_x_ref: name: experimental.to parent: experimental -weight: 302 + identifier: experimental/to +weight: 101 flux/v0.x/tags: [outputs] -related: - - /flux/v0.x/stdlib/influxdata/influxdb/to/ introduced: 0.40.0 --- -The `experimental.to()` function writes data to an InfluxDB v2.0 bucket, but in -a [different structure](#expected-data-structure) than the -[`to()` function](/flux/v0.x/stdlib/influxdata/influxdb/to/). + + +`experimental.to()` writes _pivoted_ data to an InfluxDB 2.x or InfluxDB Cloud bucket. + +#### Requirements and behavior +- Requires both a `_time` and a `_measurement` column. +- All columns in the group key (other than `_measurement`) are written as tags + with the column name as the tag key and the column value as the tag value. +- All columns **not** in the group key (other than `_time`) are written as + fields with the column name as the field key and the column value as the field value. + +If using the `from()` to query data from InfluxDB, use pivot() to transform +data into the structure `experimental.to()` expects. + +##### Function type signature ```js -import "experimental" - -experimental.to( - bucket: "my-bucket", - org: "my-org", - host: "http://localhost:8086", - token: "mY5uPeRs3Cre7tok3N", -) - -// OR - -experimental.to( - bucketID: "1234567890", - orgID: "0987654321", - host: "http://localhost:8086", - token: "mY5uPeRs3Cre7tok3N", -) +( + <-tables: stream[A], + ?bucket: string, + ?bucketID: string, + ?host: string, + ?org: string, + ?orgID: string, + ?token: string, +) => stream[A] where A: Record ``` -### Expected data structure - -#### Data structure expected by built-in to() -The built-in `to()` function requires `_time`, `_measurement`, `_field`, and `_value` columns. -The `_field` column stores the **field key** and the `_value` column stores the **field value**. - -| _time | _measurement | _field | _value | -| ----- | ------------ | ------ | ------ | -| timestamp | measurement-name | field key | field value | - -#### Data structure expected by experimental to() -`experimental.to()` requires both a `_time` and a `_measurement` column. -All columns _in the group key_ (other than `_measurement`) are written as tags -with the column name as the **tag key** and the column value as the **tag value**. - -All columns _**not** in the group key_ (other than `_time`) are written as fields -with the column name as the **field key** and the column value as the **field value**. - -| _time | _measurement | field_key | -| ----- | ------------ | --------- | -| timestamp | measurement-name | field value | - -If using the built-in `from()` function, use [`pivot()`](/flux/v0.x/stdlib/universe/pivot/) -to transform data into the structure `experimetnal.to()` expects. -_[See the example below](#use-pivot-to-shape-data-for-experimentalto)._ +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### bucket {data-type="string"} -The bucket to write data to. -`bucket` and `bucketID` are mutually exclusive. +### bucket -### bucketID {data-type="string"} -The ID of the bucket to write data to. -`bucketID` and `bucket` are mutually exclusive. +Name of the bucket to write to. +_`bucket` and `bucketID` are mutually exclusive_. -### org {data-type="string"} -The organization name of the specified [`bucket`](#bucket). -Only required when writing to a different organization or a remote host. -`org` and `orgID` are mutually exclusive. -### orgID {data-type="string"} -The organization ID of the specified [`bucket`](#bucket). -Only required when writing to a different organization or a remote host. -`orgID` and `org` are mutually exclusive. -{{% warn %}} -`experimental.to()` cannot write to from one InfluxDB Cloud organization to another. -{{% /warn %}} +### bucketID -### host {data-type="string"} -[InfluxDB URL](/{{< latest "influxdb" >}}/reference/urls/) or -[InfluxDB Cloud region](/influxdb/cloud/reference/regions) URL to write to. +String-encoded bucket ID to to write to. +_`bucket` and `bucketID` are mutually exclusive_. -{{% warn %}} -_`host` is required when writing to a remote InfluxDB instance. -If specified, [`token`](#token) is also required._ -{{% /warn %}} -### token {data-type="string"} -[InfluxDB API token](/{{< latest "influxdb" >}}/security/tokens). -{{% warn %}} -_`token` is required when writing to another organization or when writing to a remote InfluxDB [`host`](#host)._ -{{% /warn %}} +### host + +URL of the InfluxDB instance to write to. + +See [InfluxDB Cloud regions](https://docs.influxdata.com/influxdb/cloud/reference/regions/) +or [InfluxDB OSS URLs](https://docs.influxdata.com/influxdb/latest/reference/urls/). +`host` is required when writing to a remote InfluxDB instance. +If specified, `token` is also required. + +### org + +Organization name. +_`org` and `orgID` are mutually exclusive_. + + + +### orgID + +String-encoded organization ID to query. +_`org` and `orgID` are mutually exclusive_. + + + +### token + +InfluxDB API token. + +**InfluxDB 1.x or Enterprise**: If authentication is disabled, provide an +empty string (`""`). If authentication is enabled, provide your InfluxDB +username and password using the `:` syntax. +`token` is required when writing to another organization or when `host` +is specified. + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). ## Examples -##### Use pivot() to shape data for experimental.to() +### Pivot and write data to InfluxDB + ```js import "experimental" from(bucket: "example-bucket") |> range(start: -1h) |> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value") - |> experimental.to(bucket: "bucket-name", org: "org-name") + |> experimental.to(bucket: "example-target-bucket") ``` + diff --git a/content/flux/v0.x/stdlib/experimental/unique.md b/content/flux/v0.x/stdlib/experimental/unique.md index 10710b44f..16c4d430f 100644 --- a/content/flux/v0.x/stdlib/experimental/unique.md +++ b/content/flux/v0.x/stdlib/experimental/unique.md @@ -1,78 +1,112 @@ --- title: experimental.unique() function description: > - The `experimental.unique()` function returns all records containing unique - values in the `_value` column. + `experimental.unique()` returns all records containing unique values in the `_value` column. menu: flux_0_x_ref: name: experimental.unique parent: experimental -weight: 302 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/unique/ - - /influxdb/cloud/reference/flux/stdlib/experimental/unique/ -related: - - /flux/v0.x/stdlib/universe/unique/ + identifier: experimental/unique +weight: 101 flux/v0.x/tags: [transformations, selectors] introduced: 0.112.0 --- -The `experimental.unique()` function returns all records containing unique -values in the `_value` column. + + +`experimental.unique()` returns all records containing unique values in the `_value` column. + `null` is considered a unique value. -_`experimental.unique()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + +#### Function behavior +- Outputs a single table for each input table. +- Outputs a single record for each unique value in an input table. +- Leaves group keys, columns, and values unmodified. +- Drops emtpy tables. + +##### Function type signature ```js -import "experimental" - -experimental.unique() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B}] ``` -#### Output schema -`experimental.unique()` outputs a single table for each input table and does -the following: - -- Outputs a single record for each unique value. -- Leaves group keys, columns, and values **unmodified**. - -{{% warn %}} -#### Empty tables -`experimental.unique()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Return rows with unique values in each input table + ```js import "experimental" +import "sampledata" -data +sampledata.int(includeNull: true) |> experimental.unique() ``` -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | _field | _value | -|:----- |:------ | ------:| -| 2021-01-01T00:00:00Z | ver | v1 | -| 2021-01-01T00:01:00Z | ver | v1 | -| 2021-01-01T00:02:00Z | ver | v2 | -| 2021-01-01T00:03:00Z | ver | | -| 2021-01-01T00:04:00Z | ver | v3 | -| 2021-01-01T00:05:00Z | ver | v3 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | _field | _value | -|:----- |:------ | ------:| -| 2021-01-01T00:00:00Z | ver | v1 | -| 2021-01-01T00:02:00Z | ver | v2 | -| 2021-01-01T00:03:00Z | ver | | -| 2021-01-01T00:04:00Z | ver | v3 | -{{% /flex-content %}} -{{< /flex >}} \ No newline at end of file +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/universe/_index.md b/content/flux/v0.x/stdlib/experimental/universe/_index.md new file mode 100644 index 000000000..ad55c053b --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/universe/_index.md @@ -0,0 +1,46 @@ +--- +title: universe package +description: > + The `universe` package provides equivalent functions to the standard universe package + but with more precise type signatures. +menu: + flux_0_x_ref: + name: universe + parent: experimental + identifier: experimental/universe +weight: 21 +cascade: + + introduced: v0.166.0 +--- + + + +The `universe` package provides equivalent functions to the standard universe package +but with more precise type signatures. +Import the `experimental/universe` package: + +```js +import "experimental/universe" +``` + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/universe/columns.md b/content/flux/v0.x/stdlib/experimental/universe/columns.md new file mode 100644 index 000000000..23eadbf85 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/universe/columns.md @@ -0,0 +1,76 @@ +--- +title: columns() function +description: > + `columns()` returns the column labels in each input table. +menu: + flux_0_x_ref: + name: columns + parent: experimental/universe + identifier: experimental/universe/columns +weight: 201 +flux/v0.x/tags: [transformations] +introduced: v0.166.0 +--- + + + +`columns()` returns the column labels in each input table. + +**Note:** `universe.columns()` is an experimental function with a more precise type signature. + +For each input table, `columns` outputs a table with the same group key +columns and a new column containing the column labels in the input table. +Each row in an output table contains the group key value and the label of one + column of the input table. +Each output table has the same number of rows as the number of columns of the input table. + +##### Function type signature + +```js +(<-tables: stream[B], ?column: A = "_value") => stream[{A: string}] where A: Label, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### column + +Name of the output column to store column labels in. +Default is "_value". + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +### List all columns per input table + +```js +import "experimental/universe" +import "sampledata" + +sampledata.string() + |> universe.columns(column: "labels") +``` + diff --git a/content/flux/v0.x/stdlib/experimental/universe/fill.md b/content/flux/v0.x/stdlib/experimental/universe/fill.md new file mode 100644 index 000000000..93de072f2 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/universe/fill.md @@ -0,0 +1,191 @@ +--- +title: fill() function +description: > + `fill()` replaces all null values in input tables with a non-null value. +menu: + flux_0_x_ref: + name: fill + parent: experimental/universe + identifier: experimental/universe/fill +weight: 201 +flux/v0.x/tags: [transformations] +introduced: v0.166.0 +--- + + + +`fill()` replaces all null values in input tables with a non-null value. + +**Note:** `universe.fill()` is an experimental function with a more precise type signature. + +Output tables are the same as the input tables with all null values replaced +in the specified column. + +##### Function type signature + +```js +(<-tables: stream[{C with A: B}], ?column: A = "_value", ?usePrevious: bool, ?value: B) => stream[{C with A: B}] where A: Label, C: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### column + +Column to replace null values in. Default is `_value`. + + + +### value + +Constant value to replace null values with. + +Value type must match the type of the specified column. + +### usePrevious + +Replace null values with the previous non-null value. +Default is `false`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +- [Fill null values with a specified non-null value](#fill-null-values-with-a-specified-non-null-value) +- [Fill null values with the previous non-null value](#fill-null-values-with-the-previous-non-null-value) + +### Fill null values with a specified non-null value + +```js +import "experimental/universe" +import "sampledata" + +sampledata.int(includeNull: true) + |> universe.fill(value: 0) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 0 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 0 | t1 | +| 2021-01-01T00:00:40Z | 0 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 0 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Fill null values with the previous non-null value + +```js +import "experimental/universe" +import "sampledata" + +sampledata.int(includeNull: true) + |> universe.fill(usePrevious: true) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | -2 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 7 | t1 | +| 2021-01-01T00:00:40Z | 7 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 19 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/universe/mean.md b/content/flux/v0.x/stdlib/experimental/universe/mean.md new file mode 100644 index 000000000..3c397294b --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/universe/mean.md @@ -0,0 +1,107 @@ +--- +title: mean() function +description: > + `mean()` returns the average of non-null values in a specified column from each + input table. +menu: + flux_0_x_ref: + name: mean + parent: experimental/universe + identifier: experimental/universe/mean +weight: 201 +flux/v0.x/tags: [transformations, aggregates] +introduced: v0.166.0 +--- + + + +`mean()` returns the average of non-null values in a specified column from each +input table. + +**Note:** `universe.mean()` is an experimental function with a more precise type signature. + +##### Function type signature + +```js +(<-tables: stream[{B with A: C}], ?column: A = "_value") => stream[{A: C}] where A: Label, B: Record, C: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### column + +Column to use to compute means. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +### Return the average of values in each input table + +```js +import "experimental/universe" +import "sampledata" + +sampledata.int() + |> universe.mean() +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 8.5 | + +| *tag | _value | +| ---- | ----------------- | +| t2 | 8.833333333333334 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/usage/_index.md b/content/flux/v0.x/stdlib/experimental/usage/_index.md index 0b5451fc4..118a1c0a0 100644 --- a/content/flux/v0.x/stdlib/experimental/usage/_index.md +++ b/content/flux/v0.x/stdlib/experimental/usage/_index.md @@ -1,33 +1,46 @@ --- -title: Flux Experimental usage package -list_title: usage package +title: usage package description: > - The Flux experimental usage package provides tools for collecting usage and usage - limit data from InfluxDB Cloud. - Import the `experimental/usage` package. + The `usage` package provides tools for collecting usage and usage limit data from + **InfluxDB Cloud**. menu: flux_0_x_ref: - name: usage - identifier: usage-exp + name: usage parent: experimental -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/usage/ - - /influxdb/cloud/reference/flux/stdlib/experimental/usage/ -weight: 301 -flux/v0.x/tags: [functions, usage, package] + identifier: experimental/usage +weight: 21 cascade: + introduced: 0.114.0 - related: - - https://www.influxdata.com/influxdb-templates/influxdb-cloud-usage-dashboard/, InfluxDB Cloud Usage – Community Template --- -The Flux experimental usage package provides tools for collecting usage and usage -limit data from **InfluxDB Cloud**. + + +The `usage` package provides tools for collecting usage and usage limit data from +**InfluxDB Cloud**. Import the `experimental/usage` package: ```js import "experimental/usage" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/usage/from.md b/content/flux/v0.x/stdlib/experimental/usage/from.md index d01b38a87..a8738695f 100644 --- a/content/flux/v0.x/stdlib/experimental/usage/from.md +++ b/content/flux/v0.x/stdlib/experimental/usage/from.md @@ -1,96 +1,112 @@ --- title: usage.from() function description: > - The `usage.from()` function returns usage data from an **InfluxDB Cloud** organization. + `usage.from()` returns usage data from an **InfluxDB Cloud** organization. menu: flux_0_x_ref: name: usage.from - parent: usage-exp -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/usage/from/ - - /influxdb/cloud/reference/flux/stdlib/experimental/usage/from/ -weight: 401 + parent: experimental/usage + identifier: experimental/usage/from +weight: 201 flux/v0.x/tags: [inputs] -related: - - /influxdb/cloud/account-management/data-usage/ - - /influxdb/cloud/account-management/limits/ --- + + `usage.from()` returns usage data from an **InfluxDB Cloud** organization. -Use `usage.from()` to monitor your InfluxDB Cloud organization's usage and identify -anomalies or rate limiting. + +### Output data schema +- **http_request** measurement + - **req_bytes** field + - **resp_bytes** field + - **org_id** tag + - **endpoint** tag + - **status** tag +- **query_count** measurement + - **req_bytes** field + - **endpoint** tag + - **orgID** tag + - **status** tag +- **storage_usage_bucket_bytes** measurement + - **gauge** field + - **bucket_id** tag + - **org_id** tag + +##### Function type signature ```js -import "experimental/usage" - -usage.from( - start: -30d, - stop: now(), - host: "", - orgID: "", - token: "", - raw: false, -) +( + start: A, + stop: B, + ?host: string, + ?orgID: string, + ?raw: C, + ?token: string, +) => stream[D] where D: Record ``` -### Usage data schema -InfluxDB Cloud usage data is reported and reset every five minutes. - -- **storage_usage_bucket_bytes** _(measurement)_ - - **gauge** _(field)_: Number of bytes on disk associated with a bucket. - - **bucket_id** _(tag)_: Bucket ID. - - **org_id** _(tag)_: Organization ID. -- **http_request** _(measurement)_ - - **req_bytes** _(field)_: Total number of bytes in HTTP request bodies - per endpoint and status code. - - **resp_bytes** _(field)_: Total number of bytes in HTTP response bodies - per endpoint and status code. - - **org_id** _(tag)_: Organization ID. - - **endpoint** _(tag)_: InfluxDB Cloud API endpoint. - - **status** _(tag)_: HTTP status code. -- **query_count** _(measurement)_ - - **req_bytes** _(field)_: Number of queries executed. - - **endpoint** _(tag)_: InfluxDB Cloud API endpoint. - - **orgID** _(tag)_: Organization ID. - - **status** _(tag)_: HTTP status code. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### start {data-type="time, duration"} +### start ({{< req >}}) Earliest time to include in results. -### stop {data-type="time, duration"} + + +### stop ({{< req >}}) Latest time to include in results. -### host {data-type="string"} -[InfluxDB Cloud region URL](/influxdb/cloud/reference/regions/). -Default is `""`. -_If an empty string, the function uses the host that the query is executed from._ -### orgID {data-type="string"} -InfluxDB Cloud organization ID. -Default is `""`. -_If an empty string, the function uses the ID of the organization that executes the query._ -### token {data-type="string"} -InfluxDB Cloud [API token](/influxdb/cloud/security/tokens/). -Default is `""`. -_If an empty string, the function uses an API token associated with the user that executes the query._ -**The API token must be an [All-Access token](/influxdb/cloud/security/tokens/#all-access-token)**. +### host + +[InfluxDB Cloud region URL](https://docs.influxdata.com/influxdb/cloud/reference/regions/). +Default is `""`. + +_(Required if executed outside of your InfluxDB Cloud organization or region)_. + +### orgID + +InfluxDB Cloud organization ID. Default is `""`. + +_(Required if executed outside of your InfluxDB Cloud organization or region)_. + +### token + +InfluxDB Cloud [API token](https://docs.influxdata.com/influxdb/cloud/security/tokens/). +Default is `""`. + +_(Required if executed outside of your InfluxDB Cloud organization or region)_. + +### raw -### raw {data-type="bool"} Return raw, high resolution usage data instead of downsampled usage data. Default is `false`. `usage.from()` can query the following time ranges: - | Data resolution | Maximum time range | | :-------------- | -----------------: | | raw | 1 hour | | downsampled | 30 days | + ## Examples - [Query downsampled usage data for your InfluxDB Cloud organization](#query-downsampled-usage-data-for-your-influxdb-cloud-organization) @@ -102,20 +118,31 @@ Default is `false`. - [Compare usage metrics to organization usage limits](#compare-usage-metrics-to-organization-usage-limits) ### Query downsampled usage data for your InfluxDB Cloud organization + ```js import "experimental/usage" +import "influxdata/influxdb/secrets" + +token = secrets.get(key: "INFLUX_TOKEN") usage.from(start: -30d, stop: now()) ``` + ### Query raw usage data for your InfluxDB Cloud organization + ```js import "experimental/usage" +import "influxdata/influxdb/secrets" + +token = secrets.get(key: "INFLUX_TOKEN") usage.from(start: -1h, stop: now(), raw: true) ``` + ### Query downsampled usage data for a different InfluxDB Cloud organization + ```js import "experimental/usage" import "influxdata/influxdb/secrets" @@ -125,13 +152,15 @@ token = secrets.get(key: "INFLUX_TOKEN") usage.from( start: -30d, stop: now(), - host: "https://cloud2.influxdata.com", + host: "https://us-west-2-1.aws.cloud2.influxdata.com", orgID: "x000X0x0xx0X00x0", token: token, ) ``` + ### Query number of bytes in requests to the /api/v2/write endpoint + ```js import "experimental/usage" @@ -144,7 +173,9 @@ usage.from(start: -30d, stop: now()) |> group() ``` + ### Query number of bytes returned from the /api/v2/query endpoint + ```js import "experimental/usage" @@ -157,13 +188,15 @@ usage.from(start: -30d, stop: now()) |> group() ``` + ### Query the query count for InfluxDB Cloud query endpoints + The following query returns query counts for the following query endpoints: - **/api/v2/query**: Flux queries - **/query**: InfluxQL queries -```javascript +```js import "experimental/usage" usage.from(start: -30d, stop: now()) @@ -171,7 +204,9 @@ usage.from(start: -30d, stop: now()) |> sort(columns: ["_time"]) ``` + ### Compare usage metrics to organization usage limits + The following query compares the amount of data written to and queried from your InfluxDB Cloud organization to your organization's rate limits. It appends a `limitReached` column to each row that indicates if your rate @@ -182,27 +217,31 @@ import "experimental/usage" limits = usage.limits() -checkLimit = (tables=<-, limit) => tables - |> map(fn: (r) => ({r with _value: r._value / 1000, limit: int(v: limit) * 60 * 5})) - |> map(fn: (r) => ({r with limitReached: r._value > r.limit})) +checkLimit = (tables=<-, limit) => + tables + |> map(fn: (r) => ({r with _value: r._value / 1000, limit: int(v: limit) * 60 * 5})) + |> map(fn: (r) => ({r with limitReached: r._value > r.limit})) -read = usage.from(start: -30d, stop: now()) - |> filter(fn: (r) => r._measurement == "http_request") - |> filter(fn: (r) => r._field == "resp_bytes") - |> filter(fn: (r) => r.endpoint == "/api/v2/query") - |> group(columns: ["_time"]) - |> sum() - |> group() - |> checkLimit(limit: limits.rate.readKBs) +read = + usage.from(start: -30d, stop: now()) + |> filter(fn: (r) => r._measurement == "http_request") + |> filter(fn: (r) => r._field == "resp_bytes") + |> filter(fn: (r) => r.endpoint == "/api/v2/query") + |> group(columns: ["_time"]) + |> sum() + |> group() + |> checkLimit(limit: limits.rate.readKBs) -write = usage.from(start: -30d, stop: now()) - |> filter(fn: (r) => r._measurement == "http_request") - |> filter(fn: (r) => r._field == "req_bytes") - |> filter(fn: (r) => r.endpoint == "/api/v2/write") - |> group(columns: ["_time"]) - |> sum() - |> group() - |> checkLimit(limit: limits.rate.writeKBs) +write = + usage.from(start: -30d, stop: now()) + |> filter(fn: (r) => r._measurement == "http_request") + |> filter(fn: (r) => r._field == "req_bytes") + |> filter(fn: (r) => r.endpoint == "/api/v2/write") + |> group(columns: ["_time"]) + |> sum() + |> group() + |> checkLimit(limit: limits.rate.writeKBs) union(tables: [read, write]) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/usage/limits.md b/content/flux/v0.x/stdlib/experimental/usage/limits.md index 98e572142..41c9f6414 100644 --- a/content/flux/v0.x/stdlib/experimental/usage/limits.md +++ b/content/flux/v0.x/stdlib/experimental/usage/limits.md @@ -1,38 +1,35 @@ --- title: usage.limits() function description: > - The `usage.limits()` function returns a record containing usage limits for an - **InfluxDB Cloud** organization. + `usage.limits()` returns a record containing usage limits for an **InfluxDB Cloud** organization. menu: flux_0_x_ref: name: usage.limits - parent: usage-exp -aliases: - - /influxdb/v2.0/reference/flux/stdlib/experimental/usage/limits/ - - /influxdb/cloud/reference/flux/stdlib/experimental/usage/limits/ -weight: 401 -related: - - /flux/v0.x/stdlib/influxdata/influxdb/cardinality/ - - /influxdb/cloud/account-management/data-usage/ - - /influxdb/cloud/account-management/limits/ + parent: experimental/usage + identifier: experimental/usage/limits +weight: 201 --- -The `usage.limits()` function returns a record containing usage limits for an -**InfluxDB Cloud** organization. + + +`usage.limits()` returns a record containing usage limits for an **InfluxDB Cloud** organization. + +### Example output record ``` - -#### Example output record -```js { orgID: "123", rate: { @@ -40,44 +37,47 @@ usage.limits( concurrentReadRequests: 0, writeKBs: 17, concurrentWriteRequests: 0, - cardinality: 10000 + cardinality: 10000, }, - bucket: { - maxBuckets: 2, - maxRetentionDuration: 2592000000000000 - }, - task: { - maxTasks: 5 - }, - dashboard: { - maxDashboards: 5 - }, - check: { - maxChecks: 2 - }, - notificationRule: { - maxNotifications: 2, - blockedNotificationRules: "comma, delimited, list" - }, - notificationEndpoint: { - blockedNotificationEndpoints: "comma, delimited, list" - } + bucket: {maxBuckets: 2, maxRetentionDuration: 2592000000000000}, + task: {maxTasks: 5}, + dashboard: {maxDashboards: 5}, + check: {maxChecks: 2}, + notificationRule: {maxNotifications: 2, blockedNotificationRules: "comma, delimited, list"}, + notificationEndpoint: {blockedNotificationEndpoints: "comma, delimited, list"}, } ``` +##### Function type signature + +```js +(?host: string, ?orgID: string, ?token: string) => A +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### host {data-type="string"} -[InfluxDB Cloud region URL](/influxdb/cloud/reference/regions/) _(Required if executed outside of your InfluxDB Cloud organization or region)_. +### host + +[InfluxDB Cloud region URL](https://docs.influxdata.com/influxdb/cloud/reference/regions/). Default is `""`. -### orgID {data-type="string"} -InfluxDB Cloud organization ID _(Required if executed outside of your InfluxDB Cloud organization or region)_. +_(Required if executed outside of your InfluxDB Cloud organization or region)_. + +### orgID + +InfluxDB Cloud organization ID. Default is `""`. + +_(Required if executed outside of your InfluxDB Cloud organization or region)_. + +### token + +InfluxDB Cloud [API token](https://docs.influxdata.com/influxdb/cloud/security/tokens/). Default is `""`. -### token {data-type="string"} -InfluxDB Cloud [API token](/influxdb/cloud/security/tokens/) _(Required if executed outside of your InfluxDB Cloud organization or region)_. -Default is `""`. +_(Required if executed outside of your InfluxDB Cloud organization or region)_. + ## Examples @@ -87,57 +87,87 @@ Default is `""`. - [Output current cardinality with your cardinality limit](#output-current-cardinality-with-your-cardinality-limit) ### Get rate limits for your InfluxDB Cloud organization + ```js import "experimental/usage" usage.limits() ``` + ### Get rate limits for a different InfluxDB Cloud organization + ```js import "experimental/usage" import "influxdata/influxdb/secrets" token = secrets.get(key: "INFLUX_TOKEN") -usage.limits(host: "https://cloud2.influxdata.com", orgID: "x000X0x0xx0X00x0", token: token) +usage.limits(host: "https://us-west-2-1.aws.cloud2.influxdata.com", orgID: "x000X0x0xx0X00x0", token: token) ``` + ### Output organization limits in a table + ```js import "array" import "experimental/usage" -import "influxdata/influxdb/secrets" -token = secrets.get(key: "INFLUX_TOKEN") - -limits = usage.limits(host: "https://cloud2.influxdata.com", orgID: "x000X0x0xx0X00x0", token: token) +limits = usage.limits() array.from( rows: [ {orgID: limits.orgID, limitGroup: "rate", limitName: "Read (kb/s)", limit: limits.rate.readKBs}, - {orgID: limits.orgID, limitGroup: "rate", limitName: "Concurrent Read Requests", limit: limits.rate.concurrentReadRequests}, + { + orgID: limits.orgID, + limitGroup: "rate", + limitName: "Concurrent Read Requests", + limit: limits.rate.concurrentReadRequests, + }, {orgID: limits.orgID, limitGroup: "rate", limitName: "Write (kb/s)", limit: limits.rate.writeKBs}, - {orgID: limits.orgID, limitGroup: "rate", limitName: "Concurrent Write Requests", limit: limits.rate.concurrentWriteRequests}, + { + orgID: limits.orgID, + limitGroup: "rate", + limitName: "Concurrent Write Requests", + limit: limits.rate.concurrentWriteRequests, + }, {orgID: limits.orgID, limitGroup: "rate", limitName: "Cardinality", limit: limits.rate.cardinality}, {orgID: limits.orgID, limitGroup: "bucket", limitName: "Max Buckets", limit: limits.bucket.maxBuckets}, - {orgID: limits.orgID, limitGroup: "bucket", limitName: "Max Retention Period (ns)", limit: limits.bucket.maxRetentionDuration}, + { + orgID: limits.orgID, + limitGroup: "bucket", + limitName: "Max Retention Period (ns)", + limit: limits.bucket.maxRetentionDuration, + }, {orgID: limits.orgID, limitGroup: "task", limitName: "Max Tasks", limit: limits.task.maxTasks}, - {orgID: limits.orgID, limitGroup: "dashboard", limitName: "Max Dashboards", limit: limits.dashboard.maxDashboards}, + { + orgID: limits.orgID, + limitGroup: "dashboard", + limitName: "Max Dashboards", + limit: limits.dashboard.maxDashboards, + }, {orgID: limits.orgID, limitGroup: "check", limitName: "Max Checks", limit: limits.check.maxChecks}, - {orgID: limits.orgID, limitGroup: "notificationRule", limitName: "Max Notification Rules", limit: limits.notificationRule.maxNotifications}, + { + orgID: limits.orgID, + limitGroup: "notificationRule", + limitName: "Max Notification Rules", + limit: limits.notificationRule.maxNotifications, + }, ], ) ``` + ### Output current cardinality with your cardinality limit + ```js import "experimental/usage" import "influxdata/influxdb" limits = usage.limits() -bucketCardinality = (bucket) => (influxdb.cardinality(bucket: bucket, start: time(v: 0)) - |> findColumn(fn: (key) => true, column: "_value"))[0] +bucketCardinality = (bucket) => + (influxdb.cardinality(bucket: bucket, start: time(v: 0)) + |> findColumn(fn: (key) => true, column: "_value"))[0] buckets() |> filter(fn: (r) => not r.name =~ /^_/) @@ -145,3 +175,4 @@ buckets() |> sum(column: "Cardinality") |> map(fn: (r) => ({r with "Cardinality Limit": limits.rate.cardinality})) ``` + diff --git a/content/flux/v0.x/stdlib/experimental/window.md b/content/flux/v0.x/stdlib/experimental/window.md index 243fa2e59..63d2feb23 100644 --- a/content/flux/v0.x/stdlib/experimental/window.md +++ b/content/flux/v0.x/stdlib/experimental/window.md @@ -1,101 +1,208 @@ --- title: experimental.window() function description: > - The `experimental.window()` function groups records based on a time value. - Input tables must have `_start`, `_stop`, and `_time` columns. + `experimental.window()` groups records based on time. menu: flux_0_x_ref: name: experimental.window parent: experimental -weight: 302 -related: - - /influxdb/v2.0/query-data/flux/window-aggregate/ - - /flux/v0.x/stdlib/universe/window/ - - /flux/v0.x/stdlib/universe/aggregatewindow/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-group-by-clause, InfluxQL – GROUP BY time() -flux/v0.x/tags: [transformations] + identifier: experimental/window +weight: 101 +flux/v0.x/tags: [transformations, date/time] introduced: 0.106.0 --- -The `experimental.window()` function groups records based on a time value. -New columns are added to uniquely identify each window. -Those columns are added to the group key of the output tables. -**Input tables must have `_start`, `_stop`, and `_time` columns.** + + +`experimental.window()` groups records based on time. + +`_start` and `_stop` columns are updated to reflect the bounds of +the window the row's time value is in. +Input tables must have `_start`, `_stop`, and `_time` columns. + +A single input record can be placed into zero or more output tables depending +on the specific windowing function. + +By default the start boundary of a window will align with the Unix epoch modified by the offset of the `location` option. -```js -import "experimental" +#### Calendar months and years +`every`, `period`, and `offset` support all valid duration units, including +calendar months (`1mo`) and years (`1y`). -experimental.window( - every: 5m, - period: 5m, - offset: 12h, - location: "UTC", - createEmpty: false, -) +##### Function type signature + +```js +( + <-tables: stream[{A with _time: time, _stop: time, _start: time}], + ?createEmpty: bool, + ?every: duration, + ?location: {zone: string, offset: duration}, + ?offset: duration, + ?period: duration, +) => stream[{A with _time: time, _stop: time, _start: time}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -{{% note %}} -#### Calendar months and years -`every`, `period`, and `offset` support all [valid duration units](/flux/v0.x/spec/types/#duration-types), -including **calendar months (`1mo`)** and **years (`1y`)**. -{{% /note %}} +### every -### every {data-type="duration"} -({{< req >}}) -Duration of time between windows. -Defaults to `period` value. +Duration of time between windows. Default is the `0s`. + + + +### period + +Duration of the window. Default is `0s`. -### period {data-type="duration"} -Duration of the window. Period is the length of each interval. It can be negative, indicating the start and stop boundaries are reversed. -Defaults to `every` value. -### offset {data-type="duration"} -Offset is the duration by which to shift the window boundaries. -It can be negative, indicating that the offset goes backwards in time. -Defaults to 0, which will align window end boundaries with the `every` duration. +### offset -### location {data-type="string"} -Location used to determine timezone. -Default is the [`location` option](/flux/v0.x/stdlib/universe/#location). +Duration to shift the window boundaries by. Default is 0s. + +`offset` can be negative, indicating that the offset goes backwards in time. + +### location + +Location used to determine timezone. Default is the `location` option. + + + +### createEmpty + +Create empty tables for empty windows. Default is `false`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -_Flux uses the timezone database (commonly referred to as "tz" or "zoneinfo") -provided by the operating system._ -### createEmpty {data-type="bool"} -Specifies whether empty tables should be created. -Defaults to `false`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data (`<-`). ## Examples -#### Window data into 10 minute intervals +- [Window data into thirty second intervals](#window-data-into-thirty-second-intervals) +- [Window by calendar month](#window-by-calendar-month) + +### Window data into thirty second intervals + ```js import "experimental" -from(bucket:"example-bucket") - |> range(start: -12h) - |> experimental.window(every: 10m) - // ... +data + |> experimental.window(every: 30s) ``` -#### Window by calendar month +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:20Z | 7 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:20Z | -3 | t2 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Window by calendar month + ```js import "experimental" -from(bucket:"example-bucket") - |> range(start: -1y) - |> experimental.window(every: 1mo) - // ... +data + |> experimental.window(every: 1mo) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-01T00:00:00Z | 32.1 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-02T00:00:00Z | 32.9 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-03T00:00:00Z | 33.2 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-01T00:00:00Z | 38.3 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-02T00:00:00Z | 38.4 | +| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-03T00:00:00Z | 37.8 | + + +#### Output data + +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-01T00:00:00Z | 32.1 | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-02T00:00:00Z | 32.9 | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-03T00:00:00Z | 33.2 | + +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-01T00:00:00Z | 38.3 | +| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-02T00:00:00Z | 38.4 | +| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-03T00:00:00Z | 37.8 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/generate/_index.md b/content/flux/v0.x/stdlib/generate/_index.md index 50ecd767d..cf33bc7d3 100644 --- a/content/flux/v0.x/stdlib/generate/_index.md +++ b/content/flux/v0.x/stdlib/generate/_index.md @@ -1,25 +1,44 @@ --- -title: Flux generate package -list_title: generate package +title: generate package description: > - The Flux `generate` package provides functions for generating data. - Import the `generate` package. + The `generate` package provides functions for generating data. menu: flux_0_x_ref: - name: generate - parent: Standard library + name: generate + parent: stdlib + identifier: generate weight: 11 -flux/v0.x/tags: [functions, generate, package] cascade: + flux/v0.x/tags: [generate] introduced: 0.17.0 --- -The Flux `generate` package provides functions for generating data. -Import the `generate` package. + + +The `generate` package provides functions for generating data. +Import the `generate` package: ```js import "generate" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/generate/from.md b/content/flux/v0.x/stdlib/generate/from.md index bd99ccfba..c971986f8 100644 --- a/content/flux/v0.x/stdlib/generate/from.md +++ b/content/flux/v0.x/stdlib/generate/from.md @@ -1,69 +1,79 @@ --- title: generate.from() function description: > - `generate.from` generates data using provided parameter values. + `generate.from()` generates data using the provided parameter values. menu: flux_0_x_ref: name: generate.from parent: generate + identifier: generate/from +weight: 101 flux/v0.x/tags: [inputs] -weight: 202 --- -`generate.from` generates data using provided parameter values. + + +`generate.from()` generates data using the provided parameter values. + + + +##### Function type signature ```js -import "generate" - -generate.from( - count: 5, - fn: (n) => n, - start: 2021-01-01T00:00:00Z, - stop: 2021-01-02T00:00:00Z, -) +(count: int, fn: (n: int) => int, start: A, stop: A) => stream[{_value: int, _time: time, _stop: time, _start: time}] where A: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### count {data-type="int"} +### count ({{< req >}}) Number of rows to generate. -### fn {data-type="function"} -({{< req >}}) -Function used to generate values. -The function takes an `n` parameter that represents the row index, operates on `n`, -and then returns an [integer value](/flux/v0.x/data-types/basic/int/). -Rows use zero-based indexing. -### start {data-type="time"} + +### fn +({{< req >}}) +Function used to generate values. + +The function takes an `n` parameter that represents the row index, operates +on `n`, and then returns an integer value. Rows use zero-based indexing. + +### start ({{< req >}}) Beginning of the time range to generate values in. -### stop {data-type="time"} -({{< req >}}) + + +### stop +({{< req >}}) End of the time range to generate values in. + + + ## Examples ### Generate sample data + ```js import "generate" -generate.from( - count: 6, - fn: (n) => (n + 1) * (n + 2), - start: 2021-01-01T00:00:00Z, - stop: 2021-01-02T00:00:00Z, -) +generate.from(count: 6, fn: (n) => (n + 1) * (n + 2), start: 2021-01-01T00:00:00Z, stop: 2021-01-02T00:00:00Z) ``` -##### Output data -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T00:00:00Z | 2 | -| 2021-01-01T04:00:00Z | 6 | -| 2021-01-01T08:00:00Z | 12 | -| 2021-01-01T12:00:00Z | 20 | -| 2021-01-01T16:00:00Z | 30 | -| 2021-01-01T20:00:00Z | 42 | \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/http/_index.md b/content/flux/v0.x/stdlib/http/_index.md index 5de991243..5ac5290e3 100644 --- a/content/flux/v0.x/stdlib/http/_index.md +++ b/content/flux/v0.x/stdlib/http/_index.md @@ -1,28 +1,44 @@ --- -title: Flux http package -list_title: http package +title: http package description: > - The Flux `http` package provides functions for transferring data using the HTTP protocol. - Import the `http` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/http/ - - /influxdb/v2.0/reference/flux/stdlib/http/ - - /influxdb/cloud/reference/flux/stdlib/http/ + The `http` package provides functions for transferring data using the HTTP protocol. menu: flux_0_x_ref: - name: http - parent: Standard library + name: http + parent: stdlib + identifier: http weight: 11 -flux/v0.x/tags: [functions, http, package] -introduced: 0.39.0 +cascade: + + introduced: 0.39.0 --- -The Flux `http` package provides functions for transferring data using the HTTP protocol. + + +The `http` package provides functions for transferring data using the HTTP protocol. Import the `http` package: ```js import "http" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/http/basicauth.md b/content/flux/v0.x/stdlib/http/basicauth.md index e74004e39..d82b256b1 100644 --- a/content/flux/v0.x/stdlib/http/basicauth.md +++ b/content/flux/v0.x/stdlib/http/basicauth.md @@ -1,44 +1,67 @@ --- title: http.basicAuth() function description: > - The `http.basicAuth()` function returns a Base64-encoded basic authentication - header using a specified username and password combination. -aliases: - - /influxdb/v2.0/reference/flux/functions/http/basicauth/ - - /influxdb/v2.0/reference/flux/stdlib/http/basicauth/ - - /influxdb/cloud/reference/flux/stdlib/http/basicauth/ + `http.basicAuth()` returns a Base64-encoded basic authentication header + using a specified username and password combination. menu: flux_0_x_ref: name: http.basicAuth parent: http -weight: 202 + identifier: http/basicAuth +weight: 101 +flux/v0.x/tags: [single notification] introduced: 0.44.0 --- -The `http.basicAuth()` function returns a Base64-encoded basic authentication -header using a specified username and password combination. + + +`http.basicAuth()` returns a Base64-encoded basic authentication header +using a specified username and password combination. + + + +##### Function type signature ```js -import "http" - -http.basicAuth(u: "username", p: "passw0rd") - -// Returns "Basic dXNlcm5hbWU6cGFzc3cwcmQ=" +(p: string, u: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### u {data-type="string"} -The username to use in the basic authentication header. +### u +({{< req >}}) +Username to use in the basic authentication header. + + + +### p +({{< req >}}) +Password to use in the basic authentication header. + + -### p {data-type="string"} -The password to use in the basic authentication header. ## Examples -##### Set a basic authentication header in an HTTP POST request +### Set a basic authentication header in an HTTP POST request + ```js -import "monitor" import "http" username = "myawesomeuser" @@ -46,7 +69,8 @@ password = "mySupErSecRetPasSW0rD" http.post( url: "http://myawesomesite.com/api/", - headers: {Authorization: http.basicAuth(u:username, p:password)}, - data: bytes(v: "something I want to send."), + headers: {Authorization: http.basicAuth(u: username, p: password)}, + data: bytes(v: "Something I want to send."), ) ``` + diff --git a/content/flux/v0.x/stdlib/http/endpoint.md b/content/flux/v0.x/stdlib/http/endpoint.md index 961bf267e..f1925f19d 100644 --- a/content/flux/v0.x/stdlib/http/endpoint.md +++ b/content/flux/v0.x/stdlib/http/endpoint.md @@ -1,47 +1,82 @@ --- title: http.endpoint() function description: > - The `http.endpoint()` function sends output data to an HTTP URL using the POST request method. -aliases: - - /influxdb/v2.0/reference/flux/functions/http/endpoint/ - - /influxdb/v2.0/reference/flux/stdlib/http/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/http/endpoint/ + `http.endpoint()` iterates over input data and sends a single POST request per input row to + a specficied URL. menu: flux_0_x_ref: name: http.endpoint parent: http -weight: 202 + identifier: http/endpoint +weight: 101 flux/v0.x/tags: [notification endpoints] -introduced: 0.39.0 --- -The `http.endpoint()` function sends output data to an HTTP URL using the POST request method. + -{{% note %}} -_You should rarely need to override the default `mapFn` parameter. -To see the default `mapFn` value or for insight into possible overrides, view the -[`http.endpoint()` source code](https://github.com/influxdata/flux/blob/master/stdlib/http/http.flux)._ -{{% /note %}} +`http.endpoint()` iterates over input data and sends a single POST request per input row to +a specficied URL. -`mapFn` accepts a table row (`r`) and returns a record that must include the following fields: +This function is designed to be used with `monitor.notify()`. + +`http.endpoint()` outputs a function that requires a `mapFn` parameter. +`mapFn` is the function that builds the record used to generate the POST request. +It accepts a table row (`r`) and returns a record that must include the +following properties: - `headers` - `data` -_For more information, see [`http.post()`](/flux/v0.x/stdlib/http/post/)_ +_For information about properties, see `http.post`._ + +##### Function type signature + +```js +( + url: string, +) => (mapFn: (r: A) => {B with headers: C, data: bytes}) => (<-tables: stream[A]) => stream[{A with _sent: string}] where C: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### url +({{< req >}}) +URL to send the POST reqeust to. + + + + +## Examples + +### Send an HTTP POST request for each row + +```js +import "http" +import "sampledata" + +endpoint = + http.endpoint(url: "http://example.com/")( + mapfn: (r) => + ({headers: {header1: "example1", header2: "example2"}, data: bytes(v: "The value is ${r._value}")}), + ) + +sampledata.int() + |> endpoint() +``` + diff --git a/content/flux/v0.x/stdlib/http/pathescape.md b/content/flux/v0.x/stdlib/http/pathescape.md index f5bbff57f..91d94c705 100644 --- a/content/flux/v0.x/stdlib/http/pathescape.md +++ b/content/flux/v0.x/stdlib/http/pathescape.md @@ -1,43 +1,124 @@ --- title: http.pathEscape() function description: > - The `http.pathEscape()` function escapes special characters in a string (including `/`) + `http.pathEscape()` escapes special characters in a string (including `/`) and replaces non-ASCII characters with hexadecimal representations (`%XX`). -aliases: - - /influxdb/v2.0/reference/flux/stdlib/http/pathescape/ - - /influxdb/cloud/reference/flux/stdlib/http/pathescape/ menu: flux_0_x_ref: name: http.pathEscape parent: http -weight: 202 + identifier: http/pathEscape +weight: 101 + introduced: 0.71.0 --- -The `http.pathEscape()` function escapes special characters in a string (including `/`) + + +`http.pathEscape()` escapes special characters in a string (including `/`) and replaces non-ASCII characters with hexadecimal representations (`%XX`). + + +##### Function type signature + ```js -import "http" - -http.pathEscape( - inputString: "/this/is/an/example-path.html" -) - -// Returns %2Fthis%2Fis%2Fan%2Fexample-path.html +(inputString: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### inputString {data-type="string"} -The string to escape. +### inputString +({{< req >}}) +String to escape. + + + ## Examples -##### URL-encode strings in a stream of tables +- [URL-encode a string](#url-encode-a-string) +- [URL-encode strings in a stream of tables](#url-encode-strings-in-a-stream-of-tables) + +### URL-encode a string + ```js import "http" -data - |> map(fn: (r) => ({r with path: http.pathEscape(inputString: r.path)})) +http.pathEscape(inputString: "Hello world!")// Returns "Hello%20world%21" + ``` + + +### URL-encode strings in a stream of tables + +```js +import "http" +import "sampledata" + +sampledata.string() + |> map(fn: (r) => ({r with _value: http.pathEscape(inputString: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | smpl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | smpl_phw664 | t1 | +| 2021-01-01T00:00:30Z | smpl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | smpl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | smpl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_b5eida | t2 | +| 2021-01-01T00:00:10Z | smpl_eu4oxp | t2 | +| 2021-01-01T00:00:20Z | smpl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | smpl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | smpl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | smpl_dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/http/post.md b/content/flux/v0.x/stdlib/http/post.md index 49df50bb9..b2339dea3 100644 --- a/content/flux/v0.x/stdlib/http/post.md +++ b/content/flux/v0.x/stdlib/http/post.md @@ -1,72 +1,88 @@ --- title: http.post() function description: > - The `http.post()` function submits an HTTP POST request to the specified URL with headers and data. - The HTTP status code is returned. -aliases: - - /influxdb/v2.0/reference/flux/functions/http/post/ - - /influxdb/v2.0/reference/flux/stdlib/http/post/ - - /influxdb/cloud/reference/flux/stdlib/http/post/ + `http.post()` sends an HTTP POST request to the specified URL with headers and data + and returns the HTTP status code. menu: flux_0_x_ref: name: http.post parent: http -weight: 202 + identifier: http/post +weight: 101 + introduced: 0.40.0 --- -The `http.post()` function submits an HTTP POST request to the specified URL with -headers and data and returns the HTTP status code. + + +`http.post()` sends an HTTP POST request to the specified URL with headers and data +and returns the HTTP status code. + + + +##### Function type signature ```js -import "http" - -http.post( - url: "http://localhost:8086/", - headers: {x:"a", y:"b", z:"c"}, - data: bytes(v: "body"), -) +(url: string, ?data: bytes, ?headers: A) => int where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -The URL to POST to. +### url +({{< req >}}) +URL to send the POST request to. + + + +### headers -### headers {data-type="record"} Headers to include with the POST request. -{{% note %}} -##### Header keys with special characters +**Header keys with special characters:** Wrap header keys that contain special characters in double quotes (`""`). -```js -{"key-1": "value 1", "key#2": "value 2" } -``` -{{% /note %}} +### data + +Data body to include with the POST request. + + -### data {data-type="bytes"} -The data body to include with the POST request. ## Examples -##### Send the last reported status to a URL +### Send the last reported status to a URL + ```js import "json" import "http" -lastReported = from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses") - |> last() - |> findColumn(fn: (key) => true, column: "_level") +lastReported = + from(bucket: "example-bucket") + |> range(start: -1m) + |> filter(fn: (r) => r._measurement == "statuses") + |> last() + |> findColumn(fn: (key) => true, column: "_level") http.post( url: "http://myawsomeurl.com/api/notify", - headers: { - Authorization: "Bearer mySuPerSecRetTokEn", - "Content-type": "application/json" - }, + headers: {Authorization: "Bearer mySuPerSecRetTokEn", "Content-type": "application/json"}, data: json.encode(v: lastReported[0]), ) ``` + diff --git a/content/flux/v0.x/stdlib/influxdata/_index.md b/content/flux/v0.x/stdlib/influxdata/_index.md index 9a97800ef..c30d4c493 100644 --- a/content/flux/v0.x/stdlib/influxdata/_index.md +++ b/content/flux/v0.x/stdlib/influxdata/_index.md @@ -1,14 +1,36 @@ --- -title: Flux InfluxData package -list_title: influxdata package +title: influxdata package +description: > + The `influxdata` package contains packages and functions that integrate with InfluxData products. menu: flux_0_x_ref: - name: influxdata - parent: Standard library + name: influxdata + parent: stdlib + identifier: influxdata weight: 11 --- -The `influxdata` package provides tools for working with InfluxData projects. + + +The `influxdata` package contains packages and functions that integrate with InfluxData products. + + + ## Packages -{{< children >}} \ No newline at end of file + +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/_index.md b/content/flux/v0.x/stdlib/influxdata/influxdb/_index.md index f7fb5bb08..c6ca42ddf 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/_index.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/_index.md @@ -1,30 +1,50 @@ --- -title: Flux InfluxDB package -list_title: influxdb package +title: influxdb package description: > - The Flux InfluxDB package provides functions for analyzing InfluxDB metadata. - Import the `influxdata/influxdb` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/influxdb/ - - /influxdb/cloud/reference/flux/stdlib/influxdb/ + The `influxdb` package provides functions designed for working with InfluxDB and + analyzing InfluxDB metadata. menu: flux_0_x_ref: - name: influxdb - identifier: influxdb-pkg + name: influxdb parent: influxdata -weight: 202 -flux/v0.x/tags: [functions, package] + identifier: influxdata/influxdb +weight: 21 +cascade: + + introduced: 0.7.0 --- -The Flux `influxdb` package provides functions for analyzing InfluxDB metadata. + + +The `influxdb` package provides functions designed for working with InfluxDB and +analyzing InfluxDB metadata. Import the `influxdata/influxdb` package: ```js import "influxdata/influxdb" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} ## Packages + {{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/buckets.md b/content/flux/v0.x/stdlib/influxdata/influxdb/buckets.md new file mode 100644 index 000000000..1f8b8e6c0 --- /dev/null +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/buckets.md @@ -0,0 +1,90 @@ +--- +title: buckets() function +description: > + `buckets()` returns a list of buckets in the specified organization. +menu: + flux_0_x_ref: + name: buckets + parent: influxdata/influxdb + identifier: influxdata/influxdb/buckets +weight: 201 +flux/v0.x/tags: [metadata] +introduced: 0.16.0 +--- + + + +`buckets()` returns a list of buckets in the specified organization. + + + +##### Function type signature + +```js +( + ?host: string, + ?org: string, + ?orgID: string, + ?token: string, +) => stream[{ + retentionPolicy: string, + retentionPeriod: int, + organizationID: string, + name: string, + id: string, +}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### org + +Organization name. Default is the current organization. + +_`org` and `orgID` are mutually exclusive_. + +### orgID + +Organization ID. Default is the ID of the current organization. + +_`org` and `orgID` are mutually exclusive_. + +### host + +URL of the InfluxDB instance. + +See [InfluxDB Cloud regions](https://docs.influxdata.com/influxdb/cloud/reference/regions/) +or [InfluxDB OSS URLs](https://docs.influxdata.com/influxdb/latest/reference/urls/). +_`host` is required when `org` or `orgID` are specified._ + +### token + +InfluxDB API token. + +_`token` is required when `host`, `org, or `orgID` are specified._ + + +## Examples + +### List buckets in an InfluxDB organization + +```js +buckets(org: "example-org", host: "http://localhost:8086", token: "mYSuP3rSecR37t0k3N") +``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/cardinality.md b/content/flux/v0.x/stdlib/influxdata/influxdb/cardinality.md index 0745a70a3..8c260c095 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/cardinality.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/cardinality.md @@ -1,136 +1,147 @@ --- title: influxdb.cardinality() function -description: The `influxdb.cardinality()` function returns the series cardinality of data stored in InfluxDB. +description: > + `influxdb.cardinality()` returns the series cardinality of data stored in InfluxDB. menu: flux_0_x_ref: name: influxdb.cardinality - parent: influxdb-pkg -aliases: - - /influxdb/v2.0/reference/flux/stdlib/influxdb/cardinality/ - - /influxdb/cloud/reference/flux/stdlib/influxdb/cardinality/ - - /flux/v0.x/stdlib/influxdb/cardinality/ -weight: 302 + parent: influxdata/influxdb + identifier: influxdata/influxdb/cardinality +weight: 201 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/spec/#show-cardinality, SHOW CARDINALITY in InfluxQL - - /flux/v0.x/stdlib/experimental/usage/limits/ introduced: 0.92.0 --- -The `influxdb.cardinality()` function returns the [series cardinality](/{{< latest "influxdb" "v2" >}}/reference/glossary#series-cardinality) of a specified dataset in InfluxDB. + + +`influxdb.cardinality()` returns the series cardinality of data stored in InfluxDB. + + + +##### Function type signature ```js -import "influxdata/influxdb" - -influxdb.cardinality( - bucket: "example-bucket", - org: "example-org", - host: "https://cloud2.influxdata.com", - token: "MySuP3rSecr3Tt0k3n", - start: -30d, - stop: now(), - predicate: (r) => true, -) - -// OR - -influxdb.cardinality( - bucketID: "00xXx0x00xXX0000", - orgID: "00xXx0x00xXX0000", - host: "https://cloud2.influxdata.com", - token: "MySuP3rSecr3Tt0k3n", - start: -30d, - stop: now(), - predicate: (r) => true, -) +( + start: A, + ?bucket: string, + ?bucketID: string, + ?host: string, + ?org: string, + ?orgID: string, + ?predicate: (r: {B with _value: C, _measurement: string, _field: string}) => bool, + ?stop: D, + ?token: string, +) => stream[{_value: int, _stop: time, _start: time}] where A: Timeable, D: Timeable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bucket {data-type="string"} +### bucket + Bucket to query cardinality from. -### bucketID {data-type="string"} + + +### bucketID + String-encoded bucket ID to query cardinality from. -### org {data-type="string"} + + +### org + Organization name. -### orgID {data-type="string"} -String-encoded [organization ID](/influxdb/cloud/organizations/view-orgs/#view-your-organization-id) to query cardinality from. -### host {data-type="string"} + +### orgID + +String-encoded organization ID. + + + +### host + URL of the InfluxDB instance to query. -_See [InfluxDB Cloud regions](/influxdb/cloud/reference/regions) or -[InfluxDB OSS URLs](/{{< latest "influxdb" "v2" >}}/reference/urls/)._ -### token {data-type="string"} -InfluxDB [API token](/{{< latest "influxdb" "v2" >}}/security/tokens/). +See [InfluxDB Cloud regions](https://docs.influxdata.com/influxdb/cloud/reference/regions/) +or [InfluxDB OSS URLs](https://docs.influxdata.com/influxdb/latest/reference/urls/). -### start {data-type="duration, time"} -The earliest time to include when calculating cardinality. -The cardinality calculation **includes** points that match the specified start time. -Use a relative duration or absolute time. -For example, `-1h` or `2019-08-28T22:00:00Z`. -Durations are relative to [`now()`](/flux/v0.x/stdlib/universe/now/). +### token -### stop {data-type="duration, time"} -The latest time to include when calculating cardinality. -The cardinality calculation **excludes** points that match the specified start time. -Use a relative duration or absolute time. -For example, `-1h` or `2019-08-28T22:00:00Z`. -Durations are relative to [`now()`](/flux/v0.x/stdlib/universe/now/). -_Default is `now()`_. +InfluxDB API token. + + + +### start +({{< req >}}) +Earliest time to include when calculating cardinality. + +The cardinality calculation includes points that match the specified start time. +Use a relative duration or absolute time. For example, `-1h` or `2019-08-28T22:00:00Z`. +Durations are relative to `now()`. + +### stop + +Latest time to include when calculating cardinality. + +The cardinality calculation excludes points that match the specified start time. +Use a relative duration or absolute time. For example, `-1h` or `2019-08-28T22:00:00Z`. +Durations are relative to `now()`. Default is `now()`. + +### predicate -### predicate {data-type="function"} Predicate function that filters records. -_Default is `(r) => true`_. +Default is `(r) => true`. + + + ## Examples - [Query series cardinality in a bucket](#query-series-cardinality-in-a-bucket) -- [Query series cardinality in a measurement](#query-series-cardinality-in-a-measurement) +- [Query series cardinality in a measurement//](#query-series-cardinality-in-a-measurement) - [Query series cardinality for a specific tag](#query-series-cardinality-for-a-specific-tag) -- [Query total cardinality across all buckets](#query-total-cardinality-across-all-buckets) -##### Query series cardinality in a bucket +### Query series cardinality in a bucket + ```js import "influxdata/influxdb" influxdb.cardinality(bucket: "example-bucket", start: -1y) ``` -##### Query series cardinality in a measurement + +### Query series cardinality in a measurement// + ```js import "influxdata/influxdb" -influxdb.cardinality( - bucket: "example-bucket", - start: -1y, - predicate: (r) => r._measurement == "example-measurement", -) +influxdb.cardinality(bucket: "example-bucket", start: -1y, predicate: (r) => r._measurement == "example-measurement") ``` -##### Query series cardinality for a specific tag + +### Query series cardinality for a specific tag + ```js import "influxdata/influxdb" -influxdb.cardinality( - bucket: "example-bucket", - start: -1y, - predicate: (r) => r.exampleTag == "foo", -) +influxdb.cardinality(bucket: "example-bucket", start: -1y, predicate: (r) => r.exampleTag == "foo") ``` -##### Query total cardinality across all buckets -```js -import "influxdata/influxdb" - -bucketCardinality = (bucket) => (influxdb.cardinality(bucket: bucket, start: time(v: 0)) - |> findColumn(fn: (key) => true, column: "_value"))[0] - -buckets() - |> filter(fn: (r) => not r.name =~ /^_/) - |> map(fn: (r) => ({bucket: r.name, "Total Cardinality": bucketCardinality(bucket: r.name)})) - |> sum(column: "Total Cardinality") -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/from.md b/content/flux/v0.x/stdlib/influxdata/influxdb/from.md index 911b8aecb..f68edb733 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/from.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/from.md @@ -1,253 +1,136 @@ --- title: from() function -description: The `from()` function retrieves data from an InfluxDB data source. -aliases: - - /flux/v0.x/stdlib/universe/from - - /influxdb/v2.0/reference/flux/functions/inputs/from - - /influxdb/v2.0/reference/flux/functions/built-in/inputs/from/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/inputs/from/ - - /influxdb/cloud/reference/flux/stdlib/built-in/inputs/from/ +description: > + `from()` queries data from an InfluxDB data source. menu: flux_0_x_ref: name: from - parent: influxdb-pkg -weight: 301 + parent: influxdata/influxdb + identifier: influxdata/influxdb/from +weight: 201 flux/v0.x/tags: [inputs] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#from-clause, InfluxQL - FROM -introduced: 0.7.0 --- -The `from()` function retrieves data from an InfluxDB data source. -It returns a stream of tables from the specified [bucket](#parameters). + + +`from()` queries data from an InfluxDB data source. + +It returns a stream of tables from the specified bucket. Each unique series is contained within its own table. Each record in the table represents a single point in the series. +#### Query remote InfluxDB data sources +Use `from()` to query data from remote **InfluxDB OSS 1.7+**, +**InfluxDB Enterprise 1.9+**, and **InfluxDB Cloud**. +To query remote InfluxDB sources, include the `host`, `token`, and `org` +(or `orgID`) parameters. + +#### from() does not require a package import +`from()` is part of the `influxdata/influxdb` package, but is part of the +Flux prelude and does not require an import statement or package namespace. + +##### Function type signature + ```js -from( - bucket: "example-bucket", - host: "https://example.com", - org: "example-org", - token: "MySuP3rSecr3Tt0k3n", -) - -// OR - -from( - bucketID: "0261d8287f4d6000", - host: "https://example.com", - orgID: "867f3fcf1846f11f", - token: "MySuP3rSecr3Tt0k3n", -) +( + ?bucket: string, + ?bucketID: string, + ?host: string, + ?org: string, + ?orgID: string, + ?token: string, +) => stream[{A with _value: B, _time: time, _measurement: string, _field: string}] ``` -{{% note %}} -#### from() does not require a package import -`from()` is part of the `influxdata/influxdb` package, but is included with the -[`universe` package](/flux/v0.x/stdlib/universe/) by default and does not require -an import statement or package namespace. -{{% /note %}} - -{{% note %}} -#### Query remote InfluxDB data sources -Use `from()` to retrieve data from remote InfluxDB OSS 1.7+, InfluxDB Enterprise 1.9+, and InfluxDB Cloud. -To query remote InfluxDB sources, include the [host](#host), [token](#token), and -[org](#org) (or [orgID](#orgid)) parameters. -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### bucket {data-type="string"} +### bucket + Name of the bucket to query. +_`bucket` and `bucketID` are mutually exclusive_. **InfluxDB 1.x or Enterprise**: Provide an empty string (`""`). -### bucketID {data-type="string"} +### bucketID + String-encoded bucket ID to query. +_`bucket` and `bucketID` are mutually exclusive_. **InfluxDB 1.x or Enterprise**: Provide an empty string (`""`). -### host {data-type="string"} +### host + URL of the InfluxDB instance to query. -_See [InfluxDB URLs](/{{< latest "influxdb" >}}/reference/urls/) or -[InfluxDB Cloud regions](/influxdb/cloud/reference/regions/)._ -### org {data-type="string"} +See [InfluxDB Cloud regions](https://docs.influxdata.com/influxdb/cloud/reference/regions/) +or [InfluxDB OSS URLs](https://docs.influxdata.com/influxdb/latest/reference/urls/). + +### org + Organization name. +_`org` and `orgID` are mutually exclusive_. **InfluxDB 1.x or Enterprise**: Provide an empty string (`""`). -### orgID {data-type="string"} -String-encoded [organization ID](/{{< latest "influxdb" >}}/organizations/view-orgs/#view-your-organization-id) to query. +### orgID + +String-encoded organization ID to query. +_`org` and `orgID` are mutually exclusive_. **InfluxDB 1.x or Enterprise**: Provide an empty string (`""`). -### token {data-type="string"} -InfluxDB [API token](/{{< latest "influxdb" >}}/security/tokens/). +### token -**InfluxDB 1.x or Enterprise**: -If authentication is _disabled_, provide an empty string (`""`). -If authentication is _enabled_, provide your InfluxDB username and password -using the `:` syntax. +InfluxDB API token. -## Push down optimizations +**InfluxDB 1.x or Enterprise**: If authentication is disabled, provide an +empty string (`""`). If authentication is enabled, provide your InfluxDB +username and password using the `:` syntax. -Some transformations called after `from()` trigger performance optimizations called pushdowns. -These optimizations are "pushed down" from Flux into the InfluxDB storage layer and where they utilize code in storage to apply the transformation. -Pushdowns happen automatically, but it is helpful understand how these optimizations work so you can better optimize your Flux queries. - -Pushdowns require an unbroken and exclusive chain between transformations. -A `from()` call stored in a variable that then goes to multiple pushdowns will -cause none of the pushdowns to be applied. For example: - -```js -// Pushdowns are NOT applied -data = from(bucket: "example-bucket") - |> range(start: -1h) - -data |> filter(fn: (r) => r._measurement == "m0") |> yield(name: "m0") -data |> filter(fn: (r) => r._measurement == "m1") |> yield(name: "m1") -``` - -To reuse code and still apply pushdowns, invoke `from()` in a function and pipe-forward the output of the function into subsequent pushdowns: - -```js -// Pushdowns ARE applied -data = () => from(bucket: "example-bucket") - |> range(start: -1h) - -data() |> filter(fn: (r) => r._measurement == "m0") |> yield(name: "m0") -data() |> filter(fn: (r) => r._measurement == "m1") |> yield(name: "m1") -``` - -### Filter - -`filter()` transformations that compare `r._measurement`, `r._field`, `r._value` -or any tag value are pushed down to the storage layer. -Comparisons that use functions do not. -If the function produces a static value, evaluate the function outside of `filter()`. -For example: - -```js -import "strings" - -// filter() is NOT pushed down -data - |> filter(fn: (r) => r.example == strings.joinStr(arr: ["foo", "bar"], v: "")) - -// filter() is pushed down -exVar = strings.joinStr(arr: ["foo", "bar"], v: "")) - -data - |> filter(fn: (r) => r.example == exVar) -``` - -Multiple consecutive `filter()` transformations that can be pushed down are -merged together into a single filter that gets pushed down. - -### Aggregates - -The following aggregate transformations are pushed down: - -- `min()` -- `max()` -- `sum()` -- `count()` -- `mean()` (except when used with `group()`) - -Aggregates will also be pushed down if they are preceded by a `group()`. -The only exception is `mean()` which cannot be pushed down to the storage layer with `group()`. - -### Aggregate Window - -Aggregates used with `aggregateWindow()` are pushed down. -Aggregates pushed down with `aggregateWindow()` are not compatible with `group()`. ## Examples -- [Query InfluxDB using the bucket name](#query-using-the-bucket-name) -- [Query InfluxDB using the bucket ID](#query-using-the-bucket-id) +- [Query InfluxDB using the bucket name](#query-influxdb-using-the-bucket-name) +- [Query InfluxDB using the bucket ID](#query-influxdb-using-the-bucket-id) - [Query a remote InfluxDB Cloud instance](#query-a-remote-influxdb-cloud-instance) -- [Query push downs](#query-push-downs) -- [Query from the same bucket to multiple push downs](#query-multiple-push-downs) -#### Query using the bucket name +### Query InfluxDB using the bucket name + ```js from(bucket: "example-bucket") ``` -#### Query using the bucket ID + +### Query InfluxDB using the bucket ID + ```js from(bucketID: "0261d8287f4d6000") ``` -#### Query a remote InfluxDB Cloud instance + +### Query a remote InfluxDB Cloud instance + ```js import "influxdata/influxdb/secrets" token = secrets.get(key: "INFLUXDB_CLOUD_TOKEN") -from( - bucket: "example-bucket", - host: "https://cloud2.influxdata.com", - org: "example-org", - token: token, -) +from(bucket: "example-bucket", host: "https://us-west-2-1.aws.cloud2.influxdata.com", org: "example-org", token: token) ``` -### Utilize pushdowns in multiple queries - -```js -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "m0") - |> filter(fn: (r) => r._field == "f0") - |> yield(name: "filter-only") - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "m0") - |> filter(fn: (r) => r._field == "f0") - |> max() - |> yield(name: "max") - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "m0") - |> filter(fn: (r) => r._field == "f0") - |> group(columns: ["t0"]) - |> max() - |> yield(name: "grouped-max") - -from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "m0") - |> filter(fn: (r) => r._field == "f0") - |> aggregateWindow(every: 5m, fn: max) - |> yield(name: "windowed-max") -``` - -### Query from the same bucket to multiple pushdowns - -```js -// Use a function. If you use a variable, this will stop -// Flux from pushing down the operation. -data = () => from(bucket: "example-bucket") - |> range(start: -1h) - -data() |> filter(fn: (r) => r._measurement == "m0") -data() |> filter(fn: (r) => r._measurement == "m1") -``` - -### Query from the same bucket to multiple transformations - -```js -// The push down chain is not broken until after the push down -// is complete. In this case, it is more efficient to use a variable. -data = from(bucket: "example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "m0") - -data |> derivative() |> yield(name: "derivative") -data |> movingAverage(n: 5) |> yield(name: "movingAverage") -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/_index.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/_index.md index e8c6ca984..4f0d89a4d 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/_index.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/_index.md @@ -1,54 +1,76 @@ --- -title: Flux InfluxDB monitor package -list_title: monitor package +title: monitor package description: > - The InfluxDB `monitor` package provides tools for monitoring and alerting with InfluxDB. - Import the `influxdata/influxdb/monitor` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/monitor/ - - /influxdb/v2.0/reference/flux/stdlib/monitor/ - - /influxdb/cloud/reference/flux/stdlib/monitor/ + The `monitor` package provides tools for monitoring and alerting with InfluxDB. menu: flux_0_x_ref: - name: monitor - parent: influxdb-pkg -weight: 202 -flux/v0.x/tags: [functions, monitor, alerts, package] -introduced: 0.39.0 + name: monitor + parent: influxdata/influxdb + identifier: influxdata/influxdb/monitor +weight: 31 +cascade: + + introduced: 0.39.0 --- -The Flux `monitor` package provides tools for monitoring and alerting with InfluxDB. + + +The `monitor` package provides tools for monitoring and alerting with InfluxDB. Import the `influxdata/influxdb/monitor` package: ```js import "influxdata/influxdb/monitor" ``` -## Options -The `monitor` packages provides the following options: +## Constants ```js -import "influxdata/influxdb/monitor" +monitor.bucket = "_monitoring" +monitor.levelCrit = "crit" +monitor.levelInfo = "info" +monitor.levelOK = "ok" +monitor.levelUnknown = "unknown" +monitor.levelWarn = "warn" +``` + +- **monitor.bucket** is the default bucket to store InfluxDB monitoring data in. +- **monitor.levelCrit** is the string representation of the "crit" level. +- **monitor.levelInfo** is the string representation of the "info" level. +- **monitor.levelOK** is the string representation of the "ok" level. +- **monitor.levelUnknown** is the string representation of the an unknown level. +- **monitor.levelWarn** is the string representation of the "warn" level. + +## Options + +```js +option monitor.log = (tables=<-) => tables |> experimental.to(bucket: bucket) option monitor.write = (tables=<-) => tables |> experimental.to(bucket: bucket) -option monitor.log = (tables=<-) => tables |> experimental.to(bucket: bucket) ``` + +### log -### write {data-type="function"} -Function option that defines how check statuses are written to InfluxDB. -Default is: +`log` persists notification events to an InfluxDB bucket. -```js -(tables=<-) => tables |> experimental.to(bucket: bucket) -``` +### write -### log {data-type="function"} -Function option that defines how notification event logs are written to InfluxDB. -Default is: +`write` persists check statuses to an InfluxDB bucket. -```js -(tables=<-) => tables |> experimental.to(bucket: bucket) -``` ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/check.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/check.md index 3513ed00c..f061cd847 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/check.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/check.md @@ -1,97 +1,167 @@ --- title: monitor.check() function description: > - The `monitor.check()` function checks input data and assigns a level - (`ok`, `info`, `warn`, or `crit`) to each row based on predicate functions. -aliases: - - /influxdb/v2.0/reference/flux/functions/monitor/check/ - - /influxdb/v2.0/reference/flux/stdlib/monitor/check/ - - /influxdb/cloud/reference/flux/stdlib/monitor/check/ + `monitor.check()` checks input data and assigns a level (`ok`, `info`, `warn`, or `crit`) + to each row based on predicate functions. menu: flux_0_x_ref: name: monitor.check - parent: monitor -weight: 202 + parent: influxdata/influxdb/monitor + identifier: influxdata/influxdb/monitor/check +weight: 301 flux/v0.x/tags: [transformations] -introduced: 0.39.0 --- -The `monitor.check()` function checks input data and assigns a level -(`ok`, `info`, `warn`, or `crit`) to each row based on predicate functions. + + +`monitor.check()` checks input data and assigns a level (`ok`, `info`, `warn`, or `crit`) +to each row based on predicate functions. `monitor.check()` stores statuses in the `_level` column and writes results to the `statuses` measurement in the `_monitoring` bucket. +##### Function type signature + +```js +( + <-tables: stream[J], + data: {A with tags: E, _type: D, _check_name: C, _check_id: B}, + messageFn: ( + r: { + F with + _type: D, + _time: H, + _time: time, + _source_timestamp: int, + _source_measurement: G, + _measurement: G, + _measurement: string, + _level: string, + _check_name: C, + _check_id: B, + }, + ) => I, + ?crit: (r: {F with _time: H, _measurement: G}) => bool, + ?info: (r: {F with _time: H, _measurement: G}) => bool, + ?ok: (r: {F with _time: H, _measurement: G}) => bool, + ?warn: (r: {F with _time: H, _measurement: G}) => bool, +) => stream[{ + F with + _type: D, + _time: H, + _time: time, + _source_timestamp: int, + _source_measurement: G, + _message: I, + _measurement: G, + _measurement: string, + _level: string, + _check_name: C, + _check_id: B, +}] where E: Record, J: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### crit {data-type="function"} -Predicate function that determines `crit` status. -Default is `(r) => false`. +### crit -### warn {data-type="function"} -Predicate function that determines `warn` status. -Default is `(r) => false`. +Predicate function that determines `crit` status. Default is `(r) => false`. -### info {data-type="function"} -Predicate function that determines `info` status. -Default is `(r) => false`. -### ok {data-type="function"} -Predicate function that determines `ok` status. -Default is `(r) => true`. -### messageFn {data-type="function"} -A function that constructs a message to append to each row. +### warn + +Predicate function that determines `warn` status. Default is `(r) => false`. + + + +### info + +Predicate function that determines `info` status. Default is `(r) => false`. + + + +### ok + +Predicate function that determines `ok` status. `Default is (r) => true`. + + + +### messageFn +({{< req >}}) +Predicate function that constructs a message to append to each row. + The message is stored in the `_message` column. -### data {data-type="record"} -Meta data used to identify this check. +### data +({{< req >}}) +Check data to append to output. used to identify this check. +This data specifies which notification rule and notification endpoint to +associate with the sent notification. +The data record must contain the following properties: + +- **\_check\_id**: check ID _(string)_ +- **\_check\_name**: check name _(string)_ +- **\_type**: check type (threshold, deadman, or custom) _(string)_ +- **tags**: Custom tags to append to output rows _(record)_ +The InfluxDB monitoring and alerting system uses `monitor.check()` to +check statuses and automatically assigns these values. +If writing a custom check task, we recommend using **unique arbitrary** +values for data record properties. + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -### Monitor disk usage +### Monitor InfluxDB disk usage collected by Telegraf + ```js import "influxdata/influxdb/monitor" from(bucket: "telegraf") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "disk" and r._field == "used_percent") - |> group(columns: ["_measurement"]) |> monitor.check( crit: (r) => r._value > 90.0, warn: (r) => r._value > 80.0, info: (r) => r._value > 70.0, ok: (r) => r._value <= 60.0, - messageFn: (r) => if r._level == "crit" then - "Critical alert!! Disk usage is at ${r._value}%!" - else if r._level == "warn" then - "Warning! Disk usage is at ${r._value}%." - else if r._level == "info" then - "Disk usage is at ${r._value}%." - else - "Things are looking good.", + messageFn: (r) => + if r._level == "crit" then + "Critical alert!! Disk usage is at ${r._value}%!" + else if r._level == "warn" then + "Warning! Disk usage is at ${r._value}%." + else if r._level == "info" then + "Disk usage is at ${r._value}%." + else + "Things are looking good.", data: { _check_name: "Disk Utilization (Used Percentage)", _check_id: "disk_used_percent", _type: "threshold", - tags: {} + tags: {}, }, ) ``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/deadman.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/deadman.md index 5442fbf36..b3df10d8b 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/deadman.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/deadman.md @@ -1,69 +1,123 @@ --- title: monitor.deadman() function description: > - The `monitor.deadman()` function detects when a group stops reporting data. -aliases: - - /influxdb/v2.0/reference/flux/functions/monitor/deadman/ - - /influxdb/v2.0/reference/flux/stdlib/monitor/deadman/ - - /influxdb/cloud/reference/flux/stdlib/monitor/deadman/ + `monitor.deadman()` detects when a group stops reporting data. + It takes a stream of tables and reports if groups have been observed since time `t`. menu: flux_0_x_ref: name: monitor.deadman - parent: monitor -weight: 202 + parent: influxdata/influxdb/monitor + identifier: influxdata/influxdb/monitor/deadman +weight: 301 flux/v0.x/tags: [transformations] -introduced: 0.39.0 --- -The `monitor.deadman()` function detects when a group stops reporting data. + + +`monitor.deadman()` detects when a group stops reporting data. It takes a stream of tables and reports if groups have been observed since time `t`. -```js -import "influxdata/influxdb/monitor" +`monitor.deadman()` retains the most recent row from each input table and adds a `dead` column. +If a record appears after time `t`, `monitor.deadman()` sets `dead` to `false`. +Otherwise, `dead` is set to `true`. -monitor.deadman(t: 2019-08-30T12:30:00Z) +##### Function type signature + +```js +(<-tables: stream[{B with _time: C}], t: A) => stream[{B with dead: bool, _time: C}] where A: Comparable, C: Comparable ``` -`monitor.deadman()` retains the most recent row from each input table and adds a `dead` column. -If a record appears **after** time `t`, `monitor.deadman()` sets `dead` to `false`. -Otherwise, `dead` is set to `true`. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### t {data-type="time"} -The time threshold for the deadman check. +### t +({{< req >}}) +Time threshold for the deadman check. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -### Detect if a host hasn't reported in the last five minutes +- [Detect if a host hasn’t reported since a specific time](#detect-if-a-host-hasnt-reported-since-a-specific-time) +- [Detect if a host hasn't reported since a relative time](#detect-if-a-host-hasnt-reported-since-a-relative-time) + +### Detect if a host hasn’t reported since a specific time + +```js +import "array" +import "influxdata/influxdb/monitor" + +data = + array.from( + rows: [ + {_time: 2021-01-01T00:00:00Z, host: "a", _value: 1.2}, + {_time: 2021-01-01T00:01:00Z, host: "a", _value: 1.3}, + {_time: 2021-01-01T00:02:00Z, host: "a", _value: 1.4}, + {_time: 2021-01-01T00:03:00Z, host: "a", _value: 1.3}, + ], + ) + |> group(columns: ["host"]) + +data + |> monitor.deadman(t: 2021-01-01T00:05:00Z) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *host | _value | +| -------------------- | ----- | ------- | +| 2021-01-01T00:00:00Z | a | 1.2 | +| 2021-01-01T00:01:00Z | a | 1.3 | +| 2021-01-01T00:02:00Z | a | 1.4 | +| 2021-01-01T00:03:00Z | a | 1.3 | + + +#### Output data + +| _time | _value | dead | *host | +| -------------------- | ------- | ----- | ----- | +| 2021-01-01T00:03:00Z | 1.3 | true | a | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Detect if a host hasn't reported since a relative time + +Use `experimental.addDuration()` to return a time value relative to a specified time. + ```js import "influxdata/influxdb/monitor" import "experimental" +// from(bucket: "example-bucket") |> range(start: -10m) - |> group(columns: ["host"]) - |> monitor.deadman(t: experimental.subDuration(d: 5m, from: now())) + |> filter(fn: (r) => r._measurement == "example-measurement") + |> monitor.deadman(t: experimental.addDuration(d: -5m, from: now())) ``` -{{< expand-wrapper >}} -{{% expand "View example input and output" %}} -##### Example input data -| _start | _stop | _time | _measurement | _host | _field | _value | -| :------------------- | :------------------- | :------------------- | :----------- | :---- | :----- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:03:00Z | 2021-01-01T00:00:00Z | example | h1 | resp | 200 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:03:00Z | 2021-01-01T00:00:30Z | example | h1 | resp | 200 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:03:00Z | 2021-01-01T00:01:00Z | example | h1 | resp | 500 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:03:00Z | 2021-01-01T00:01:30Z | example | h1 | resp | 500 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:03:00Z | 2021-01-01T00:02:00Z | example | h1 | resp | 200 | - -##### Example output data -| _start | _stop | _time | _measurement | _host | _field | _value | dead | -| :------------------- | :------------------- | :------------------- | :----------- | :---- | :----- | -----: | ---: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:03:00Z | 2021-01-01T00:02:00Z | example | h1 | resp | 200 | true | -{{% /expand %}} -{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/from.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/from.md index 59c2d7dd9..c6bf5a516 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/from.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/from.md @@ -1,63 +1,92 @@ --- title: monitor.from() function description: > - The `monitor.from()` function retrieves check statuses stored in the `statuses` - measurement in the `_monitoring` bucket. -aliases: - - /influxdb/v2.0/reference/flux/functions/monitor/from/ - - /influxdb/v2.0/reference/flux/stdlib/monitor/from/ - - /influxdb/cloud/reference/flux/stdlib/monitor/from/ + `monitor.from()` retrieves check statuses stored in the `statuses` measurement in the + `_monitoring` bucket. menu: flux_0_x_ref: name: monitor.from - parent: monitor -weight: 202 -flux/v0.x/tags: [inputs] -introduced: 0.39.0 + parent: influxdata/influxdb/monitor + identifier: influxdata/influxdb/monitor/from +weight: 301 --- -The `monitor.from()` function retrieves check statuses stored in the `statuses` -measurement in the `_monitoring` bucket. + + +`monitor.from()` retrieves check statuses stored in the `statuses` measurement in the +`_monitoring` bucket. + + + +##### Function type signature ```js -import "influxdata/influxdb/monitor" - -monitor.from( - start: -1h, - stop: now(), - fn: (r) => true, -) +( + start: A, + ?fn: ( + r: { + B with + _value: C, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, + ?stop: D, +) => stream[E] where E: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### start {data-type="duration, time, int"} -The earliest time to include in results. +### start +({{< req >}}) +Earliest time to include in results. + Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -### stop {data-type="duration, time, int"} -The latest time to include in results. +### stop + +Latest time to include in results. Default is `now()`. + Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. -Durations are relative to `now()`. -Defaults to `now()`. +Durations are relative to `now()` -{{% note %}} -Time values in Flux must be in [RFC3339 format](/flux/v0.x/spec/types#timestamp-format). -{{% /note %}} +### fn + +Predicate function that evaluates true or false. -### fn {data-type="function"} -A single argument predicate function that evaluates `true` or `false`. Records or rows (`r`) that evaluate to `true` are included in output tables. Records that evaluate to _null_ or `false` are not included in output tables. + ## Examples ### View critical check statuses from the last hour + ```js import "influxdata/influxdb/monitor" monitor.from(start: -1h, fn: (r) => r._level == "crit") ``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/log.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/log.md new file mode 100644 index 000000000..999397771 --- /dev/null +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/log.md @@ -0,0 +1,48 @@ +--- +title: monitor.log() function +description: > + `monitor.log()` persists notification events to an InfluxDB bucket. +menu: + flux_0_x_ref: + name: monitor.log + parent: influxdata/influxdb/monitor + identifier: influxdata/influxdb/monitor/log +weight: 301 +--- + + + +`monitor.log()` persists notification events to an InfluxDB bucket. + + + +##### Function type signature + +```js +(<-tables: stream[A]) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/logs.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/logs.md index d99d61b97..60d4ff9c6 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/logs.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/logs.md @@ -1,63 +1,93 @@ --- title: monitor.logs() function description: > - The `monitor.logs()` function retrieves notification events stored in the `notifications` - measurement in the `_monitoring` bucket. -aliases: - - /influxdb/v2.0/reference/flux/functions/monitor/logs/ - - /influxdb/v2.0/reference/flux/stdlib/monitor/logs/ - - /influxdb/cloud/reference/flux/stdlib/monitor/logs/ + `monitor.logs()` retrieves notification events stored in the `notifications` measurement + in the `_monitoring` bucket. menu: flux_0_x_ref: name: monitor.logs - parent: monitor -weight: 202 + parent: influxdata/influxdb/monitor + identifier: influxdata/influxdb/monitor/logs +weight: 301 flux/v0.x/tags: [inputs] -introduced: 0.39.0 --- -The `monitor.logs()` function retrieves notification events stored in the `notifications` -measurement in the `_monitoring` bucket. + + +`monitor.logs()` retrieves notification events stored in the `notifications` measurement +in the `_monitoring` bucket. + + + +##### Function type signature ```js -import "influxdata/influxdb/monitor" - -monitor.logs( - start: -1h, - stop: now(), - fn: (r) => true, -) +( + fn: ( + r: { + A with + _value: B, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, + start: C, + ?stop: D, +) => stream[E] where E: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### start {data-type="duration, time, int"} -The earliest time to include in results. +### start +({{< req >}}) +Earliest time to include in results. + Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -### stop {data-type="duration, time, int"} -The latest time to include in results. +### stop + +Latest time to include in results. Default is `now()`. + Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -Defaults to `now()`. -{{% note %}} -Time values in Flux must be in [RFC3339 format](/flux/v0.x/spec/types#timestamp-format). -{{% /note %}} +### fn +({{< req >}}) +Predicate function that evaluates true or false. -### fn {data-type="function"} -A single argument predicate function that evaluates `true` or `false`. Records or rows (`r`) that evaluate to `true` are included in output tables. Records that evaluate to _null_ or `false` are not included in output tables. + ## Examples ### Query notification events from the last hour + ```js import "influxdata/influxdb/monitor" monitor.logs(start: -2h, fn: (r) => true) ``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/notify.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/notify.md index 648562676..13e91e72c 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/notify.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/notify.md @@ -1,64 +1,84 @@ --- title: monitor.notify() function description: > - The `monitor.notify()` function sends a notification to an endpoint and logs it - in the `notifications` measurement in the `_monitoring` bucket. -aliases: - - /influxdb/v2.0/reference/flux/functions/monitor/notify/ - - /influxdb/v2.0/reference/flux/stdlib/monitor/notify/ - - /influxdb/cloud/reference/flux/stdlib/monitor/notify/ + `monitor.notify()` sends a notification to an endpoint and logs it in the `notifications` + measurement in the `_monitoring` bucket. menu: flux_0_x_ref: name: monitor.notify - parent: monitor -weight: 202 -introduced: 0.39.0 + parent: influxdata/influxdb/monitor + identifier: influxdata/influxdb/monitor/notify +weight: 301 --- -The `monitor.notify()` function sends a notification to an endpoint and logs it -in the `notifications` measurement in the [`_monitoring` bucket](/influxdb/cloud/reference/internals/system-buckets/#monitoring-system-bucket). + + +`monitor.notify()` sends a notification to an endpoint and logs it in the `notifications` +measurement in the `_monitoring` bucket. + + + +##### Function type signature ```js -import "influxdata/influxdb/monitor" - -monitor.notify( - endpoint: endpoint, - data: {}, -) +( + <-tables: stream[E], + data: A, + endpoint: (<-: stream[{B with _time: C, _time: time, _status_timestamp: int, _measurement: string}]) => stream[D], +) => stream[D] where A: Record, D: Record, E: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### endpoint {data-type="function"} -({{< req >}}) A function that constructs and sends the notification to an endpoint. +### endpoint +({{< req >}}) +A function that constructs and sends the notification to an endpoint. -### data {data-type="record"} -({{< req >}}) Notification data to append to the output. -This data specifies which notification rule and notification endpoint to associate -with the sent notification. -The data record must contain the following fields: -- _notification_rule_id -- _notification_rule_name -- _notification_endpoint_id -- _notification_endpoint_name +### data +({{< req >}}) +Notification data to append to the output. +This data specifies which notification rule and notification endpoint to +associate with the sent notification. +The data record must contain the following properties: +- \_notification\_rule\_id +- \_notification\_rule\_name +- \_notification\_endpoint\_id +- \_notification\_endpoint\_name The InfluxDB monitoring and alerting system uses `monitor.notify()` to store information about sent notifications and automatically assigns these values. -If writing a custom notification [task](/influxdb/cloud/process-data/), -we recommend using **unique arbitrary values** for data record fields. +If writing a custom notification task, we recommend using **unique arbitrary** +values for data record properties. + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -- [Send a notification to Slack](#send-a-notification-to-slack) -- [Send a notification to PagerDuty](#send-a-notification-to-pagerduty) +### Send critical status notifications to Slack -### Send a notification to Slack ```js import "influxdata/influxdb/monitor" import "influxdata/influxdb/secrets" @@ -72,45 +92,11 @@ notification_data = { _notification_rule_id: "0000000000000001", _notification_rule_name: "example-rule-name", _notification_endpoint_id: "0000000000000002", - _notification_endpoint_name: "example-endpoint-name" + _notification_endpoint_name: "example-endpoint-name", } -from(bucket: "system") +monitor.from(range: -5m, fn: (r) => r._level == "crit") |> range(start: -5m) |> monitor.notify(endpoint: endpoint, data: notification_data) ``` -### Send a notification to PagerDuty -```js -import "influxdata/influxdb/monitor" -import "influxdata/influxdb/secrets" -import "pagerduty" - -routingKey = secrets.get(key: "PAGERDUTY_ROUTING_KEY") - -endpoint = pagerduty.endpoint()( - mapFn: (r) => ({ - routingKey: routingKey, - client: "ExampleClient", - clientURL: "http://examplepagerdutyclient.com", - dedupkey: "ExampleDedupKey", - class: "cpu usage", - group: "app-stack", - severity: "ok", - eventAction: "trigger", - source: "monitoringtool:vendor:region", - timestamp: r._source_timestamp, - }), -) - -notification_data = { - _notification_rule_id: "0000000000000001", - _notification_rule_name: "example-rule-name", - _notification_endpoint_id: "0000000000000002", - _notification_endpoint_name: "example-endpoint-name" -} - -from(bucket: "system") - |> range(start: -5m) - |> monitor.notify(endpoint: endpoint, data: notification_data) -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechanges.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechanges.md index 11eb257a0..8e5acd372 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechanges.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechanges.md @@ -1,74 +1,108 @@ --- title: monitor.stateChanges() function description: > - The `monitor.stateChanges()` function detects state changes in a stream of tables and - outputs records that change from `fromLevel` to `toLevel`. -aliases: - - /influxdb/v2.0/reference/flux/functions/monitor/statechanges/ - - /influxdb/v2.0/reference/flux/stdlib/monitor/statechanges/ - - /influxdb/cloud/reference/flux/stdlib/monitor/statechanges/ + `monitor.stateChanges()` detects state changes in a stream of data with a `_level` column + and outputs records that change from `fromLevel` to `toLevel`. menu: flux_0_x_ref: name: monitor.stateChanges - parent: monitor -weight: 202 + parent: influxdata/influxdb/monitor + identifier: influxdata/influxdb/monitor/stateChanges +weight: 301 flux/v0.x/tags: [transformations] introduced: 0.42.0 --- -The `monitor.stateChanges()` function detects state changes in a stream of data with -a `_level` column and outputs records that change from `fromLevel` to `toLevel`. + + +`monitor.stateChanges()` detects state changes in a stream of data with a `_level` column +and outputs records that change from `fromLevel` to `toLevel`. + + + +##### Function type signature ```js -import "influxdata/influxdb/monitor" - -monitor.stateChanges( - fromLevel: "any", - toLevel: "any", -) +(<-tables: stream[{C with _level: D}], ?fromLevel: A, ?toLevel: B) => stream[E] where A: Equatable, B: Equatable, D: Equatable, E: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### fromLevel {data-type="string"} -The level to detect a change from. -Defaults to `"any"`. +### fromLevel + +Level to detect a change from. Default is `"any"`. + + + +### toLevel + +Level to detect a change to. Default is `"any"`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + -### toLevel {data-type="string"} -The level to detect a change to. -The function output records that change to this level. -Defaults to `"any"`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -##### Detect when the state changes to critical +### Detect when the state changes to critical + ```js +import "array" import "influxdata/influxdb/monitor" -monitor.from(start: -1h) +data = + array.from( + rows: [ + {_time: 2021-01-01T00:00:00Z, _level: "ok"}, + {_time: 2021-01-01T00:01:00Z, _level: "ok"}, + {_time: 2021-01-01T00:02:00Z, _level: "warn"}, + {_time: 2021-01-01T00:03:00Z, _level: "crit"}, + ], + ) + +data |> monitor.stateChanges(toLevel: "crit") ``` -{{< flex >}} -{{% flex-content %}} -##### Example input data +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| _time | _level | -| :------------------- | :----: | -| 2021-01-01T00:00:00Z | ok | -| 2021-01-01T00:10:00Z | ok | -| 2021-01-01T00:20:00Z | warn | -| 2021-01-01T00:30:00Z | crit | -{{% /flex-content %}} -{{% flex-content %}} -##### Example output data +#### Input data -| _time | _level | -| :------------------- | :----: | -| 2021-01-01T00:30:00Z | crit | -{{% /flex-content %}} -{{< /flex >}} +| _time | _level | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | ok | +| 2021-01-01T00:01:00Z | ok | +| 2021-01-01T00:02:00Z | warn | +| 2021-01-01T00:03:00Z | crit | + + +#### Output data + +| _time | *_level | +| -------------------- | ------- | +| 2021-01-01T00:03:00Z | crit | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechangesonly.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechangesonly.md index 45f1cd20b..fb421e69b 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechangesonly.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechangesonly.md @@ -1,64 +1,102 @@ --- title: monitor.stateChangesOnly() function description: > - The `monitor.stateChangesOnly()` function takes a stream of tables that contains a `_level` - column and returns a stream of tables where each record represents a state change. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/monitor/statechangesonly/ - - /influxdb/cloud/reference/flux/stdlib/monitor/statechangesonly/ - - /cloud/reference/flux/stdlib/monitor/statechangesonly/ + `monitor.stateChangesOnly()` takes a stream of tables that contains a _level column + and returns a stream of tables grouped by `_level` where each record + represents a state change. menu: flux_0_x_ref: name: monitor.stateChangesOnly - parent: monitor -weight: 202 + parent: influxdata/influxdb/monitor + identifier: influxdata/influxdb/monitor/stateChangesOnly +weight: 301 flux/v0.x/tags: [transformations] introduced: 0.65.0 --- -The `monitor.stateChangesOnly()` function takes a stream of tables that contains a `_level` -column and returns a stream of tables where each record represents a state change. + + +`monitor.stateChangesOnly()` takes a stream of tables that contains a _level column +and returns a stream of tables grouped by `_level` where each record +represents a state change. + + + +##### Function type signature ```js -import "influxdata/influxdb/monitor" - -monitor.stateChangesOnly() +(<-tables: stream[{A with _level: B}]) => stream[C] where B: Equatable, C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -##### Return records representing state changes +### Return records representing state changes + ```js +import "array" import "influxdata/influxdb/monitor" -monitor.from(start: -1h) +data = + array.from( + rows: [ + {_time: 2021-01-01T00:00:00Z, _level: "ok"}, + {_time: 2021-01-01T00:01:00Z, _level: "ok"}, + {_time: 2021-01-01T00:02:00Z, _level: "warn"}, + {_time: 2021-01-01T00:03:00Z, _level: "crit"}, + ], + ) + +data |> monitor.stateChangesOnly() ``` -{{< flex >}} -{{% flex-content %}} -##### Example input data +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| _time | _level | -|:----- |:------:| -| 0001 | ok | -| 0002 | ok | -| 0003 | warn | -| 0004 | crit | -{{% /flex-content %}} -{{% flex-content %}} -##### Example output data +#### Input data -| _time | _level | -|:----- |:------:| -| 0002 | ok | -| 0003 | warn | -| 0004 | crit | -{{% /flex-content %}} -{{< /flex >}} +| _time | _level | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | ok | +| 2021-01-01T00:01:00Z | ok | +| 2021-01-01T00:02:00Z | warn | +| 2021-01-01T00:03:00Z | crit | + + +#### Output data + +| _time | *_level | +| -------------------- | ------- | +| 2021-01-01T00:03:00Z | crit | + +| _time | *_level | +| -------------------- | ------- | +| 2021-01-01T00:02:00Z | warn | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/write.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/write.md new file mode 100644 index 000000000..6ab21dd06 --- /dev/null +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/write.md @@ -0,0 +1,48 @@ +--- +title: monitor.write() function +description: > + `monitor.write()` persists check statuses to an InfluxDB bucket. +menu: + flux_0_x_ref: + name: monitor.write + parent: influxdata/influxdb/monitor + identifier: influxdata/influxdb/monitor/write +weight: 301 +--- + + + +`monitor.write()` persists check statuses to an InfluxDB bucket. + + + +##### Function type signature + +```js +(<-tables: stream[A]) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/sample/_index.md b/content/flux/v0.x/stdlib/influxdata/influxdb/sample/_index.md index 374240f15..e4c12454c 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/sample/_index.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/sample/_index.md @@ -1,28 +1,44 @@ --- -title: Flux InfluxDB sample package -list_title: sample package +title: sample package description: > - The Flux InfluxDB `sample` package provides functions for downloading and outputting InfluxDB data sample. - Import the `influxdata/influxdb/sample` package. + The `sample` package provides functions for downloading and ouputting InfluxDB sample datasets. menu: flux_0_x_ref: - name: sample - identifier: sample-pkg - parent: influxdb-pkg -weight: 202 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/influxdb-sample - - /influxdb/cloud/reference/flux/stdlib/influxdb-sample -flux/v0.x/tags: [functions, sample data, package] -introduced: 0.123.0 + name: sample + parent: influxdata/influxdb + identifier: influxdata/influxdb/sample +weight: 31 +cascade: + flux/v0.x/tags: [sample data] + introduced: 0.123.0 --- -The Flux InfluxDB `sample` package provides functions for downloading and outputting InfluxDB data sample. + + +The `sample` package provides functions for downloading and ouputting InfluxDB sample datasets. Import the `influxdata/influxdb/sample` package: ```js import "influxdata/influxdb/sample" ``` + + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/sample/aligntonow.md b/content/flux/v0.x/stdlib/influxdata/influxdb/sample/aligntonow.md index d56f21b34..d80cb00fd 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/sample/aligntonow.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/sample/aligntonow.md @@ -5,50 +5,61 @@ description: > menu: flux_0_x_ref: name: sample.alignToNow - parent: sample-pkg + parent: influxdata/influxdb/sample + identifier: influxdata/influxdb/sample/alignToNow weight: 301 -related: - - /influxdb/v2.0/reference/sample-data/ -introduced: 0.132.0 +flux/v0.x/tags: [transformations] --- + + `sample.alignToNow()` shifts time values in input data to align the chronological last point to _now_. + +When writing static historical sample datasets to **InfluxDB Cloud**, use `alignToNow()` +to avoid losing sample data with timestamps outside of the retention period +associated with your InfluxDB Cloud account. + Input data must have a `_time` column. -{{% note %}} -When writing static historical sample datasets to **InfluxDB Cloud**, -use `sample.alignToNow()` to avoid losing sample data with timestamps outside -of the retention period associated with your InfluxDB Cloud account. -{{% /note %}} +##### Function type signature + +```js +(<-tables: stream[A]) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Defaults to piped-forward data (`<-`). + + + ## Examples -#### Align sample data timestamps to the current time +### Align sample data to now + ```js import "influxdata/influxdb/sample" -option now = () => 2021-01-01T00:00:00Z - -data = sample.data(set: "birdMigration") - |> filter(fn: (r) => r._field == "lon" and r.s2_cell_id == "471ed2c" and r.id == "91916A") - |> tail(n: 3) - -data +sample.data(set: "birdMigration") |> sample.alignToNow() ``` -{{% expand "View input and output" %}} -#### Input data -| _time | _measurement | id | s2_cell_id | _field | _value | -| :------------------- | :----------- | :----- | :--------- | :----- | -------: | -| 2019-09-19T15:00:00Z | migration | 91916A | 471ed2c | lon | 21.10333 | -| 2019-09-22T09:00:00Z | migration | 91916A | 471ed2c | lon | 21.084 | -| 2019-09-22T15:00:00Z | migration | 91916A | 471ed2c | lon | 21.10317 | - -#### Output data -| _time | _measurement | id | s2_cell_id | _field | _value | -| :------------------- | :----------- | :----- | :--------- | :----- | -------: | -| 2020-12-29T00:00:00Z | migration | 91916A | 471ed2c | lon | 21.10333 | -| 2020-12-31T18:00:00Z | migration | 91916A | 471ed2c | lon | 21.084 | -| 2021-01-01T00:00:00Z | migration | 91916A | 471ed2c | lon | 21.10317 | -{{% /expand %}} \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/sample/data.md b/content/flux/v0.x/stdlib/influxdata/influxdb/sample/data.md index 1869be938..2aecd45ce 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/sample/data.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/sample/data.md @@ -1,133 +1,55 @@ --- title: sample.data() function description: > - The `sample.data()` function downloads and outputs an InfluxDB sample dataset. + `sample.data()` downloads a specified InfluxDB sample dataset. menu: flux_0_x_ref: name: sample.data - parent: sample-pkg + parent: influxdata/influxdb/sample + identifier: influxdata/influxdb/sample/data weight: 301 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/influxdb-sample/data - - /influxdb/cloud/reference/flux/stdlib/influxdb-sample/data -related: - - /influxdb/v2.0/reference/sample-data/ -flux/v0.x/tags: [sample data, inputs] -introduced: 0.123.0 --- -The `sample.data()` function downloads and outputs an InfluxDB sample dataset. + + +`sample.data()` downloads a specified InfluxDB sample dataset. + + + +##### Function type signature ```js -import "influxdata/influxdb/sample" - -sample.data(set: "airSensor") +(set: string) => stream[A] where A: Record ``` -{{% note %}} -#### Network bandwidth -Each execution of `sample.data()` downloads the specified dataset from **Amazon S3**. -If using [InfluxDB Cloud](/influxdb/cloud/) or a hosted InfluxDB OSS instance, -you may see additional network bandwidth costs when using this function. -Approximate sample dataset sizes are listed [below](#available-influxdb-sample-datasets) -and in the output of [`sample.list()`](/flux/v0.x/stdlib/influxdata/influxdb/sample/list/). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### set {data-type="string"} -({{< req >}}) InfluxDB sample dataset to download and output. +### set +({{< req >}}) +Sample data set to download and output. -**Valid values**: +Valid datasets: +- **airSensor**: Simulated temperature, humidity, and CO data from an office building. +- **birdMigration**: 2019 African bird migration data from [Movebank: Animal Tracking](https://www.kaggle.com/pulkit8595/movebank-animal-tracking). +- **bitcoin**: Bitcoin price data from the last 30 days _([Powered by CoinDesk](https://www.coindesk.com/price/bitcoin))_. +- **noaa**: Latest observations from the [NOAA National Data Buoy Center (NDBC)](https://www.ndbc.noaa.gov/). +- **machineProduction**: States and metrics reported from four automated grinding wheel stations on a production line. +- **noaaWater**: Water level observations from two stations reported by the NOAA Center for Operational Oceanographic Products and Services between 2019-08-17 and 2019-09-17. +- **usgs**: USGS earthquake data from the last week. -- [`airSensor`](#airsensor) -- [`birdMigration`](#birdmigration) -- [`bitcoin`](#bitcoin) -- [`machineProduction`](#machineproduction) -- [`noaa`](#noaa) -- [`noaaWater`](#noaawater) -- [`usgs`](#usgs) - -## Available InfluxDB sample datasets - -### airSensor - -Simulated office building air sensor data with temperature, -humidity, and carbon monoxide metrics. - -{{% caption %}} -**Size**: ~600 KB • **Updated**: every 15m -{{% /caption %}} - -### birdMigration - -2019 African bird migration data from the -[Movebank: Animal Tracking](https://www.kaggle.com/pulkit8595/movebank-animal-tracking) dataset. -Contains geotemporal data between 2019-01-01 and 2019-12-31. - -{{% caption %}} -**Size**: ~1.2 MB • **Updated**: N/A -{{% /caption %}} - -### bitcoin - -Bitcoin price data from the last 30 days ([Powered by CoinDesk](https://www.coindesk.com/price/bitcoin)). -Data is updated approximately every 15m. - -{{% caption %}} -**Size**: ~700 KB • **Updated**: every 15m -{{% /caption %}} - -### machineProduction - -States and metrics reported from four automated grinding wheel stations on a production line. -Contains data from 2021-08-01T00:00:00Z to 2021-08-01T23:59:59Z. - -{{% caption %}} -**Size**: ~11.9 MB • **Updated**: N/A -{{% /caption %}} - -### noaa - -Latest observations from the [NOAA National Data Buoy Center (NDBC)](https://www.ndbc.noaa.gov/). -Contains only the most recent observations (no historical data). -Data is updated approximately every 15m. - -{{% caption %}} -**Size**: ~1.3 MB • **Updated**: every 15m -{{% /caption %}} - -### noaaWater - -Water level observations from two stations reported by the NOAA Center for -Operational Oceanographic Products and Services. -Contains data between 2019-08-17 and 2019-09-17. - -{{% caption %}} -**Size**: ~10.3 MB • **Updated**: N/A -{{% /caption %}} - -### usgs - -USGS earthquake data from the last week. -Contains geotemporal data collected from USGS seismic sensors around the world. -Data is updated approximately every 15m. - -{{% caption %}} -**Size**: ~6 MB • **Updated**: every 15m -{{% /caption %}} - -## Examples - -#### Return USGS earthquake data from the last week -```js -import "influxdata/influxdb/sample" - -sample.data(set: "usgs") -``` - -#### Download and write NOAA NDBC data to InfluxDB -Add the following as an [InfluxDB task](/{{< latest "influxdb" >}}/process-data/) -to regularly collect the latest reported observations from the NOAA NDBC. - -{{% get-shared-text "flux/noaa-ndbc-sample-task.md" %}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/sample/list.md b/content/flux/v0.x/stdlib/influxdata/influxdb/sample/list.md index ccaca9de7..a5d554c1d 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/sample/list.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/sample/list.md @@ -1,24 +1,59 @@ --- title: sample.list() function description: > - The `sample.list()` function outputs information about available InfluxDB sample datasets. + `sample.list()` outputs information about available InfluxDB sample datasets. menu: flux_0_x_ref: name: sample.list - parent: sample-pkg + parent: influxdata/influxdb/sample + identifier: influxdata/influxdb/sample/list weight: 301 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/influxdb-sample/list - - /influxdb/cloud/reference/flux/stdlib/influxdb-sample/list -related: - - /influxdb/v2.0/reference/sample-data/ -introduced: 0.123.0 --- -The `sample.list()` function outputs information about available InfluxDB sample datasets. + + +`sample.list()` outputs information about available InfluxDB sample datasets. + + + +##### Function type signature + +```js +( + +) => stream[{ + url: string, + type: string, + size: string, + name: string, + description: string, +}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + + +## Examples + +### List available InfluxDB sample datasets ```js import "influxdata/influxdb/sample" sample.list() ``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/_index.md b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/_index.md index e01f71b3b..dfe58d14f 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/_index.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/_index.md @@ -1,36 +1,44 @@ --- -title: Flux InfluxDB schema package -list_title: schema package +title: schema package description: > - The Flux InfluxDB `schema` package provides functions for exploring your InfluxDB data schema. - Import the `influxdata/influxdb/schema` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/ + The `schema` package provides functions for exploring your InfluxDB data schema. menu: flux_0_x_ref: - name: schema - parent: influxdb-pkg -weight: 202 -flux/v0.x/tags: [functions, schema, package] + name: schema + parent: influxdata/influxdb + identifier: influxdata/influxdb/schema +weight: 31 cascade: + introduced: 0.88.0 - append: - block: warn - content: | - #### Not supported in the Flux REPL - `schema` functions can retrieve schema information when executed within - the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). --- -The Flux InfluxDB `schema` package provides functions for exploring your InfluxDB data schema. + + +The `schema` package provides functions for exploring your InfluxDB data schema. Import the `influxdata/influxdb/schema` package: ```js import "influxdata/influxdb/schema" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldkeys.md b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldkeys.md index e6221ecdb..05f30b62c 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldkeys.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldkeys.md @@ -1,87 +1,101 @@ --- title: schema.fieldKeys() function -description: The `schema.fieldKeys()` function returns field keys in a bucket. +description: > + `schema.fieldKeys()` returns field keys in a bucket. menu: flux_0_x_ref: name: schema.fieldKeys - parent: schema + parent: influxdata/influxdb/schema + identifier: influxdata/influxdb/schema/fieldKeys weight: 301 flux/v0.x/tags: [metadata] -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/fieldkeys - - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/fieldkeys/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/fieldkeys/ -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-field-keys, SHOW FIELD KEYS in InfluxQL -introduced: 0.88.0 --- -The `schema.fieldKeys()` function returns [field keys](/{{< latest "influxdb" >}}/reference/glossary/#field-key) in a bucket. -The return value is always a single table with a single column, `_value`. + + +`schema.fieldKeys()` returns field keys in a bucket. + +Results include a single table with a single column, `_value`. + +**Note**: FieldKeys is a special application of `tagValues that returns field +keys in a given bucket. + +##### Function type signature ```js -import "influxdata/influxdb/schema" - -schema.fieldKeys( - bucket: "example-bucket", - predicate: (r) => true, - start: -30d, -) +( + bucket: string, + ?predicate: ( + r: { + A with + _value: B, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, + ?start: C, + ?stop: D, +) => stream[E] where E: Record ``` -{{% note %}} -#### Deleted fields -Fields [deleted from InfluxDB Cloud using the `/api/v2/delete` endpoint or the `influx delete` command](/influxdb/cloud/write-data/delete-data/) -**do not** appear in results. - -#### Expired fields -- **InfluxDB Cloud**: field keys associated with points outside of the bucket's - retention policy **may** appear in results up to an hour after expiring. -- **InfluxDB OSS**: field keys associated with points outside of the bucket's - retention policy **may** appear in results. - For more information, see [Data retention in InfluxDB OSS](/{{< latest "influxdb" >}}/reference/internals/data-retention/). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to list field keys from. -### predicate {data-type="function"} + + +### predicate + Predicate function that filters field keys. -_Default is `(r) => true`._ +Default is `(r) => true`. -### start {data-type="duration, time"} -Earliest time to include in results. -_Default is `-30d`._ -Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). -### stop {data-type="duration, time"} -Latest time to include in results. -_Default is `now()`._ +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. -The `stop` time is exclusive, meaning values with a time equal to stop time are -excluded from results. Relative start times are defined using negative durations. Negative durations are relative to `now()`. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). +Absolute start times are defined using time values. + ## Examples -### Return all field keys in a bucket +### Query field keys from an InfluxDB bucket + ```js import "influxdata/influxdb/schema" schema.fieldKeys(bucket: "example-bucket") ``` -### Return all field keys in a bucket from a non-default time range -```js -import "influxdata/influxdb/schema" - -schema.fieldKeys(bucket: "example-bucket", start: -90d, stop: -60d) -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols.md b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols.md index f1c5b0b79..6d1f0b00e 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols.md @@ -1,76 +1,93 @@ --- title: schema.fieldsAsCols() function -description: The schema.fieldsAsCols() function pivots a table to automatically align fields within each input table that have the same timestamp. -aliases: - - /influxdb/v2.0/reference/flux/functions/inputs/fromrows - - /influxdb/v2.0/reference/flux/functions/transformations/influxfieldsascols - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/fieldsascols/ - - /influxdb/v2.0/reference/flux/functions/influxdb-schema/fieldsascols/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/fieldsascols/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/fieldsascols/ +description: > + `schema.fieldsAsCols()` is a special application of `pivot()` that pivots input data + on `_field` and `_time` columns to align fields within each input table that + have the same timestamp. menu: flux_0_x_ref: name: schema.fieldsAsCols - parent: schema + parent: influxdata/influxdb/schema + identifier: influxdata/influxdb/schema/fieldsAsCols weight: 301 flux/v0.x/tags: [transformations] -introduced: 0.88.0 --- -The `schema.fieldsAsCols()` function is a special application of the -[`pivot()`](/flux/v0.x/stdlib/universe/pivot/) -function that pivots on `_field` and `_time` columns to aligns fields within each -input table that have the same timestamp. + + +`schema.fieldsAsCols()` is a special application of `pivot()` that pivots input data +on `_field` and `_time` columns to align fields within each input table that +have the same timestamp. + + + +##### Function type signature ```js -import "influxdata/influxdb/schema" - -schema.fieldsAsCols() +(<-tables: stream[A]) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Pivot InfluxDB fields into columns + ```js import "influxdata/influxdb/schema" -from(bucket:"example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "cpu") +data |> schema.fieldsAsCols() ``` {{< expand-wrapper >}} -{{% expand "View example input and output" %}} +{{% expand "View example input and ouput" %}} -_`_start` and `_stop` columns have been omitted._ +#### Input data -##### Example input data -| _measurement | _host | _time | _field | _value | -| :----------- | :---- | :------------------- | :------ | -----: | -| example | h1 | 2021-01-01T00:00:00Z | resp_ms | 43 | -| example | h1 | 2021-01-01T00:00:30Z | resp_ms | 52 | -| example | h1 | 2021-01-01T00:01:00Z | resp_ms | 30000 | -| example | h1 | 2021-01-01T00:01:30Z | resp_ms | 49 | +| _time | *_measurement | *loc | *_field | _value | +| -------------------- | ------------- | ------- | ------- | ------- | +| 2021-01-01T12:00:00Z | m | Seattle | hum | 89.2 | +| 2021-01-02T12:00:00Z | m | Seattle | hum | 90.5 | +| 2021-01-03T12:00:00Z | m | Seattle | hum | 81.0 | -| _measurement | _host | _time | _field | _value | -| :----------- | :---- | :------------------- | :-------- | -----: | -| example | h1 | 2021-01-01T00:00:00Z | resp_code | 200 | -| example | h1 | 2021-01-01T00:00:30Z | resp_code | 200 | -| example | h1 | 2021-01-01T00:01:00Z | resp_code | 500 | -| example | h1 | 2021-01-01T00:01:30Z | resp_code | 200 | +| _time | *_measurement | *loc | *_field | _value | +| -------------------- | ------------- | ------- | ------- | ------- | +| 2021-01-01T12:00:00Z | m | Seattle | temp | 73.1 | +| 2021-01-02T12:00:00Z | m | Seattle | temp | 68.2 | +| 2021-01-03T12:00:00Z | m | Seattle | temp | 61.4 | -##### Example output data -| _measurement | _host | _time | resp_ms | resp_code | -| :----------- | :---- | :------------------- | ------: | --------: | -| example | h1 | 2021-01-01T00:00:00Z | 43 | 200 | -| example | h1 | 2021-01-01T00:00:30Z | 52 | 200 | -| example | h1 | 2021-01-01T00:01:00Z | 30000 | 500 | -| example | h1 | 2021-01-01T00:01:30Z | 49 | 200 | + +#### Output data + +| _time | *_measurement | *loc | hum | temp | +| -------------------- | ------------- | ------- | ---- | ----- | +| 2021-01-01T12:00:00Z | m | Seattle | 89.2 | 73.1 | +| 2021-01-02T12:00:00Z | m | Seattle | 90.5 | 68.2 | +| 2021-01-03T12:00:00Z | m | Seattle | 81.0 | 61.4 | {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys.md b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys.md index 5191ea780..dcbdb73d4 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys.md @@ -1,86 +1,82 @@ --- title: schema.measurementFieldKeys() function -description: The `schema.measurementFieldKeys()` function returns a list of fields in a measurement. +description: > + `schema.measurementFieldKeys()` returns a list of fields in a measurement. menu: flux_0_x_ref: name: schema.measurementFieldKeys - parent: schema + parent: influxdata/influxdb/schema + identifier: influxdata/influxdb/schema/measurementFieldKeys weight: 301 flux/v0.x/tags: [metadata] -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementfieldkeys/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/measurementfieldkeys/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/measurementfieldkeys/ -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-field-keys, SHOW FIELD KEYS in InfluxQL -introduced: 0.88.0 --- -The `schema.measurementFieldKeys()` function returns a list of fields in a measurement. -The return value is always a single table with a single column, `_value`. + + +`schema.measurementFieldKeys()` returns a list of fields in a measurement. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/schema" - -schema.measurementFieldKeys( - bucket: "example-bucket", - measurement: "example-measurement", - start: -30d, -) +(bucket: string, measurement: A, ?start: B, ?stop: C) => stream[D] where A: Equatable, D: Record ``` -{{% note %}} -#### Deleted fields -Fields [explicitly deleted from InfluxDB Cloud](/influxdb/cloud/write-data/delete-data/) -**do not** appear in results. - -#### Expired fields -- **InfluxDB Cloud**: field keys associated with points outside of the bucket's - retention policy **may** appear in results up to an hour after expiring. -- **InfluxDB OSS**: field keys associated with points outside of the bucket's - retention policy **may** appear in results. - For more information, see [Data retention in InfluxDB OSS](/{{< latest "influxdb" >}}/reference/internals/data-retention/). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to retrieve field keys from. -### measurement {data-type="string"} + + +### measurement +({{< req >}}) Measurement to list field keys from. -### start {data-type="duration, time"} -Earliest time to include in results. -_Defaults to `-30d`._ -Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). -### stop {data-type="duration, time"} -Latest time to include in results. -_Default is `now()`._ +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. -The `stop` time is exclusive, meaning values with a time equal to stop time are -excluded from results. Relative start times are defined using negative durations. Negative durations are relative to `now()`. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). +Absolute start times are defined using time values. + ## Examples -### Return all field keys in a measurement +### Query field keys from an InfluxDB measurement + ```js import "influxdata/influxdb/schema" -schema.measurementFieldKeys(bucket: "example-bucket", measurement: "example-measurement") +schema.measurementFieldKeys(bucket: "example-bucket", measurement: "example-measurement") ``` -### Return all field keys in a measurement from a non-default time range -```js -import "influxdata/influxdb/schema" - -schema.measurementFieldKeys(bucket: "example-bucket", measurement: "example-measurement", start: -90d, stop: -60d) -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurements.md b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurements.md index 001988e50..3ac590894 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurements.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurements.md @@ -1,24 +1,70 @@ --- title: schema.measurements() function -description: The schema.measurements() function returns a list of measurements in a specific bucket. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurements/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/measurements/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/measurements/ +description: > + `schema.measurements()` returns a list of measurements in a specific bucket. menu: flux_0_x_ref: name: schema.measurements - parent: schema + parent: influxdata/influxdb/schema + identifier: influxdata/influxdb/schema/measurements weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-measurements, SHOW MEASUREMENTS in InfluxQL -introduced: 0.88.0 --- -The `schema.measurements()` function returns a list of measurements in a specific bucket. -The return value is always a single table with a single column, `_value`. + + +`schema.measurements()` returns a list of measurements in a specific bucket. + +Results include a single table with a single column, `_value`. + +##### Function type signature + +```js +(bucket: string, ?start: A, ?stop: B) => stream[C] where C: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### bucket +({{< req >}}) +Bucket to retrieve measurements from. + + + +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. + + + + +## Examples + +### Return a list of measurements in an InfluxDB bucket ```js import "influxdata/influxdb/schema" @@ -26,41 +72,3 @@ import "influxdata/influxdb/schema" schema.measurements(bucket: "example-bucket") ``` -## Parameters - -### bucket {data-type="string"} -Bucket to retrieve measurements from. - -### start {data-type="duration, time"} -Earliest time to include in results. -_Default is `-30d`._ - -Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). - -### stop {data-type="duration, time"} -Latest time to include in results. -_Default is `now()`._ - -The `stop` time is exclusive, meaning values with a time equal to stop time are -excluded from results. -Relative start times are defined using negative durations. -Negative durations are relative to `now()`. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). - -## Examples - -### Return all measurements in a bucket -```js -import "influxdata/influxdb/schema" - -measurements(bucket: "example-bucket") -``` - -### Return all measurements in a bucket from a non-default time range -```js -import "influxdata/influxdb/schema" - -measurements(bucket: "example-bucket", start: -90d, stop: -60d) -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys.md b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys.md index 8010e2408..c7ebe44b3 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys.md @@ -1,85 +1,80 @@ --- title: schema.measurementTagKeys() function -description: The schema.measurementTagKeys() function returns a list of tag keys for a specific measurement. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementtagkeys/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/measurementtagkeys/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/measurementtagkeys/ +description: > + `schema.measurementTagKeys()` returns the list of tag keys for a specific measurement. menu: flux_0_x_ref: name: schema.measurementTagKeys - parent: schema + parent: influxdata/influxdb/schema + identifier: influxdata/influxdb/schema/measurementTagKeys weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-keys, SHOW TAG KEYS in InfluxQL -introduced: 0.88.0 --- -The `schema.measurementTagKeys()` function returns a list of tag keys for a specific measurement. -The return value is always a single table with a single column, `_value`. + + +`schema.measurementTagKeys()` returns the list of tag keys for a specific measurement. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/schema" - -schema.measurementTagKeys( - bucket: "example-bucket", - measurement: "cpu", -) +(bucket: string, measurement: A, ?start: B, ?stop: C) => stream[D] where A: Equatable, D: Record ``` -{{% note %}} -#### Deleted tags -Tags [explicitly deleted from InfluxDB](/{{< latest "influxdb" >}}/write-data/delete-data/) -**do not** appear in results. - -#### Expired tags -- **InfluxDB Cloud**: tags associated with points outside of the bucket's - retention policy **may** appear in results up to an hour after expiring. -- **InfluxDB OSS**: tags associated with points outside of the bucket's - retention policy **may** appear in results. - For more information, see [Data retention in InfluxDB OSS](/{{< latest "influxdb" >}}/reference/internals/data-retention/). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to return tag keys from for a specific measurement. -### measurement {data-type="string"} + + +### measurement +({{< req >}}) Measurement to return tag keys from. -### start {data-type="duration, time"} -Earliest time to include in results. -_Default is `-30d`._ -Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). -### stop {data-type="duration, time"} -Latest time to include in results. -_Default is `now()`._ +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. + + -The `stop` time is exclusive, meaning values with a time equal to stop time are -excluded from results. -Relative start times are defined using negative durations. -Negative durations are relative to `now()`. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). ## Examples -### Return all tag keys in a measurement +### Query tag keys from an InfluxDB measurement + ```js import "influxdata/influxdb/schema" schema.measurementTagKeys(bucket: "example-bucket", measurement: "example-measurement") ``` -### Return all tag keys in a measurement during a non-default time range -```js -import "influxdata/influxdb/schema" - -schema.measurementTagKeys(bucket: "example-bucket", measurement: "example-measurement", start: -90d, stop: -60d) -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagvalues.md b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagvalues.md index 8482fd6b1..adee740fa 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagvalues.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagvalues.md @@ -1,97 +1,92 @@ --- title: schema.measurementTagValues() function -description: The schema.measurementTagValues() function returns a list of tag values for a specific measurement. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementtagvalues/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/measurementtagvalues/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/measurementtagvalues/ +description: > + `schema.measurementTagValues()` returns a list of tag values for a specific measurement. menu: flux_0_x_ref: name: schema.measurementTagValues - parent: schema + parent: influxdata/influxdb/schema + identifier: influxdata/influxdb/schema/measurementTagValues weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-values, SHOW TAG VALUES in InfluxQL -introduced: 0.88.0 --- -The `schema.measurementTagValues()` function returns a list of tag values for a specific measurement. -The return value is always a single table with a single column, `_value`. + + +`schema.measurementTagValues()` returns a list of tag values for a specific measurement. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/schema" - -schema.measurementTagValues( - bucket: "example-bucket", - measurement: "cpu", - tag: "host", -) +( + bucket: string, + measurement: A, + tag: string, + ?start: B, + ?stop: C, +) => stream[D] where A: Equatable, D: Record ``` -{{% note %}} -#### Deleted tags -Tags [explicitly deleted from InfluxDB](/{{< latest "influxdb" >}}/write-data/delete-data/) -**do not** appear in results. - -#### Expired tags -- **InfluxDB Cloud**: tags associated with points outside of the bucket's - retention policy **may** appear in results up to an hour after expiring. -- **InfluxDB OSS**: tags associated with points outside of the bucket's - retention policy **may** appear in results. - For more information, see [Data retention in InfluxDB OSS](/{{< latest "influxdb" >}}/reference/internals/data-retention/). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to return tag values from for a specific measurement. -### measurement {data-type="string"} + + +### measurement +({{< req >}}) Measurement to return tag values from. -### tag {data-type="string"} + + +### tag +({{< req >}}) Tag to return all unique values from. -### start {data-type="duration, time"} -Earliest time to include in results. -_Default is `-30d`._ -Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). -### stop {data-type="duration, time"} -Latest time to include in results. -_Default is `now()`._ +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. + + -The `stop` time is exclusive, meaning values with a time equal to stop time are -excluded from results. -Relative start times are defined using negative durations. -Negative durations are relative to `now()`. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). ## Examples -### Return all values for a tag in a measurement +### Query unique tag values from an InfluxDB measurement + ```js import "influxdata/influxdb/schema" -schema.measurementTagValues(bucket: "example-bucket", measurement: "example-measurement", tag: "host") +schema.measurementTagValues(bucket: "example-bucket", measurement: "example-measurement", tag: "example-tag") ``` -### Return all tag values in a measurement during a non-default time range -```js -import "influxdata/influxdb/schema" - -schema.measurementTagValues( - bucket: "example-bucket", - measurement: "example-measurement", - tag: "host", - start: -90d, - stop: -60d, -) -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/tagkeys.md b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/tagkeys.md index 5535837b5..41d78e61b 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/tagkeys.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/tagkeys.md @@ -1,87 +1,98 @@ --- title: schema.tagKeys() function -description: The schema.tagKeys() function returns a list of tag keys for all series that match the predicate. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/tagkeys/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/tagkeys/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/tagkeys/ +description: > + `schema.tagKeys()` returns a list of tag keys for all series that match the `predicate`. menu: flux_0_x_ref: name: schema.tagKeys - parent: schema + parent: influxdata/influxdb/schema + identifier: influxdata/influxdb/schema/tagKeys weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-keys, SHOW TAG KEYS in InfluxQL -introduced: 0.88.0 --- -The `schema.tagKeys()` function returns a list of tag keys for all series that match the [`predicate`](#predicate). -The return value is always a single table with a single column, `_value`. + + +`schema.tagKeys()` returns a list of tag keys for all series that match the `predicate`. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/schema" - -schema.tagKeys( - bucket: "example-bucket", - predicate: (r) => true, - start: -30d, -) +( + bucket: string, + ?predicate: ( + r: { + A with + _value: B, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, + ?start: C, + ?stop: D, +) => stream[E] where E: Record ``` -{{% note %}} -#### Deleted tags -Tags [explicitly deleted from InfluxDB](/{{< latest "influxdb" >}}/write-data/delete-data/) -**do not** appear in results. - -#### Expired tags -- **InfluxDB Cloud**: tags associated with points outside of the bucket's - retention policy **may** appear in results up to an hour after expiring. -- **InfluxDB OSS**: tags associated with points outside of the bucket's - retention policy **may** appear in results. - For more information, see [Data retention in InfluxDB OSS](/{{< latest "influxdb" >}}/reference/internals/data-retention/). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to return tag keys from. -### predicate {data-type="function"} + + +### predicate + Predicate function that filters tag keys. -_Default is `(r) => true`._ +Default is `(r) => true`. -### start {data-type="duration, time"} -Earliest time to include in results. -_Default is `-30d`._ -Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). -### stop {data-type="duration, time"} -Latest time to include in results. -_Default is `now()`._ +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. -The `stop` time is exclusive, meaning values with a time equal to stop time are -excluded from results. Relative start times are defined using negative durations. Negative durations are relative to `now()`. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). +Absolute start times are defined using time values. + ## Examples -### Return all tag keys in a bucket +### Query tag keys in an InfluxDB bucket + ```js import "influxdata/influxdb/schema" schema.tagKeys(bucket: "example-bucket") ``` -### Return all tag keys in a bucket during a non-default time range -```js -import "influxdata/influxdb/schema" - -schema.tagKeys(bucket: "example-bucket", start: -90d, stop: -60d) -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/tagvalues.md b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/tagvalues.md index f062d30cb..0137bb822 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/schema/tagvalues.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/schema/tagvalues.md @@ -1,91 +1,105 @@ --- title: schema.tagValues() function -description: The `schema.tagValues()` function returns a list unique values for a given tag. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/tagvalues/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/tagvalues/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/tagvalues/ +description: > + `schema.tagValues()` returns a list of unique values for a given tag. menu: flux_0_x_ref: name: schema.tagValues - parent: schema + parent: influxdata/influxdb/schema + identifier: influxdata/influxdb/schema/tagValues weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-values, SHOW TAG VALUES in InfluxQL -introduced: 0.88.0 --- -The `schema.tagValues()` function returns a list of unique values for a given tag. -The return value is always a single table with a single column, `_value`. + + +`schema.tagValues()` returns a list of unique values for a given tag. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/schema" - -schema.tagValues( - bucket: "example-bucket", - tag: "host", - predicate: (r) => true, - start: -30d, -) +( + bucket: string, + tag: string, + ?predicate: ( + r: { + A with + _value: B, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, + ?start: C, + ?stop: D, +) => stream[E] where E: Record ``` -{{% note %}} -#### Deleted tags -Tags [explicitly deleted from InfluxDB](/{{< latest "influxdb" >}}/write-data/delete-data/) -**do not** appear in results. - -#### Expired tags -- **InfluxDB Cloud**: tags associated with points outside of the bucket's - retention policy **may** appear in results up to an hour after expiring. -- **InfluxDB OSS**: tags associated with points outside of the bucket's - retention policy **may** appear in results. - For more information, see [Data retention in InfluxDB OSS](/{{< latest "influxdb" >}}/reference/internals/data-retention/). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to return unique tag values from. -### tag {data-type="string"} + + +### tag +({{< req >}}) Tag to return unique values from. -### predicate {data-type="function"} + + +### predicate + Predicate function that filters tag values. -_Default is `(r) => true`._ +Default is `(r) => true`. -### start {data-type="duration, time"} -Earliest time to include in results. -_Default is `-30d`._ + + +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. Relative start times are defined using negative durations. Negative durations are relative to `now()`. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). +Absolute start times are defined using time values. -### stop {data-type="duration, time"} -Latest time to include in results. -_Default is `now()`._ - -The `stop` time is exclusive, meaning values with a time equal to stop time are -excluded from results. -Relative start times are defined using negative durations. -Negative durations are relative to `now()`. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). ## Examples -### Return all values for a tag in a bucket +### Query unique tag values from an InfluxDB bucket + ```js import "influxdata/influxdb/schema" schema.tagValues(bucket: "example-bucket", tag: "host") ``` -### Return all tag values in a bucket during a non-default time range -```js -import "influxdata/influxdb/schema" - -schema.tagValues(bucket: "example-bucket", tag: "host", start: -90d, stop: -60d) -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/secrets/_index.md b/content/flux/v0.x/stdlib/influxdata/influxdb/secrets/_index.md index 64f2cf5a6..6d4183856 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/secrets/_index.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/secrets/_index.md @@ -1,28 +1,44 @@ --- -title: Flux InfluxDB secrets package -list_title: secrets package +title: secrets package description: > - The Flux InfluxDB `secrets` package provides functions for working with sensitive secrets managed by InfluxDB. - Import the `influxdata/influxdb/secrets` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/secrets/ - - /influxdb/v2.0/reference/flux/stdlib/secrets/ - - /influxdb/cloud/reference/flux/stdlib/secrets/ + The `secrets` package functions for working with sensitive secrets managed by InfluxDB. menu: flux_0_x_ref: - name: secrets - parent: influxdb-pkg -weight: 202 -flux/v0.x/tags: [functions, secrets, package, security] -introduced: 0.41.0 + name: secrets + parent: influxdata/influxdb + identifier: influxdata/influxdb/secrets +weight: 31 +cascade: + flux/v0.x/tags: [secrets, security] + introduced: 0.41.0 --- -InfluxDB `secrets` Flux functions provide tools for working with sensitive secrets managed by InfluxDB. + + +The `secrets` package functions for working with sensitive secrets managed by InfluxDB. Import the `influxdata/influxdb/secrets` package: ```js import "influxdata/influxdb/secrets" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/secrets/get.md b/content/flux/v0.x/stdlib/influxdata/influxdb/secrets/get.md index 792dc5116..627575441 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/secrets/get.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/secrets/get.md @@ -1,22 +1,58 @@ --- title: secrets.get() function description: > - The `secrets.get()` function retrieves a secret from the InfluxDB secret store. -aliases: - - /influxdb/v2.0/reference/flux/functions/secrets/get/ - - /influxdb/v2.0/reference/flux/stdlib/secrets/get/ - - /influxdb/cloud/reference/flux/stdlib/secrets/get/ + `secrets.get()` retrieves a secret from the InfluxDB secret store. menu: flux_0_x_ref: name: secrets.get - parent: secrets -weight: 202 -flux/v0.x/tags: [security, secrets] -introduced: 0.41.0 + parent: influxdata/influxdb/secrets + identifier: influxdata/influxdb/secrets/get +weight: 301 --- -The `secrets.get()` function retrieves a secret from the -[InfluxDB secret store](/{{< latest "influxdb" >}}/security/secrets/). + + +`secrets.get()` retrieves a secret from the InfluxDB secret store. + + + +##### Function type signature + +```js +(key: string) => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### key +({{< req >}}) +Secret key to retrieve. + + + + +## Examples + +- [Retrive a key from the InfluxDB secret store](#retrive-a-key-from-the-influxdb-secret-store) +- [Populate sensitive credentials with secrets//](#populate-sensitive-credentials-with-secrets) + +### Retrive a key from the InfluxDB secret store ```js import "influxdata/influxdb/secrets" @@ -24,14 +60,9 @@ import "influxdata/influxdb/secrets" secrets.get(key: "KEY_NAME") ``` -## Parameters -### key {data-type="string"} -The secret key to retrieve. +### Populate sensitive credentials with secrets// -## Examples - -### Populate sensitive credentials with secrets ```js import "sql" import "influxdata/influxdb/secrets" @@ -42,6 +73,7 @@ password = secrets.get(key: "POSTGRES_PASSWORD") sql.from( driverName: "postgres", dataSourceName: "postgresql://${username}:${password}@localhost", - query:"SELECT * FROM example-table", + query: "SELECT * FROM example-table", ) ``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/tasks/_index.md b/content/flux/v0.x/stdlib/influxdata/influxdb/tasks/_index.md index 547754f63..722c94c15 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/tasks/_index.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/tasks/_index.md @@ -1,46 +1,55 @@ --- -title: Flux InfluxDB `tasks` package -list_title: tasks package +title: tasks package description: > - The Flux InfluxDB `tasks` package provides options and functions for working with - [InfluxDB tasks](/influxdb/cloud/process-data/get-started/). - Import the `influxdata/influxdb/tasks` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-tasks/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-tasks/ + The `tasks` package provides tools for working with InfluxDB tasks. menu: flux_0_x_ref: - name: tasks - parent: influxdb-pkg -weight: 202 -flux/v0.x/tags: [functions, tasks, package] -related: - - /{{< latest "influxdb" >}}/process-data/get-started/ -introduced: 0.84.0 + name: tasks + parent: influxdata/influxdb + identifier: influxdata/influxdb/tasks +weight: 31 +cascade: + + introduced: 0.84.0 --- -The Flux InfluxDB `tasks` package provides options and functions for working with -[InfluxDB tasks](/influxdb/cloud/process-data/get-started/). + + +The `tasks` package provides tools for working with InfluxDB tasks. Import the `influxdata/influxdb/tasks` package: ```js import "influxdata/influxdb/tasks" ``` + + ## Options -The `influxdata/influxdb/tasks` package provides the following options: ```js -import "influxdata/influxdb/tasks" - -option tasks.lastSuccessTime = 0000-01-01T00:00:00Z +option tasks.lastSuccessTime = _zeroTime ``` + +### lastSuccessTime + +`lastSuccessTime` is the last time this task ran successfully. + + -### lastSuccessTime {data-type="time"} -Define the time of the last successful task run. -_Only use this option to override the time of the last successful run provided by -the InfluxDB task engine._ ## Functions diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/tasks/lastsuccess.md b/content/flux/v0.x/stdlib/influxdata/influxdb/tasks/lastsuccess.md index b051208d4..4370b4e1e 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/tasks/lastsuccess.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/tasks/lastsuccess.md @@ -1,22 +1,57 @@ --- title: tasks.lastSuccess() function description: > - The `tasks.lastSuccess()` function returns the time of last successful run of the - InfluxDB task or the value of the `orTime` parameter if the task has never successfully run. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/influxdb-tasks/lastsuccess/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-tasks/lastsuccess/ + `tasks.lastSuccess()` returns the time of the last successful run of the InfluxDB task + or the value of the `orTime` parameter if the task has never successfully run. menu: flux_0_x_ref: name: tasks.lastSuccess - parent: tasks + parent: influxdata/influxdb/tasks + identifier: influxdata/influxdb/tasks/lastSuccess weight: 301 -flux/v0.x/tags: [metadata] -introduced: 0.84.0 --- -The `tasks.lastSuccess()` function returns the time of last successful run of the -InfluxDB task or the value of the `orTime` parameter if the task has never successfully run. + + +`tasks.lastSuccess()` returns the time of the last successful run of the InfluxDB task +or the value of the `orTime` parameter if the task has never successfully run. + + + +##### Function type signature + +```js +(orTime: A) => time where A: Timeable +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### orTime +({{< req >}}) +Defualt time value returned if the task has never successfully run. + + + + +## Examples + +### Return the time an InfluxDB task last succesfully ran ```js import "influxdata/influxdb/tasks" @@ -24,20 +59,3 @@ import "influxdata/influxdb/tasks" tasks.lastSuccess(orTime: 2020-01-01T00:00:00Z) ``` -## Parameters - -### orTime {data-type="duration, time"} -The default time value returned if the task has never successfully run. - -## Examples - -##### Query data since the last successful task run -```js -import "influxdata/influxdb/tasks" - -option task = {name: "Example task", every: 30m} - -from(bucket: "example-bucket") - |> range(start: tasks.lastSuccess(orTime: -task.every)) - // ... -``` diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/to.md b/content/flux/v0.x/stdlib/influxdata/influxdb/to.md index 54884f55d..8435c6bbf 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/to.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/to.md @@ -1,206 +1,276 @@ --- title: to() function description: > - `to()` writes data to an **InfluxDB Cloud or v2.x** bucket and outputs the - written data. -aliases: - - /flux/v0.x/stdlib/universe/to - - /influxdb/v2.0/reference/flux/functions/outputs/to - - /influxdb/v2.0/reference/flux/functions/built-in/outputs/to/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/outputs/to/ - - /influxdb/cloud/reference/flux/stdlib/built-in/outputs/to/ + `to()` writes data to an InfluxDB Cloud or 2.x bucket and returns the written data. menu: flux_0_x_ref: name: to - parent: influxdb-pkg -weight: 301 + parent: influxdata/influxdb + identifier: influxdata/influxdb/to +weight: 201 flux/v0.x/tags: [outputs] -related: - - /flux/v0.x/stdlib/experimental/to/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-into-clause, InfluxQL – SELECT INTO -introduced: 0.7.0 --- -`to()` writes data to an **InfluxDB Cloud or v2.x** bucket and outputs the -written data. + + +`to()` writes data to an InfluxDB Cloud or 2.x bucket and returns the written data. ### Output data requirements -`to()` writes data structured using the standard -[InfluxDB v2.x and InfluxDB Cloud data structure](/{{< latest "influxdb" >}}/reference/key-concepts/data-elements/) -that includes, at a minimum, the following columns: +`to()` writes data structured using the standard InfluxDB Cloud and v2.x data +structure that includes, at a minimum, the following columns: - `_time` - `_measurement` - `_field` - `_value` -_All other columns are written to InfluxDB as [tags](/{{< latest "influxdb" >}}/reference/key-concepts/data-elements/#tags)._ +All other columns are written to InfluxDB as +[tags](https://docs.influxdata.com/influxdb/cloud/reference/key-concepts/data-elements/#tags). -{{% note %}} -`to()` drops rows with a null `_time` value and does not write them to InfluxDB. -{{% /note %}} +**Note**: `to()` drops rows with null `_time` values and does not write them +to InfluxDB. + +#### to() does not require a package import +`to()` is part of the `influxdata/influxdb` package, but is part of the +Flux prelude and does not require an import statement or package namespace. + +##### Function type signature + +```js +( + <-tables: stream[A], + ?bucket: string, + ?bucketID: string, + ?fieldFn: (r: A) => B, + ?host: string, + ?measurementColumn: string, + ?org: string, + ?orgID: string, + ?tagColumns: [string], + ?timeColumn: string, + ?token: string, +) => stream[A] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -{{% note %}} -You must provide a `bucket` or `bucketID` and an `org` or `orgID`. -{{% /note %}} +### bucket -### bucket {data-type="string"} -Bucket to write data to. -_`bucket` and `bucketID` are mutually exclusive._ +Name of the bucket to write to. +_`bucket` and `bucketID` are mutually exclusive_. -### bucketID {data-type="string"} -Bucket ID to write data to. -_`bucketID` and `bucket` are mutually exclusive._ -### org {data-type="string"} -InfluxDB organization name. -_`org` and `orgID` are mutually exclusive._ -### orgID {data-type="string"} -InfluxDB organization ID. -_`orgID` and `org` are mutually exclusive._ +### bucketID -{{% warn %}} -`to()` cannot write to from one InfluxDB Cloud organization to another. -{{% /warn %}} +String-encoded bucket ID to to write to. +_`bucket` and `bucketID` are mutually exclusive_. -### host {data-type="string"} -[InfluxDB URL](/{{< latest "influxdb" >}}/reference/urls/) or -[InfluxDB Cloud region](/influxdb/cloud/reference/regions) URL to write to. -{{% warn %}} -_`host` is required when writing to a remote InfluxDB instance. -If specified, [`token`](#token) is also required._ -{{% /warn %}} -### token {data-type="string"} -[InfluxDB API token](/{{< latest "influxdb" >}}/security/tokens). +### host -{{% warn %}} -_`token` is required when writing to another organization or when writing to a remote InfluxDB [`host`](#host)._ -{{% /warn %}} +URL of the InfluxDB instance to write to. -### timeColumn {data-type="string"} -Time column of the output. -Default is `"_time"`. +See [InfluxDB Cloud regions](https://docs.influxdata.com/influxdb/cloud/reference/regions/) +or [InfluxDB OSS URLs](https://docs.influxdata.com/influxdb/latest/reference/urls/). +`host` is required when writing to a remote InfluxDB instance. +If specified, `token` is also required. + +### org + +Organization name. +_`org` and `orgID` are mutually exclusive_. + + + +### orgID + +String-encoded organization ID to query. +_`org` and `orgID` are mutually exclusive_. + + + +### token + +InfluxDB API token. + +**InfluxDB 1.x or Enterprise**: If authentication is disabled, provide an +empty string (`""`). If authentication is enabled, provide your InfluxDB +username and password using the `:` syntax. +`token` is required when writing to another organization or when `host` +is specified. + +### timeColumn + +Time column of the output. Default is `"_time"`. + + + +### measurementColumn + +Measurement column of the output. Default is `"_measurement"`. + + + +### tagColumns + +Tag columns in the output. Defaults to all columns with type +`string`, excluding all value columns and columns identified by `fieldFn`. + + + +### fieldFn + +Function that maps a field key to a field value and returns a record. +Default is `(r) => ({ [r._field]: r._value })`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -### tagColumns {data-type="array of strings"} -Tag columns in the output. -Defaults to all columns with type `string`, excluding all value columns and columns -identified by [`fieldFn`](#fieldfn). -### fieldFn {data-type="function"} -Function that takes a record from the input table and returns a record. -For each record from the input table, `fieldFn` returns a record that maps the -output field key to the output value. -Default is `(r) => ({ [r._field]: r._value })` -_**Output data type:** Record_ -{{% note %}} -Make sure `fieldFn` parameter names match each specified parameter. -To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} ## Examples -- [Default to() operation](#default-to-operation) -- [Custom to() operation](#custom-to-operation) -- [Write to multiple buckets](#write-to-multiple-buckets) +- [Write data to InfluxDB](#write-data-to-influxdb) +- [Customize measurement, tag, and field columns in the to() operation](#customize-measurement-tag-and-field-columns-in-the-to-operation) +- [Write to multiple InfluxDB buckets](#write-to-multiple-influxdb-buckets) -### Default to() operation - -Given the following table: - -| _time | _start | _stop | _measurement | _field | _value | -| ----- | ------ | ----- | ------------ | ------ | ------ | -| 0005 | 0000 | 0009 | "a" | "temp" | 100.1 | -| 0006 | 0000 | 0009 | "a" | "temp" | 99.3 | -| 0007 | 0000 | 0009 | "a" | "temp" | 99.9 | - -The default `to()` operation: +### Write data to InfluxDB ```js +data = + array.from( + rows: [ + { + _time: 2021-01-01T00:00:00Z, + _measurement: "m", + tag1: "a", + _field: "temp", + _value: 100.1, + }, + { + _time: 2021-01-01T00:01:00Z, + _measurement: "m", + tag1: "a", + _field: "temp", + _value: 99.8, + }, + { + _time: 2021-01-01T00:02:00Z, + _measurement: "m", + tag1: "a", + _field: "temp", + _value: 99.1, + }, + { + _time: 2021-01-01T00:03:00Z, + _measurement: "m", + tag1: "a", + _field: "temp", + _value: 98.6, + }, + ], + ) + data - |> to(bucket:"my-bucket", org:"my-org") + |> to(bucket: "example-bucket", org: "example-org", token: "mYSuP3rSecR37t0k3N", host: "http://localhost:8086") ``` -is equivalent to writing the above data using the following line protocol: +The example above produces the following line protocol and sends it to the +InfluxDB `/api/v2/write` endpoint: -``` -_measurement=a temp=100.1 0005 -_measurement=a temp=99.3 0006 -_measurement=a temp=99.9 0007 +```txt +m,tag1=a temp=100.1 1609459200000000000 +m,tag1=a temp=99.8 1609459260000000000 +m,tag1=a temp=99.1 1609459320000000000 +m,tag1=a temp=98.6 1609459380000000000 ``` -### Custom to() operation -The default `to()` operation can be overridden. -For example, given the following table: - -| _time | _start | _stop | tag1 | tag2 | hum | temp | -| ----- | ------ | ----- | ---- | ---- | ---- | ----- | -| 0005 | 0000 | 0009 | "a" | "b" | 55.3 | 100.1 | -| 0006 | 0000 | 0009 | "a" | "b" | 55.4 | 99.3 | -| 0007 | 0000 | 0009 | "a" | "b" | 55.5 | 99.9 | - -The operation: +### Customize measurement, tag, and field columns in the to() operation ```js +data = + array.from( + rows: [ + { + _time: 2021-01-01T00:00:00Z, + tag1: "a", + tag2: "b", + hum: 53.3, + temp: 100.1, + }, + { + _time: 2021-01-01T00:01:00Z, + tag1: "a", + tag2: "b", + hum: 53.4, + temp: 99.8, + }, + { + _time: 2021-01-01T00:02:00Z, + tag1: "a", + tag2: "b", + hum: 53.6, + temp: 99.1, + }, + { + _time: 2021-01-01T00:03:00Z, + tag1: "a", + tag2: "b", + hum: 53.5, + temp: 98.6, + }, + ], + ) + data |> to( - bucket:"my-bucket", - org:"my-org", - tagColumns:["tag1"], + bucket: "example-bucket", + measurementColumn: "tag1", + tagColumns: ["tag2"], fieldFn: (r) => ({"hum": r.hum, "temp": r.temp}), ) ``` -is equivalent to writing the above data using the following line protocol: +The example above produces the following line protocol and sends it to the +InfluxDB `/api/v2/write` endpoint: -``` -_tag1=a hum=55.3,temp=100.1 0005 -_tag1=a hum=55.4,temp=99.3 0006 -_tag1=a hum=55.5,temp=99.9 0007 +```txt +a,tag2=b hum=53.3,temp=100.1 1609459200000000000 +a,tag2=b hum=53.4,temp=99.8 1609459260000000000 +a,tag2=b hum=53.6,temp=99.1 1609459320000000000 +a,tag2=b hum=53.5,temp=98.6 1609459380000000000 ``` -### Write to multiple buckets + +### Write to multiple InfluxDB buckets + The example below does the following: 1. Writes data to `bucket1` and returns the data as it is written. -2. Ungroups the returned data. +2. Applies an empty group key to group all rows into a single table. 3. Counts the number of rows. 4. Maps columns required to write to InfluxDB. 5. Writes the modified data to `bucket2`. @@ -213,3 +283,4 @@ data |> map(fn: (r) => ({r with _time: now(), _measurement: "writeStats", _field: "numPointsWritten"})) |> to(bucket: "bucket2") ``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/_index.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/_index.md index 71668ebb8..4845f3e64 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/_index.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/_index.md @@ -1,49 +1,59 @@ --- -title: Flux InfluxDB v1 package -list_title: v1 package +title: v1 package description: > - The Flux InfluxDB v1 package provides functions for managing data from an InfluxDB v1.x - database or structured using the InfluxDB v1 data structure. - Import the `influxdata/influxdb/v1` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/ + The `v1` package provides tools for managing data from an InfluxDB v1.x database or + structured using the InfluxDB v1 data structure. menu: flux_0_x_ref: - name: v1 - parent: influxdb-pkg -weight: 202 -flux/v0.x/tags: [functions, influxdb-v1, package] -introduced: 0.16.0 + name: v1 + parent: influxdata/influxdb + identifier: influxdata/influxdb/v1 +weight: 31 +cascade: + + introduced: 0.16.0 --- -InfluxDB v1 Flux functions provide tools for managing data from an InfluxDB v1.x -database or structured using the InfluxDB v1 data structure. + + +The `v1` package provides tools for managing data from an InfluxDB v1.x database or +structured using the InfluxDB v1 data structure. Import the `influxdata/influxdb/v1` package: ```js import "influxdata/influxdb/v1" ``` +### Deprecated functions +In Flux 0.88.0, the following v1 package functions moved to +the InfluxDB schema package. These functions are still available in the v1 +package for backwards compatibility, but are deprecated in favor of the +schema package. + +- `v1.fieldKeys()` +- `v1.fieldsAsCols()` +- `v1.measurementFieldKeys()` +- `v1.measurements()` +- `v1.measurementTagKeys()` +- `v1.measurementTagValues()` +- `v1.tagKeys()` +- `v1.tagValues()` + + ## Functions + {{< children type="functions" show="pages" >}} - -{{% warn %}} -#### Deprecated functions -In **Flux 0.88.0**, the following InfluxDB v1 package functions moved to the -[InfluxDB schema package](/flux/v0.x/stdlib/influxdata/influxdb/schema/). -These functions are still available in the `v1` package for backwards compatibility, -but are deprecated in favor of `schema`. - -| Deprecated v1 function | → | Corresponding schema function | -|:------------------- |:-:|:------------------------ | -| **v1.fieldKeys()** | → | [schema.fieldKeys()](/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldkeys/) | -| **v1.fieldsAsCols()** | → | [schema.fieldsAsCols()](/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols/) | -| **v1.measurementFieldKeys()** | → | [schema.measurementFieldKeys()](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys/) | -| **v1.measurements()** | → | [schema.measurements()](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurements/) | -| **v1.measurementTagKeys()** | → | [schema.measurementTagKeys()](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys/) | -| **v1.measurementTagValues()** | → | [schema.measurementTagValues()](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagvalues/) | -| **v1.tagKeys()** | → | [schema.tagKeys()](/flux/v0.x/stdlib/influxdata/influxdb/schema/tagkeys/) | -| **v1.tagValues()** | → | [schema.tagValues()](/flux/v0.x/stdlib/influxdata/influxdb/schema/tagvalues/) | -{{% /warn %}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/databases.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/databases.md index 231257a13..510c4bfb0 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/databases.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/databases.md @@ -1,21 +1,91 @@ --- title: v1.databases() function -description: The `v1.databases()` function returns a list of databases in an InfluxDB 1.7+ instance. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/databases/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/databases/ +description: > + `v1.databases()` returns a list of databases in an InfluxDB 1.x (1.7+) instance. menu: flux_0_x_ref: name: v1.databases - parent: v1 + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/databases weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-databases, SHOW DATABASES in InfluxQL -introduced: 0.16.0 --- -The `v1.databases()` function returns a list of databases in an **InfluxDB 1.7+ instance**. + + +`v1.databases()` returns a list of databases in an InfluxDB 1.x (1.7+) instance. + +Output includes the following columns: + +- **databaseName**: Database name (string) +- **retentionPolicy**: Retention policy name (string) +- **retentionPeriod**: Retention period in nanoseconds (integer) +- **default**: Default retention policy for the database (boolean) + +##### Function type signature + +```js +( + ?host: string, + ?org: string, + ?orgID: string, + ?token: string, +) => stream[{ + retentionPolicy: string, + retentionPeriod: int, + organizationID: string, + default: bool, + databaseName: string, + bucketID: string, +}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### org + +Organization name. + + + +### orgID + +Organization ID. + + + +### host + +InfluxDB URL. Default is `http://localhost:8086`. + + + +### token + +InfluxDB API token. + + + + +## Examples + +### List databases from an InfluxDB instance ```js import "influxdata/influxdb/v1" @@ -23,9 +93,3 @@ import "influxdata/influxdb/v1" v1.databases() ``` -Output includes the following columns: - -- **databaseName:** Database name _(string)_ -- **retentionPolicy:** Retention policy name _(string)_ -- **retentionPeriod:** Retention period in nanoseconds _(integer)_ -- **default:** Default retention policy for database _(boolean)_ diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldkeys.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldkeys.md index f8b3257b0..8e71e513c 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldkeys.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldkeys.md @@ -1,72 +1,102 @@ --- title: v1.fieldKeys() function -description: The `v1.fieldKeys()` function returns field keys in a bucket. +description: > + `v1.fieldKeys()` returns field keys in a bucket. menu: flux_0_x_ref: name: v1.fieldKeys - parent: v1 + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/fieldKeys weight: 301 flux/v0.x/tags: [metadata] -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/fieldkeys - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/fieldkeys/ -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-field-keys, SHOW FIELD KEYS in InfluxQL -introduced: 0.68.0 deprecated: 0.88.0 --- -{{% warn %}} -`v1.fieldKeys()` was deprecated in **Flux v0.88.0** in favor of -[`schema.fieldKeys()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldkeys/). -{{% /warn %}} + + +`v1.fieldKeys()` returns field keys in a bucket. + +Results include a single table with a single column, `_value`. + +**Note**: FieldKeys is a special application of `tagValues that returns field +keys in a given bucket. + +##### Function type signature ```js -import "influxdata/influxdb/v1" - -v1.fieldKeys( - bucket: "example-bucket", - predicate: (r) => true, - start: -30d, -) +( + bucket: string, + ?predicate: ( + r: { + A with + _value: B, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, + ?start: C, + ?stop: D, +) => stream[E] where E: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bucket {data-type="string"} -The bucket to list field keys from. +### bucket +({{< req >}}) +Bucket to list field keys from. -### predicate {data-type="function"} -The predicate function that filters field keys. -_Default is `(r) => true`._ -### start {data-type="duration, time"} -The oldest time to include in results. -_Default is `-30d`._ + +### predicate + +Predicate function that filters field keys. +Default is `(r) => true`. + + + +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). +Negative durations are relative to `now()`. +Absolute start times are defined using time values. + ## Examples -```js -import "influxdata/influxdb/v1" -v1.fieldKeys(bucket: "my-bucket") +### Query field keys from an InfluxDB bucket + +```js +import "influxdata/influxdb/schema" + +schema.fieldKeys(bucket: "example-bucket") ``` -## Function definition -```js -package v1 - -fieldKeys = (bucket, predicate=(r) => true, start=-30d) => - tagValues(bucket: bucket, tag: "_field", predicate: predicate, start: start) -``` - -_**Used functions:** -[v1.tagValues]((/flux/v0.x/stdlib/influxdata/influxdb/v1/tagvalues/)_ diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldsascols.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldsascols.md index 000c8d371..cd22f6bbc 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldsascols.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldsascols.md @@ -1,82 +1,94 @@ --- title: v1.fieldsAsCols() function -description: The v1.fieldsAsCols() function pivots a table to automatically align fields within each input table that have the same timestamp. -aliases: - - /influxdb/v2.0/reference/flux/functions/inputs/fromrows - - /influxdb/v2.0/reference/flux/functions/transformations/influxfieldsascols - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/fieldsascols/ - - /influxdb/v2.0/reference/flux/functions/influxdb-schema/fieldsascols/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/fieldsascols/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/fieldsascols/ +description: > + `v1.fieldsAsCols()` is a special application of `pivot()` that pivots input data + on `_field` and `_time` columns to align fields within each input table that + have the same timestamp. menu: flux_0_x_ref: name: v1.fieldsAsCols - parent: v1 + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/fieldsAsCols weight: 301 flux/v0.x/tags: [transformations] -introduced: 0.16.0 deprecated: 0.88.0 --- -{{% warn %}} -`v1.fieldsAsCols()` was deprecated in **Flux v0.88.0** in favor of -[`schema.fieldsAsCols()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols/). -{{% /warn %}} + + +`v1.fieldsAsCols()` is a special application of `pivot()` that pivots input data +on `_field` and `_time` columns to align fields within each input table that +have the same timestamp. + +**Deprecated**: See influxdata/influxdata/schema.fieldsAsCols. + +##### Function type signature ```js -import "influxdata/influxdb/v1" - -v1.fieldsAsCols() +(<-tables: stream[A]) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples + +### Pivot InfluxDB fields into columns + ```js import "influxdata/influxdb/v1" -from(bucket:"example-bucket") - |> range(start: -1h) - |> filter(fn: (r) => r._measurement == "cpu") +data |> v1.fieldsAsCols() ``` {{< expand-wrapper >}} -{{% expand "View example input and output" %}} +{{% expand "View example input and ouput" %}} -_`_start` and `_stop` columns have been omitted._ +#### Input data -##### Example input data -| _measurement | _host | _time | _field | _value | -| :----------- | :---- | :------------------- | :------ | -----: | -| example | h1 | 2021-01-01T00:00:00Z | resp_ms | 43 | -| example | h1 | 2021-01-01T00:00:30Z | resp_ms | 52 | -| example | h1 | 2021-01-01T00:01:00Z | resp_ms | 30000 | -| example | h1 | 2021-01-01T00:01:30Z | resp_ms | 49 | +| _time | *_measurement | *loc | *_field | _value | +| -------------------- | ------------- | ------- | ------- | ------- | +| 2021-01-01T12:00:00Z | m | Seattle | hum | 89.2 | +| 2021-01-02T12:00:00Z | m | Seattle | hum | 90.5 | +| 2021-01-03T12:00:00Z | m | Seattle | hum | 81.0 | -| _measurement | _host | _time | _field | _value | -| :----------- | :---- | :------------------- | :-------- | -----: | -| example | h1 | 2021-01-01T00:00:00Z | resp_code | 200 | -| example | h1 | 2021-01-01T00:00:30Z | resp_code | 200 | -| example | h1 | 2021-01-01T00:01:00Z | resp_code | 500 | -| example | h1 | 2021-01-01T00:01:30Z | resp_code | 200 | +| _time | *_measurement | *loc | *_field | _value | +| -------------------- | ------------- | ------- | ------- | ------- | +| 2021-01-01T12:00:00Z | m | Seattle | temp | 73.1 | +| 2021-01-02T12:00:00Z | m | Seattle | temp | 68.2 | +| 2021-01-03T12:00:00Z | m | Seattle | temp | 61.4 | -##### Example output data -| _measurement | _host | _time | resp_ms | resp_code | -| :----------- | :---- | :------------------- | ------: | --------: | -| example | h1 | 2021-01-01T00:00:00Z | 43 | 200 | -| example | h1 | 2021-01-01T00:00:30Z | 52 | 200 | -| example | h1 | 2021-01-01T00:01:00Z | 30000 | 500 | -| example | h1 | 2021-01-01T00:01:30Z | 49 | 200 | + +#### Output data + +| _time | *_measurement | *loc | hum | temp | +| -------------------- | ------------- | ------- | ---- | ----- | +| 2021-01-01T12:00:00Z | m | Seattle | 89.2 | 73.1 | +| 2021-01-02T12:00:00Z | m | Seattle | 90.5 | 68.2 | +| 2021-01-03T12:00:00Z | m | Seattle | 81.0 | 61.4 | {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/json.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/json.md new file mode 100644 index 000000000..7893e699b --- /dev/null +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/json.md @@ -0,0 +1,127 @@ +--- +title: v1.json() function +description: > + `v1.json()` parses an InfluxDB 1.x JSON result into a stream of tables. +menu: + flux_0_x_ref: + name: v1.json + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/json +weight: 301 +flux/v0.x/tags: [inputs] +--- + + + +`v1.json()` parses an InfluxDB 1.x JSON result into a stream of tables. + + + +##### Function type signature + +```js +(?file: string, ?json: string) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### json + +InfluxDB 1.x query results in JSON format. + +_`json` and `file` are mutually exclusive._ + +### file + +File path to file containing InfluxDB 1.x query results in JSON format. + +The path can be absolute or relative. +If relative, it is relative to the working directory of the `fluxd` process. +The JSON file must exist in the same file system running the `fluxd` process. +**Note**: InfluxDB OSS and InfluxDB Cloud do not support the `file` parameter. +Neither allow access to the underlying filesystem. + + +## Examples + +- [Convert a InfluxDB 1.x JSON query output string to a stream of tables](#convert-a-influxdb-1x-json-query-output-string-to-a-stream-of-tables) +- [Convert a InfluxDB 1.x JSON query output file to a stream of tables](#convert-a-influxdb-1x-json-query-output-file-to-a-stream-of-tables) + +### Convert a InfluxDB 1.x JSON query output string to a stream of tables + +```js +import "influxdata/influxdb/v1" + +jsonData = + "{ + \"results\": [ + { + \"statement_id\": 0, + \"series\": [ + { + \"name\": \"cpu_load_short\", + \"columns\": [ + \"time\", + \"value\" + ], + \"values\": [ + [ + \"2021-01-01T00:00:00.000000000Z\", + 2 + ], + [ + \"2021-01-01T00:01:00.000000000Z\", + 0.55 + ], + [ + \"2021-01-01T00:02:00.000000000Z\", + 0.64 + ] + ] + } + ] + } + ] +}" + +v1.json(json: jsonData) +``` + +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| _time | *_measurement | *_field | _value | +| -------------------- | -------------- | ------- | ------- | +| 2021-01-01T00:00:00Z | cpu_load_short | value | 2 | +| 2021-01-01T00:01:00Z | cpu_load_short | value | 0.55 | +| 2021-01-01T00:02:00Z | cpu_load_short | value | 0.64 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Convert a InfluxDB 1.x JSON query output file to a stream of tables + +```js +import "influxdata/influxdb/v1" + +v1.json(file: "/path/to/results.json") +``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementfieldkeys.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementfieldkeys.md index 8a91a7a82..00571fd4d 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementfieldkeys.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementfieldkeys.md @@ -1,60 +1,83 @@ --- title: v1.measurementFieldKeys() function -description: The `v1.measurementFieldKeys()` function returns a list of fields in a measurement. +description: > + `v1.measurementFieldKeys()` returns a list of fields in a measurement. menu: flux_0_x_ref: name: v1.measurementFieldKeys - parent: v1 + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/measurementFieldKeys weight: 301 flux/v0.x/tags: [metadata] -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementfieldkeys/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/measurementfieldkeys/ -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-field-keys, SHOW FIELD KEYS in InfluxQL -introduced: 0.68.0 deprecated: 0.88.0 --- -{{% warn %}} -`v1.measurementFieldKeys()` was deprecated in **Flux v0.88.0** in favor of -[`schema.measurementFieldKeys()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys/). -{{% /warn %}} + + +`v1.measurementFieldKeys()` returns a list of fields in a measurement. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/v1" - -v1.measurementFieldKeys( - bucket: "example-bucket", - measurement: "example-measurement", - start: -30d, -) +(bucket: string, measurement: A, ?start: B, ?stop: C) => stream[D] where A: Equatable, D: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to retrieve field keys from. -### measurement {data-type="string"} + + +### measurement +({{< req >}}) Measurement to list field keys from. -### start {data-type="duration, time"} -Oldest time to include in results. -_Defaults to `-30d`._ + + +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). +Negative durations are relative to `now()`. +Absolute start times are defined using time values. + ## Examples -```js -import "influxdata/influxdb/v1" -v1.measurementFieldKeys(bucket: "telegraf", measurement: "cpu") +### Query field keys from an InfluxDB measurement + +```js +import "influxdata/influxdb/schema" + +schema.measurementFieldKeys(bucket: "example-bucket", measurement: "example-measurement") ``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurements.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurements.md index 318cffce0..87c3afb1a 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurements.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurements.md @@ -1,38 +1,75 @@ --- title: v1.measurements() function -description: The v1.measurements() function returns a list of measurements in a specific bucket. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurements/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/measurements/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/measurements/ +description: > + `v1.measurements()` returns a list of measurements in a specific bucket. menu: flux_0_x_ref: name: v1.measurements - parent: v1 + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/measurements weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-measurements, SHOW MEASUREMENTS in InfluxQL -introduced: 0.16.0 deprecated: 0.88.0 --- -{{% warn %}} -`v1.measurements()` was deprecated in **Flux v0.88.0** in favor of -[`schema.measurements()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurements/). -{{% /warn %}} + + +`v1.measurements()` returns a list of measurements in a specific bucket. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/v1" - -v1.measurements(bucket: "example-bucket") +(bucket: string, ?start: A, ?stop: B) => stream[C] where C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to retrieve measurements from. + + + +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. + + + + +## Examples + +### Return a list of measurements in an InfluxDB bucket + +```js +import "influxdata/influxdb/schema" + +schema.measurements(bucket: "example-bucket") +``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagkeys.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagkeys.md index 1de146d7c..f66e6d200 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagkeys.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagkeys.md @@ -1,44 +1,81 @@ --- title: v1.measurementTagKeys() function -description: The v1.measurementTagKeys() function returns a list of tag keys for a specific measurement. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementtagkeys/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/measurementtagkeys/ +description: > + `v1.measurementTagKeys()` returns the list of tag keys for a specific measurement. menu: flux_0_x_ref: name: v1.measurementTagKeys - parent: v1 + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/measurementTagKeys weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-keys, SHOW TAG KEYS in InfluxQL -introduced: 0.16.0 deprecated: 0.88.0 --- -{{% warn %}} -`v1.measurementTagKeys()` was deprecated in **Flux v0.88.0** in favor of -[`schema.measurementTagKeys()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys/). -{{% /warn %}} + + +`v1.measurementTagKeys()` returns the list of tag keys for a specific measurement. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/v1" - -v1.measurementTagKeys( - bucket: "example-bucket", - measurement: "cpu", -) +(bucket: string, measurement: A, ?start: B, ?stop: C) => stream[D] where A: Equatable, D: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to return tag keys from for a specific measurement. -### measurement {data-type="string"} + + +### measurement +({{< req >}}) Measurement to return tag keys from. + + + +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. + + + + +## Examples + +### Query tag keys from an InfluxDB measurement + +```js +import "influxdata/influxdb/schema" + +schema.measurementTagKeys(bucket: "example-bucket", measurement: "example-measurement") +``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagvalues.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagvalues.md index f5dc090ce..962f3d761 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagvalues.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagvalues.md @@ -1,48 +1,93 @@ --- title: v1.measurementTagValues() function -description: The v1.measurementTagValues() function returns a list of tag values for a specific measurement. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementtagvalues/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/measurementtagvalues/ +description: > + `v1.measurementTagValues()` returns a list of tag values for a specific measurement. menu: flux_0_x_ref: name: v1.measurementTagValues - parent: v1 + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/measurementTagValues weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-values, SHOW TAG VALUES in InfluxQL -introduced: 0.16.0 deprecated: 0.88.0 --- -{{% warn %}} -`v1.measurementTagValues()` was deprecated in **Flux v0.88.0** in favor of -[`schema.measurementTagValues()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagvalues/). -{{% /warn %}} + + +`v1.measurementTagValues()` returns a list of tag values for a specific measurement. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/v1" - -v1.measurementTagValues( - bucket: "example-bucket", - measurement: "cpu", - tag: "host", -) +( + bucket: string, + measurement: A, + tag: string, + ?start: B, + ?stop: C, +) => stream[D] where A: Equatable, D: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -## bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to return tag values from for a specific measurement. -### measurement {data-type="string"} + + +### measurement +({{< req >}}) Measurement to return tag values from. -### tag {data-type="string"} + + +### tag +({{< req >}}) Tag to return all unique values from. + + + +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. + + + + +## Examples + +### Query unique tag values from an InfluxDB measurement + +```js +import "influxdata/influxdb/schema" + +schema.measurementTagValues(bucket: "example-bucket", measurement: "example-measurement", tag: "example-tag") +``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/tagkeys.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/tagkeys.md index a1f3c5a1c..03d9fd35a 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/tagkeys.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/tagkeys.md @@ -1,61 +1,99 @@ --- title: v1.tagKeys() function -description: The v1.tagKeys() function returns a list of tag keys for all series that match the predicate. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/tagkeys/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/tagkeys/ +description: > + `v1.tagKeys()` returns a list of tag keys for all series that match the `predicate`. menu: flux_0_x_ref: name: v1.tagKeys - parent: v1 + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/tagKeys weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-keys, SHOW TAG KEYS in InfluxQL -introduced: 0.16.0 deprecated: 0.88.0 --- -{{% warn %}} -`v1.tagkeys()` was deprecated in **Flux v0.88.0** in favor of -[`schema.tagkeys()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/tagkeys/). -{{% /warn %}} + + +`v1.tagKeys()` returns a list of tag keys for all series that match the `predicate`. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/v1" - -v1.tagKeys( - bucket: "example-bucket", - predicate: (r) => true, - start: -30d, -) +( + bucket: string, + ?predicate: ( + r: { + A with + _value: B, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, + ?start: C, + ?stop: D, +) => stream[E] where E: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to return tag keys from. -### predicate {data-type="function"} -Predicate function that filters tag keys. -_Default is `(r) => true`._ -### start {data-type="duration, time"} -Oldest time to include in results. -_Default is `-30d`._ + +### predicate + +Predicate function that filters tag keys. +Default is `(r) => true`. + + + +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). +Negative durations are relative to `now()`. +Absolute start times are defined using time values. + ## Examples + +### Query tag keys in an InfluxDB bucket + ```js import "influxdata/influxdb/v1" -v1.tagKeys(bucket: "my-bucket") +v1.tagKeys(bucket: "example-bucket") ``` + diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/tagvalues.md b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/tagvalues.md index 2acad48ac..9b092e079 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/v1/tagvalues.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/v1/tagvalues.md @@ -1,65 +1,106 @@ --- title: v1.tagValues() function -description: The `v1.tagValues()` function returns a list unique values for a given tag. -aliases: - - /influxdb/v2.0/reference/flux/functions/influxdb-v1/tagvalues/ - - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues/ - - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/tagvalues/ +description: > + `v1.tagValues()` returns a list of unique values for a given tag. menu: flux_0_x_ref: name: v1.tagValues - parent: v1 + parent: influxdata/influxdb/v1 + identifier: influxdata/influxdb/v1/tagValues weight: 301 flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-values, SHOW TAG VALUES in InfluxQL -introduced: 0.16.0 deprecated: 0.88.0 --- -{{% warn %}} -`v1.tagValues()` was deprecated in **Flux v0.88.0** in favor of -[`schema.tagValues()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/tagvalues/). -{{% /warn %}} + + +`v1.tagValues()` returns a list of unique values for a given tag. + +Results include a single table with a single column, `_value`. + +##### Function type signature ```js -import "influxdata/influxdb/v1" - -v1.tagValues( - bucket: "example-bucket", - tag: "host", - predicate: (r) => true, - start: -30d, -) +( + bucket: string, + tag: string, + ?predicate: ( + r: { + A with + _value: B, + _time: time, + _stop: time, + _start: time, + _measurement: string, + _field: string, + }, + ) => bool, + ?start: C, + ?stop: D, +) => stream[E] where E: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### bucket {data-type="string"} +### bucket +({{< req >}}) Bucket to return unique tag values from. -### tag {data-type="string"} + + +### tag +({{< req >}}) Tag to return unique values from. -### predicate {data-type="function"} -Predicate function that filters tag values. -_Default is `(r) => true`._ -### start {data-type="duration, time"} -Oldest time to include in results. -_Default is `-30d`._ + +### predicate + +Predicate function that filters tag values. +Default is `(r) => true`. + + + +### start + +Oldest time to include in results. Default is `-30d`. + + + +### stop + +Newest time include in results. +The stop time is exclusive, meaning values with a time equal to stop time are excluded from the results. +Default is `now()`. Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using [time values](/flux/v0.x/spec/types/#time-types). +Negative durations are relative to `now()`. +Absolute start times are defined using time values. + ## Examples + +### Query unique tag values from an InfluxDB bucket + ```js import "influxdata/influxdb/v1" -v1.tagValues(bucket: "my-bucket", tag: "host") +v1.tagValues(bucket: "example-bucket", tag: "host") ``` + diff --git a/content/flux/v0.x/stdlib/internal/_index.md b/content/flux/v0.x/stdlib/internal/_index.md new file mode 100644 index 000000000..8906ab9cf --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/_index.md @@ -0,0 +1,36 @@ +--- +title: internal package +description: > + The `internal` package contains packages and functions used internally by Flux. +menu: + flux_0_x_ref: + name: internal + parent: stdlib + identifier: internal +weight: 11 +--- + + + +The `internal` package contains packages and functions used internally by Flux. + + + + +## Packages + +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/internal/boolean/_index.md b/content/flux/v0.x/stdlib/internal/boolean/_index.md new file mode 100644 index 000000000..443bcff32 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/boolean/_index.md @@ -0,0 +1,40 @@ +--- +title: boolean package +description: > + The `boolean` package provides constants for true and false values. +menu: + flux_0_x_ref: + name: boolean + parent: internal + identifier: internal/boolean +weight: 21 +--- + + + +The `boolean` package provides constants for true and false values. + +## Constants + +```js +false +true +``` + +- **false** is a constant that is the false value. +- **true** is a constant that is the truth value. + diff --git a/content/flux/v0.x/stdlib/internal/debug/_index.md b/content/flux/v0.x/stdlib/internal/debug/_index.md new file mode 100644 index 000000000..bb2776a81 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/debug/_index.md @@ -0,0 +1,53 @@ +--- +title: debug package +description: > + The `debug` package provides methods for debugging the Flux engine. +menu: + flux_0_x_ref: + name: debug + parent: internal + identifier: internal/debug +weight: 21 +--- + + + +The `debug` package provides methods for debugging the Flux engine. +Import the `internal/debug` package: + +```js +import "internal/debug" +``` + + + +## Options + +```js +option debug.vectorize = false +``` + +### vectorize + +`vectorize` controls whether the compiler attempts to vectorize Flux functions. + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/internal/debug/feature.md b/content/flux/v0.x/stdlib/internal/debug/feature.md new file mode 100644 index 000000000..4724b0f4d --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/debug/feature.md @@ -0,0 +1,48 @@ +--- +title: debug.feature() function +description: > + `debug.feature()` returns the value associated with the given feature flag. +menu: + flux_0_x_ref: + name: debug.feature + parent: internal/debug + identifier: internal/debug/feature +weight: 201 +--- + + + +`debug.feature()` returns the value associated with the given feature flag. + + + +##### Function type signature + +```js +(key: string) => A +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### key +({{< req >}}) +Feature flag name. + + + diff --git a/content/flux/v0.x/stdlib/internal/debug/getoption.md b/content/flux/v0.x/stdlib/internal/debug/getoption.md new file mode 100644 index 000000000..29d73257d --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/debug/getoption.md @@ -0,0 +1,54 @@ +--- +title: debug.getOption() function +description: > + `debug.getOption()` gets the value of an option using a form of reflection. +menu: + flux_0_x_ref: + name: debug.getOption + parent: internal/debug + identifier: internal/debug/getOption +weight: 201 +--- + + + +`debug.getOption()` gets the value of an option using a form of reflection. + + + +##### Function type signature + +```js +(name: string, pkg: string) => A +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### pkg +({{< req >}}) +Full path of the package. + + + +### name +({{< req >}}) +Option name. + + + diff --git a/content/flux/v0.x/stdlib/internal/debug/opaque.md b/content/flux/v0.x/stdlib/internal/debug/opaque.md new file mode 100644 index 000000000..5bcf43c9d --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/debug/opaque.md @@ -0,0 +1,52 @@ +--- +title: debug.opaque() function +description: > + `debug.opaque()` works like `pass` in that it passes any incoming tables directly to the + following transformation, save for its type signature does not indicate that the + input type has any correlation with the output type. +menu: + flux_0_x_ref: + name: debug.opaque + parent: internal/debug + identifier: internal/debug/opaque +weight: 201 +--- + + + +`debug.opaque()` works like `pass` in that it passes any incoming tables directly to the +following transformation, save for its type signature does not indicate that the +input type has any correlation with the output type. + + + +##### Function type signature + +```js +(<-tables: stream[A]) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Stream to pass unmodified to next transformation. + + + diff --git a/content/flux/v0.x/stdlib/internal/debug/pass.md b/content/flux/v0.x/stdlib/internal/debug/pass.md new file mode 100644 index 000000000..ed4b6175e --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/debug/pass.md @@ -0,0 +1,50 @@ +--- +title: debug.pass() function +description: > + `debug.pass()` will pass any incoming tables directly next to the following transformation. + It is best used to interrupt any planner rules that rely on a specific ordering. +menu: + flux_0_x_ref: + name: debug.pass + parent: internal/debug + identifier: internal/debug/pass +weight: 201 +--- + + + +`debug.pass()` will pass any incoming tables directly next to the following transformation. +It is best used to interrupt any planner rules that rely on a specific ordering. + + + +##### Function type signature + +```js +(<-tables: stream[A]) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Stream to pass unmodified to next transformation. + + + diff --git a/content/flux/v0.x/stdlib/internal/debug/sink.md b/content/flux/v0.x/stdlib/internal/debug/sink.md new file mode 100644 index 000000000..76fff3f13 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/debug/sink.md @@ -0,0 +1,48 @@ +--- +title: debug.sink() function +description: > + `debug.sink()` will discard all data that comes into it. +menu: + flux_0_x_ref: + name: debug.sink + parent: internal/debug + identifier: internal/debug/sink +weight: 201 +--- + + + +`debug.sink()` will discard all data that comes into it. + + + +##### Function type signature + +```js +(<-tables: stream[A]) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Stream to discard. + + + diff --git a/content/flux/v0.x/stdlib/internal/debug/slurp.md b/content/flux/v0.x/stdlib/internal/debug/slurp.md new file mode 100644 index 000000000..12d510243 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/debug/slurp.md @@ -0,0 +1,52 @@ +--- +title: debug.slurp() function +description: > + `debug.slurp()` will read the incoming tables and concatenate buffers with the same group key + into a single in memory table buffer. This is useful for testing the performance impact of multiple + buffers versus a single buffer. +menu: + flux_0_x_ref: + name: debug.slurp + parent: internal/debug + identifier: internal/debug/slurp +weight: 201 +--- + + + +`debug.slurp()` will read the incoming tables and concatenate buffers with the same group key +into a single in memory table buffer. This is useful for testing the performance impact of multiple +buffers versus a single buffer. + + + +##### Function type signature + +```js +(<-tables: stream[A]) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Stream to consume into single buffers per table. + + + diff --git a/content/flux/v0.x/stdlib/internal/debug/unpivot.md b/content/flux/v0.x/stdlib/internal/debug/unpivot.md new file mode 100644 index 000000000..93d66643b --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/debug/unpivot.md @@ -0,0 +1,52 @@ +--- +title: debug.unpivot() function +description: > + `debug.unpivot()` removes the `_time` column and any other column not in the group key and outputs a new table with `_field` and `_value` columns pairs. + The output stream retains the group key and all group key columns of the input stream. + Specialized to transform the pivoted output from `iox.from()` into the unpivoted format. +menu: + flux_0_x_ref: + name: debug.unpivot + parent: internal/debug + identifier: internal/debug/unpivot +weight: 201 +--- + + + +`debug.unpivot()` removes the `_time` column and any other column not in the group key and outputs a new table with `_field` and `_value` columns pairs. +The output stream retains the group key and all group key columns of the input stream. +Specialized to transform the pivoted output from `iox.from()` into the unpivoted format. + + + +##### Function type signature + +```js +(<-tables: stream[{A with _time: time}]) => stream[{B with _value: C, _field: string}] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + diff --git a/content/flux/v0.x/stdlib/internal/gen/_index.md b/content/flux/v0.x/stdlib/internal/gen/_index.md new file mode 100644 index 000000000..0e4c7d1b1 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/gen/_index.md @@ -0,0 +1,41 @@ +--- +title: gen package +description: > + The `gen` package provides methods for generating data. +menu: + flux_0_x_ref: + name: gen + parent: internal + identifier: internal/gen +weight: 21 +--- + + + +The `gen` package provides methods for generating data. +Import the `internal/gen` package: + +```js +import "internal/gen" +``` + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/internal/gen/tables.md b/content/flux/v0.x/stdlib/internal/gen/tables.md new file mode 100644 index 000000000..b498fe7e2 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/gen/tables.md @@ -0,0 +1,71 @@ +--- +title: gen.tables() function +description: > + `gen.tables()` generates a stream of table data. +menu: + flux_0_x_ref: + name: gen.tables + parent: internal/gen + identifier: internal/gen/tables +weight: 201 +--- + + + +`gen.tables()` generates a stream of table data. + + + +##### Function type signature + +```js +( + n: int, + ?nulls: float, + ?seed: int, + ?tags: [{name: string, cardinality: int}], +) => stream[{A with _value: float, _time: time}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### n +({{< req >}}) +Number of rows to generate. + + + +### nulls + +Percentage chance that a null value will be used in the input. Valid value range is `[0.0 - 1.0]`. + + + +### tags + +Set of tags with their cardinality to generate. + + + +### seed + +Pass seed to tables generator to get the very same sequence each time + + + diff --git a/content/flux/v0.x/stdlib/internal/influxql/_index.md b/content/flux/v0.x/stdlib/internal/influxql/_index.md new file mode 100644 index 000000000..db047126a --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/influxql/_index.md @@ -0,0 +1,42 @@ +--- +title: influxql package +description: > + The `influxql` package provides constants for working with InfluxQL. +menu: + flux_0_x_ref: + name: influxql + parent: internal + identifier: internal/influxql +weight: 21 +--- + + + +The `influxql` package provides constants for working with InfluxQL. + +## Constants + +```js +influxql.epoch = 1970-01-01T00:00:00Z +influxql.maxTime = 2262-04-11T23:47:16.854775806Z +influxql.minTime = 1677-09-21T00:12:43.145224194Z +``` + +- **influxql.epoch** is the absolute time that all InfluxQL time and duration values use as a zero reference. +- **influxql.maxTime** is the latest time InfluxQL can represent. +- **influxql.minTime** is the earliest time InfluxQL can represent. + diff --git a/content/flux/v0.x/stdlib/internal/location/_index.md b/content/flux/v0.x/stdlib/internal/location/_index.md new file mode 100644 index 000000000..0a37fe4ff --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/location/_index.md @@ -0,0 +1,44 @@ +--- +title: location package +description: > + The `location` package loads a timezone based on a location name. +menu: + flux_0_x_ref: + name: location + parent: internal + identifier: internal/location +weight: 21 +--- + + + +The `location` package loads a timezone based on a location name. + + + +## Options + +```js +option location = {zone: "UTC", offset: 0h} +``` + +### location + +`location` loads a timezone based on a location name. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/_index.md b/content/flux/v0.x/stdlib/internal/promql/_index.md new file mode 100644 index 000000000..0855b8ac7 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/_index.md @@ -0,0 +1,41 @@ +--- +title: promql package +description: > + The `promql` package provides an internal API for implementing PromQL via Flux. +menu: + flux_0_x_ref: + name: promql + parent: internal + identifier: internal/promql +weight: 21 +--- + + + +The `promql` package provides an internal API for implementing PromQL via Flux. +Import the `internal/promql` package: + +```js +import "internal/promql" +``` + +THIS PACKAGE IS NOT MEANT FOR EXTERNAL USE. + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/internal/promql/changes.md b/content/flux/v0.x/stdlib/internal/promql/changes.md new file mode 100644 index 000000000..5b2d166fd --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/changes.md @@ -0,0 +1,50 @@ +--- +title: promql.changes() function +description: > + `promql.changes()` implements functionality equivalent to + [PromQL's `changes()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#changes). +menu: + flux_0_x_ref: + name: promql.changes + parent: internal/promql + identifier: internal/promql/changes +weight: 201 +--- + + + +`promql.changes()` implements functionality equivalent to +[PromQL's `changes()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#changes). + + + +##### Function type signature + +```js +(<-tables: stream[{A with _value: float}]) => stream[{B with _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/emptytable.md b/content/flux/v0.x/stdlib/internal/promql/emptytable.md new file mode 100644 index 000000000..87d54ac98 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/emptytable.md @@ -0,0 +1,44 @@ +--- +title: promql.emptyTable() function +description: > + `promql.emptyTable()` returns an empty table, which is used as a helper function to implement + PromQL's [`time()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#time) and + [`vector()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#vector) functions. +menu: + flux_0_x_ref: + name: promql.emptyTable + parent: internal/promql + identifier: internal/promql/emptyTable +weight: 201 +--- + + + +`promql.emptyTable()` returns an empty table, which is used as a helper function to implement +PromQL's [`time()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#time) and +[`vector()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#vector) functions. + + + +##### Function type signature + +```js +() => stream[{_value: float, _time: time, _stop: time, _start: time}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + diff --git a/content/flux/v0.x/stdlib/internal/promql/extrapolatedrate.md b/content/flux/v0.x/stdlib/internal/promql/extrapolatedrate.md new file mode 100644 index 000000000..4bfc9b584 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/extrapolatedrate.md @@ -0,0 +1,76 @@ +--- +title: promql.extrapolatedRate() function +description: > + `promql.extrapolatedRate()` is a helper function that calculates extrapolated rates over + counters and is used to implement PromQL's rate(), delta(), and increase() functions. + extrapolatedRate is a helper function that calculates extrapolated rates over + counters and is used to implement PromQL's + [`rate()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#rate), + [`delta()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#increase), + and [`increase()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#delta) functions. +menu: + flux_0_x_ref: + name: promql.extrapolatedRate + parent: internal/promql + identifier: internal/promql/extrapolatedRate +weight: 201 +--- + + + +`promql.extrapolatedRate()` is a helper function that calculates extrapolated rates over +counters and is used to implement PromQL's rate(), delta(), and increase() functions. +extrapolatedRate is a helper function that calculates extrapolated rates over +counters and is used to implement PromQL's +[`rate()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#rate), +[`delta()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#increase), +and [`increase()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#delta) functions. + + + +##### Function type signature + +```js +( + <-tables: stream[{A with _value: float, _time: time, _stop: time, _start: time}], + ?isCounter: bool, + ?isRate: bool, +) => stream[{B with _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + +### isCounter + +Data represents a counter. + + + +### isRate + +Data represents a rate. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/holtwinters.md b/content/flux/v0.x/stdlib/internal/promql/holtwinters.md new file mode 100644 index 000000000..1b06660fe --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/holtwinters.md @@ -0,0 +1,66 @@ +--- +title: promql.holtWinters() function +description: > + `promql.holtWinters()` implements functionality equivalent to + [PromQL's `holt_winters()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#holt_winters). +menu: + flux_0_x_ref: + name: promql.holtWinters + parent: internal/promql + identifier: internal/promql/holtWinters +weight: 201 +--- + + + +`promql.holtWinters()` implements functionality equivalent to +[PromQL's `holt_winters()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#holt_winters). + + + +##### Function type signature + +```js +( + <-tables: stream[{A with _value: float, _time: time}], + ?smoothingFactor: float, + ?trendFactor: float, +) => stream[{B with _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + +### smoothingFactor + +Exponential smoothing factor. + + + +### trendFactor + +Trend factor. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/instantrate.md b/content/flux/v0.x/stdlib/internal/promql/instantrate.md new file mode 100644 index 000000000..19fa5a1f2 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/instantrate.md @@ -0,0 +1,60 @@ +--- +title: promql.instantRate() function +description: > + `promql.instantRate()` is a helper function that calculates instant rates over + counters and is used to implement PromQL's + [`irate()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#irate) and + [`idelta()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#idelta) functions. +menu: + flux_0_x_ref: + name: promql.instantRate + parent: internal/promql + identifier: internal/promql/instantRate +weight: 201 +--- + + + +`promql.instantRate()` is a helper function that calculates instant rates over +counters and is used to implement PromQL's +[`irate()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#irate) and +[`idelta()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#idelta) functions. + + + +##### Function type signature + +```js +(<-tables: stream[{A with _value: float, _time: time}], ?isRate: bool) => stream[{B with _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Defaults is piped-forward data (`<-`). + + + +### isRate + +Data represents a rate. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/join.md b/content/flux/v0.x/stdlib/internal/promql/join.md new file mode 100644 index 000000000..1a19b6a82 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/join.md @@ -0,0 +1,64 @@ +--- +title: promql.join() function +description: > + `promql.join()` joins two streams of tables on the **group key and `_time` column**. + See `experimental.join`. +menu: + flux_0_x_ref: + name: promql.join + parent: internal/promql + identifier: internal/promql/join +weight: 201 +--- + + + +`promql.join()` joins two streams of tables on the **group key and `_time` column**. +See `experimental.join`. + + + +##### Function type signature + +```js +(fn: (left: A, right: B) => C, left: stream[A], right: stream[B]) => stream[C] where A: Record, B: Record, C: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### left +({{< req >}}) +First of two streams of tables to join. + + + +### right +({{< req >}}) +Second of two streams of tables to join. + + + +### fn +({{< req >}}) +Function with left and right arguments that maps a new output record +using values from the `left` and `right` input records. +The return value must be a record. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/labelreplace.md b/content/flux/v0.x/stdlib/internal/promql/labelreplace.md new file mode 100644 index 000000000..760387b1e --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/labelreplace.md @@ -0,0 +1,80 @@ +--- +title: promql.labelReplace() function +description: > + `promql.labelReplace()` implements functionality equivalent to + [PromQL's `label_replace()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#label_replace). +menu: + flux_0_x_ref: + name: promql.labelReplace + parent: internal/promql + identifier: internal/promql/labelReplace +weight: 201 +--- + + + +`promql.labelReplace()` implements functionality equivalent to +[PromQL's `label_replace()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#label_replace). + + + +##### Function type signature + +```js +( + <-tables: stream[{A with _value: float}], + destination: string, + regex: string, + replacement: string, + source: string, +) => stream[{B with _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + +### source +({{< req >}}) +Input label. + + + +### destination +({{< req >}}) +Output label. + + + +### regex +({{< req >}}) +Pattern as a regex string. + + + +### replacement +({{< req >}}) +Replacement value. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/linearregression.md b/content/flux/v0.x/stdlib/internal/promql/linearregression.md new file mode 100644 index 000000000..c74c7aea6 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/linearregression.md @@ -0,0 +1,67 @@ +--- +title: promql.linearRegression() function +description: > + `promql.linearRegression()` implements linear regression functionality required to implement + PromQL's deriv() and predict_linear() functions: +menu: + flux_0_x_ref: + name: promql.linearRegression + parent: internal/promql + identifier: internal/promql/linearRegression +weight: 201 +--- + + + +`promql.linearRegression()` implements linear regression functionality required to implement +PromQL's deriv() and predict_linear() functions: + +https://prometheus.io/docs/prometheus/latest/querying/functions/#deriv +https://prometheus.io/docs/prometheus/latest/querying/functions/#predict_linear + +##### Function type signature + +```js +( + <-tables: stream[{A with _value: float, _time: time, _stop: time}], + ?fromNow: float, + ?predict: bool, +) => stream[{B with _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + +### predict + +Output should contain a prediction. + + + +### fromNow + +Time as a floating point value. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/promhistogramquantile.md b/content/flux/v0.x/stdlib/internal/promql/promhistogramquantile.md new file mode 100644 index 000000000..584a8f5d4 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/promhistogramquantile.md @@ -0,0 +1,80 @@ +--- +title: promql.promHistogramQuantile() function +description: > + `promql.promHistogramQuantile()` implements functionality equivalent to + [PromQL's `histogram_quantile()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile). +menu: + flux_0_x_ref: + name: promql.promHistogramQuantile + parent: internal/promql + identifier: internal/promql/promHistogramQuantile +weight: 201 +--- + + + +`promql.promHistogramQuantile()` implements functionality equivalent to +[PromQL's `histogram_quantile()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile). + + + +##### Function type signature + +```js +( + <-tables: stream[A], + ?countColumn: string, + ?quantile: float, + ?upperBoundColumn: string, + ?valueColumn: string, +) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + +### quantile + +Quantile to compute (`[0.0 - 1.0]`). + + + +### countColumn + +Count column name. + + + +### upperBoundColumn + +Upper bound column name. + + + +### valueColumn + +Output value column name. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/promqldayofmonth.md b/content/flux/v0.x/stdlib/internal/promql/promqldayofmonth.md new file mode 100644 index 000000000..cdc389b8b --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/promqldayofmonth.md @@ -0,0 +1,50 @@ +--- +title: promql.promqlDayOfMonth() function +description: > + `promql.promqlDayOfMonth()` implements functionality equivalent to + [PromQL's `day_of_month()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#day_of_month). +menu: + flux_0_x_ref: + name: promql.promqlDayOfMonth + parent: internal/promql + identifier: internal/promql/promqlDayOfMonth +weight: 201 +--- + + + +`promql.promqlDayOfMonth()` implements functionality equivalent to +[PromQL's `day_of_month()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#day_of_month). + + + +##### Function type signature + +```js +(timestamp: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### timestamp +({{< req >}}) +Time as a floating point value. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/promqldayofweek.md b/content/flux/v0.x/stdlib/internal/promql/promqldayofweek.md new file mode 100644 index 000000000..9ccbd6d7f --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/promqldayofweek.md @@ -0,0 +1,50 @@ +--- +title: promql.promqlDayOfWeek() function +description: > + `promql.promqlDayOfWeek()` implements functionality equivalent to + [PromQL's `day_of_week()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#day_of_week). +menu: + flux_0_x_ref: + name: promql.promqlDayOfWeek + parent: internal/promql + identifier: internal/promql/promqlDayOfWeek +weight: 201 +--- + + + +`promql.promqlDayOfWeek()` implements functionality equivalent to +[PromQL's `day_of_week()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#day_of_week). + + + +##### Function type signature + +```js +(timestamp: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### timestamp +({{< req >}}) +Time as a floating point value. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/promqldaysinmonth.md b/content/flux/v0.x/stdlib/internal/promql/promqldaysinmonth.md new file mode 100644 index 000000000..62ce1a1f7 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/promqldaysinmonth.md @@ -0,0 +1,50 @@ +--- +title: promql.promqlDaysInMonth() function +description: > + `promql.promqlDaysInMonth()` implements functionality equivalent to + [PromQL's `days_in_month()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#days_in_month). +menu: + flux_0_x_ref: + name: promql.promqlDaysInMonth + parent: internal/promql + identifier: internal/promql/promqlDaysInMonth +weight: 201 +--- + + + +`promql.promqlDaysInMonth()` implements functionality equivalent to +[PromQL's `days_in_month()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#days_in_month). + + + +##### Function type signature + +```js +(timestamp: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### timestamp +({{< req >}}) +Time as a floating point value. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/promqlhour.md b/content/flux/v0.x/stdlib/internal/promql/promqlhour.md new file mode 100644 index 000000000..367a2bf47 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/promqlhour.md @@ -0,0 +1,50 @@ +--- +title: promql.promqlHour() function +description: > + `promql.promqlHour()` implements functionality equivalent to + [PromQL's `hour()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#hour). +menu: + flux_0_x_ref: + name: promql.promqlHour + parent: internal/promql + identifier: internal/promql/promqlHour +weight: 201 +--- + + + +`promql.promqlHour()` implements functionality equivalent to +[PromQL's `hour()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#hour). + + + +##### Function type signature + +```js +(timestamp: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### timestamp +({{< req >}}) +Time as a floating point value. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/promqlminute.md b/content/flux/v0.x/stdlib/internal/promql/promqlminute.md new file mode 100644 index 000000000..717a76b55 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/promqlminute.md @@ -0,0 +1,50 @@ +--- +title: promql.promqlMinute() function +description: > + `promql.promqlMinute()` implements functionality equivalent to + [PromQL's `minute()` function]( https://prometheus.io/docs/prometheus/latest/querying/functions/#minute). +menu: + flux_0_x_ref: + name: promql.promqlMinute + parent: internal/promql + identifier: internal/promql/promqlMinute +weight: 201 +--- + + + +`promql.promqlMinute()` implements functionality equivalent to +[PromQL's `minute()` function]( https://prometheus.io/docs/prometheus/latest/querying/functions/#minute). + + + +##### Function type signature + +```js +(timestamp: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### timestamp +({{< req >}}) +Time as a floating point value. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/promqlmonth.md b/content/flux/v0.x/stdlib/internal/promql/promqlmonth.md new file mode 100644 index 000000000..4d8fd2b06 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/promqlmonth.md @@ -0,0 +1,50 @@ +--- +title: promql.promqlMonth() function +description: > + `promql.promqlMonth()` implements functionality equivalent to + [PromQL's `month()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#month). +menu: + flux_0_x_ref: + name: promql.promqlMonth + parent: internal/promql + identifier: internal/promql/promqlMonth +weight: 201 +--- + + + +`promql.promqlMonth()` implements functionality equivalent to +[PromQL's `month()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#month). + + + +##### Function type signature + +```js +(timestamp: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### timestamp +({{< req >}}) +Time as a floating point value. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/promqlyear.md b/content/flux/v0.x/stdlib/internal/promql/promqlyear.md new file mode 100644 index 000000000..e9bf29cd2 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/promqlyear.md @@ -0,0 +1,50 @@ +--- +title: promql.promqlYear() function +description: > + `promql.promqlYear()` implements functionality equivalent to + [PromQL's `year()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#year). +menu: + flux_0_x_ref: + name: promql.promqlYear + parent: internal/promql + identifier: internal/promql/promqlYear +weight: 201 +--- + + + +`promql.promqlYear()` implements functionality equivalent to +[PromQL's `year()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#year). + + + +##### Function type signature + +```js +(timestamp: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### timestamp +({{< req >}}) +Time as a floating point value. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/quantile.md b/content/flux/v0.x/stdlib/internal/promql/quantile.md new file mode 100644 index 000000000..4507eb3e7 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/quantile.md @@ -0,0 +1,64 @@ +--- +title: promql.quantile() function +description: > + `promql.quantile()` accounts checks for quantile values that are out of range, above 1.0 or + below 0.0, by either returning positive infinity or negative infinity in the `_value` + column respectively. `q` must be a float. +menu: + flux_0_x_ref: + name: promql.quantile + parent: internal/promql + identifier: internal/promql/quantile +weight: 201 +--- + + + +`promql.quantile()` accounts checks for quantile values that are out of range, above 1.0 or +below 0.0, by either returning positive infinity or negative infinity in the `_value` +column respectively. `q` must be a float. + + + +##### Function type signature + +```js +(<-tables: stream[A], q: float, ?method: string) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Default is piped-forward data (`<-`). + + + +### q +({{< req >}}) +Quantile to compute (`[0.0 - 1.0]`). + + + +### method + +Quantile method to use. + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/resets.md b/content/flux/v0.x/stdlib/internal/promql/resets.md new file mode 100644 index 000000000..0f7007ac0 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/resets.md @@ -0,0 +1,50 @@ +--- +title: promql.resets() function +description: > + `promql.resets()` implements functionality equivalent to + [PromQL's `resets()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#resets). +menu: + flux_0_x_ref: + name: promql.resets + parent: internal/promql + identifier: internal/promql/resets +weight: 201 +--- + + + +`promql.resets()` implements functionality equivalent to +[PromQL's `resets()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#resets). + + + +##### Function type signature + +```js +(<-tables: stream[{A with _value: float}]) => stream[{B with _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Defaults is piped-forward data (`<-`). + + + diff --git a/content/flux/v0.x/stdlib/internal/promql/timestamp.md b/content/flux/v0.x/stdlib/internal/promql/timestamp.md new file mode 100644 index 000000000..5df1df1a9 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/promql/timestamp.md @@ -0,0 +1,50 @@ +--- +title: promql.timestamp() function +description: > + `promql.timestamp()` implements functionality equivalent to + [PromQL's `timestamp()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#timestamp). +menu: + flux_0_x_ref: + name: promql.timestamp + parent: internal/promql + identifier: internal/promql/timestamp +weight: 201 +--- + + + +`promql.timestamp()` implements functionality equivalent to +[PromQL's `timestamp()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#timestamp). + + + +##### Function type signature + +```js +(<-tables: stream[{A with _value: float}]) => stream[{A with _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### tables + +Input data. Defaults is piped-forward data (`<-`). + + + diff --git a/content/flux/v0.x/stdlib/internal/testutil/_index.md b/content/flux/v0.x/stdlib/internal/testutil/_index.md new file mode 100644 index 000000000..f53174b73 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/testutil/_index.md @@ -0,0 +1,41 @@ +--- +title: testutil package +description: > + The `testutil` package provides helper function for writing test cases. +menu: + flux_0_x_ref: + name: testutil + parent: internal + identifier: internal/testutil +weight: 21 +--- + + + +The `testutil` package provides helper function for writing test cases. +Import the `internal/testutil` package: + +```js +import "internal/testutil" +``` + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/internal/testutil/fail.md b/content/flux/v0.x/stdlib/internal/testutil/fail.md new file mode 100644 index 000000000..f2ad7dbef --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/testutil/fail.md @@ -0,0 +1,40 @@ +--- +title: testutil.fail() function +description: > + `testutil.fail()` causes the current script to fail. +menu: + flux_0_x_ref: + name: testutil.fail + parent: internal/testutil + identifier: internal/testutil/fail +weight: 201 +--- + + + +`testutil.fail()` causes the current script to fail. + + + +##### Function type signature + +```js +() => bool +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + diff --git a/content/flux/v0.x/stdlib/internal/testutil/makeany.md b/content/flux/v0.x/stdlib/internal/testutil/makeany.md new file mode 100644 index 000000000..ff0280834 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/testutil/makeany.md @@ -0,0 +1,48 @@ +--- +title: testutil.makeAny() function +description: > + `testutil.makeAny()` constructs any value based on a type description as a string. +menu: + flux_0_x_ref: + name: testutil.makeAny + parent: internal/testutil + identifier: internal/testutil/makeAny +weight: 201 +--- + + + +`testutil.makeAny()` constructs any value based on a type description as a string. + + + +##### Function type signature + +```js +(typ: string) => A +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### typ +({{< req >}}) +Description of the type to create. + + + diff --git a/content/flux/v0.x/stdlib/internal/testutil/makerecord.md b/content/flux/v0.x/stdlib/internal/testutil/makerecord.md new file mode 100644 index 000000000..eeedd6e67 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/testutil/makerecord.md @@ -0,0 +1,48 @@ +--- +title: testutil.makeRecord() function +description: > + `testutil.makeRecord()` is the identity function, but breaks the type connection from input to output. +menu: + flux_0_x_ref: + name: testutil.makeRecord + parent: internal/testutil + identifier: internal/testutil/makeRecord +weight: 201 +--- + + + +`testutil.makeRecord()` is the identity function, but breaks the type connection from input to output. + + + +##### Function type signature + +```js +(o: A) => B where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### o +({{< req >}}) +Record value. + + + diff --git a/content/flux/v0.x/stdlib/internal/testutil/yield.md b/content/flux/v0.x/stdlib/internal/testutil/yield.md new file mode 100644 index 000000000..2c38d4e82 --- /dev/null +++ b/content/flux/v0.x/stdlib/internal/testutil/yield.md @@ -0,0 +1,48 @@ +--- +title: testutil.yield() function +description: > + `testutil.yield()` is the identity function. +menu: + flux_0_x_ref: + name: testutil.yield + parent: internal/testutil + identifier: internal/testutil/yield +weight: 201 +--- + + + +`testutil.yield()` is the identity function. + + + +##### Function type signature + +```js +(<-v: A) => A +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### v + +Any value. + + + diff --git a/content/flux/v0.x/stdlib/interpolate/_index.md b/content/flux/v0.x/stdlib/interpolate/_index.md index 4d2ed9017..9b41ae3cf 100644 --- a/content/flux/v0.x/stdlib/interpolate/_index.md +++ b/content/flux/v0.x/stdlib/interpolate/_index.md @@ -1,28 +1,46 @@ --- -title: Flux interpolate package -list_title: interpolate package +title: interpolate package description: > - The Flux `interpolate` package provides functions that insert rows for missing - data at regular intervals and estimate values using different interpolation methods. - Import the `interpolate` package. + The `interpolate` package provides functions that insert rows for missing data + at regular intervals and estimate values using different interpolation methods. menu: flux_0_x_ref: - name: interpolate - parent: Standard library -aliases: - - /influxdb/v2.0/reference/flux/stdlib/interpolate/ - - /influxdb/cloud/reference/flux/stdlib/interpolate/ + name: interpolate + parent: stdlib + identifier: interpolate weight: 11 -introduced: 0.87.0 +cascade: + + introduced: 0.87.0 --- -The `interpolate` package provides functions that insert rows for missing -data at regular intervals and estimate values using different interpolation methods. + + +The `interpolate` package provides functions that insert rows for missing data +at regular intervals and estimate values using different interpolation methods. Import the `interpolate` package: ```js import "interpolate" ``` + + + ## Functions -{{< children type="articles" show="pages" >}} + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/interpolate/linear.md b/content/flux/v0.x/stdlib/interpolate/linear.md index 3e36fa0d5..c50ca7458 100644 --- a/content/flux/v0.x/stdlib/interpolate/linear.md +++ b/content/flux/v0.x/stdlib/interpolate/linear.md @@ -1,47 +1,67 @@ --- title: interpolate.linear() function description: > - The `interpolate.linear` function inserts rows at regular intervals using - **linear interpolation** to determine values for inserted rows. + `interpolate.linear()` inserts rows at regular intervals using linear interpolation to + determine values for inserted rows. menu: flux_0_x_ref: name: interpolate.linear parent: interpolate + identifier: interpolate/linear weight: 101 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/interpolate/linear/ - - /influxdb/cloud/reference/flux/stdlib/interpolate/linear/ -introduced: 0.87.0 -list_query_example: interpolate_linear +flux/v0.x/tags: [transformations] --- -The `interpolate.linear` function inserts rows at regular intervals using -[linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation) -to determine values for inserted rows. + + +`interpolate.linear()` inserts rows at regular intervals using linear interpolation to +determine values for inserted rows. + +### Function requirements +- Input data must have `_time` and `_value` columns. +- All columns other than `_time` and `_value` must be part of the group key. + +##### Function type signature ```js -import "interpolate" - -interpolate.linear(every: 1m) +(<-tables: stream[{A with _value: float, _time: time}], every: duration) => stream[{A with _value: float, _time: time}] ``` -#### Function requirements -- Input data must have `_time` and `_value` columns. -- `_value` column must be of type `float`. -- **All columns** other than `_time` and `_value` must be part of the group key. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### every {data-type="duration"} +### every +({{< req >}}) Duration of time between interpolated points. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples ### Interpolate missing data by day + ```js import "interpolate" @@ -49,32 +69,34 @@ data |> interpolate.linear(every: 1d) ``` -{{< flex >}} -{{% flex-content %}} -##### Input -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 10.0 | -| 2021-01-02T00:00:00Z | 20.0 | -| 2021-01-04T00:00:00Z | 40.0 | -| 2021-01-05T00:00:00Z | 50.0 | -| 2021-01-08T00:00:00Z | 80.0 | -| 2021-01-09T00:00:00Z | 90.0 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output -| _time | _value | -|:----- | ------:| -| 2021-01-01T00:00:00Z | 10.0 | -| 2021-01-02T00:00:00Z | 20.0 | -| 2021-01-03T00:00:00Z | 30.0 | -| 2021-01-04T00:00:00Z | 40.0 | -| 2021-01-05T00:00:00Z | 50.0 | -| 2021-01-06T00:00:00Z | 60.0 | -| 2021-01-07T00:00:00Z | 70.0 | -| 2021-01-08T00:00:00Z | 80.0 | -| 2021-01-09T00:00:00Z | 90.0 | -{{% /flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -{{< /flex >}} +#### Input data +| _time | _value | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | 10 | +| 2021-01-02T00:00:00Z | 20 | +| 2021-01-04T00:00:00Z | 40 | +| 2021-01-05T00:00:00Z | 50 | +| 2021-01-08T00:00:00Z | 80 | +| 2021-01-09T00:00:00Z | 90 | + + +#### Output data + +| _time | _value | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | 10 | +| 2021-01-02T00:00:00Z | 20 | +| 2021-01-03T00:00:00Z | 30 | +| 2021-01-04T00:00:00Z | 40 | +| 2021-01-05T00:00:00Z | 50 | +| 2021-01-06T00:00:00Z | 60 | +| 2021-01-07T00:00:00Z | 70 | +| 2021-01-08T00:00:00Z | 80 | +| 2021-01-09T00:00:00Z | 90 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/join/_index.md b/content/flux/v0.x/stdlib/join/_index.md new file mode 100644 index 000000000..4a9148b4b --- /dev/null +++ b/content/flux/v0.x/stdlib/join/_index.md @@ -0,0 +1,41 @@ +--- +title: join package +description: > + The `join` package is under active development and is not yet ready for public consumption. +menu: + flux_0_x_ref: + name: join + parent: stdlib + identifier: join +weight: 11 +--- + + + +The `join` package is under active development and is not yet ready for public consumption. +Import the `join` package: + +```js +import "join" +``` + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/join/join.md b/content/flux/v0.x/stdlib/join/join.md new file mode 100644 index 000000000..fa95f51b6 --- /dev/null +++ b/content/flux/v0.x/stdlib/join/join.md @@ -0,0 +1,78 @@ +--- +title: join.join() function +description: > + `join.join()` is under active development and is not yet ready for public consumption. +menu: + flux_0_x_ref: + name: join.join + parent: join + identifier: join/join +weight: 101 +--- + + + +`join.join()` is under active development and is not yet ready for public consumption. + + + +##### Function type signature + +```js +( + <-left: stream[A], + as: (l: A, r: B) => C, + method: string, + on: (l: A, r: B) => bool, + right: stream[B], +) => stream[C] where A: Record, B: Record, C: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### left + +left: + + + +### right +({{< req >}}) +right: + + + +### on +({{< req >}}) +on: + + + +### as +({{< req >}}) +as: + + + +### method +({{< req >}}) +method: + + + diff --git a/content/flux/v0.x/stdlib/json/_index.md b/content/flux/v0.x/stdlib/json/_index.md index 59e2bbbab..bc9f152bf 100644 --- a/content/flux/v0.x/stdlib/json/_index.md +++ b/content/flux/v0.x/stdlib/json/_index.md @@ -1,28 +1,44 @@ --- -title: Flux json package -list_title: json package +title: json package description: > - The Flux `json` package provides functions for working with JSON. - Import the `json` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/json/ - - /influxdb/v2.0/reference/flux/stdlib/json/ - - /influxdb/cloud/reference/flux/stdlib/json/ + The `json` package provides tools for working with JSON. menu: flux_0_x_ref: - name: json - parent: Standard library + name: json + parent: stdlib + identifier: json weight: 11 -flux/v0.x/tags: [functions, json, package] -introduced: 0.40.0 +cascade: + + introduced: 0.40.0 --- -The Flux `json` package provides functions for working with JSON. + + +The `json` package provides tools for working with JSON. Import the `json` package: ```js import "json" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/json/encode.md b/content/flux/v0.x/stdlib/json/encode.md index 5772699fd..0c2d10de9 100644 --- a/content/flux/v0.x/stdlib/json/encode.md +++ b/content/flux/v0.x/stdlib/json/encode.md @@ -1,37 +1,71 @@ --- title: json.encode() function -description: The `json.encode()` function converts a value into JSON bytes. -aliases: - - /influxdb/v2.0/reference/flux/functions/json/encode/ - - /influxdb/v2.0/reference/flux/stdlib/json/encode/ - - /influxdb/cloud/reference/flux/stdlib/json/encode/ +description: > + `json.encode()` converts a value into JSON bytes. menu: flux_0_x_ref: name: json.encode parent: json -weight: 202 + identifier: json/encode +weight: 101 flux/v0.x/tags: [type-conversions] -introduced: 0.40.0 --- -The `json.encode()` function converts a value into JSON bytes. + + +`json.encode()` converts a value into JSON bytes. + +This function encodes Flux types as follows: + +- **time** values in [RFC3339](https://docs.influxdata.com/influxdb/cloud/reference/glossary/#rfc3339-timestamp) format +- **duration** values in number of milliseconds since the Unix epoch +- **regexp** values as their string representation +- **bytes** values as base64-encoded strings +- **function** values are not encoded and produce an error + +##### Function type signature + +```js +(v: A) => bytes +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### v +({{< req >}}) +Value to convert. + + + + +## Examples + +### Encode a value as JSON bytes ```js import "json" -json.encode(v: "some value") -// Returns [34 115 111 109 101 32 118 97 108 117 101 34] +jsonData = {foo: "bar", baz: 123, quz: [4, 5, 6]} + +json.encode( + v: jsonData, +)// Returns [123 34 98 97 122 34 58 49 50 51 44 34 102 111 111 34 58 34 98 97 114 34 44 34 113 117 122 34 58 91 52 44 53 44 54 93 125] + ``` -This function encodes [Flux types](/flux/v0.x/spec/types/) as follows: - -- `time` values in [RFC3339](/influxdb/cloud/reference/glossary/#rfc3339-timestamp) format -- `duration` values in number of milliseconds since the epoch -- `regexp` values as their string representation -- `bytes` values as base64-encoded strings -- `function` values are not encoded and produce an error - -## Parameters - -### v {data-type="record, array, dict, string, bool, duration, int, uint, float, time"} -The value to convert. diff --git a/content/flux/v0.x/stdlib/kafka/_index.md b/content/flux/v0.x/stdlib/kafka/_index.md new file mode 100644 index 000000000..0afb757a6 --- /dev/null +++ b/content/flux/v0.x/stdlib/kafka/_index.md @@ -0,0 +1,44 @@ +--- +title: kafka package +description: > + The `kafka` package provides tools for working with [Apache Kafka](https://kafka.apache.org/). +menu: + flux_0_x_ref: + name: kafka + parent: stdlib + identifier: kafka +weight: 11 +cascade: + flux/v0.x/tags: [kafka] + introduced: 0.14.0 +--- + + + +The `kafka` package provides tools for working with [Apache Kafka](https://kafka.apache.org/). +Import the `kafka` package: + +```js +import "kafka" +``` + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/kafka/to.md b/content/flux/v0.x/stdlib/kafka/to.md new file mode 100644 index 000000000..f761aee58 --- /dev/null +++ b/content/flux/v0.x/stdlib/kafka/to.md @@ -0,0 +1,133 @@ +--- +title: kafka.to() function +description: > + `kafka.to()` sends data to [Apache Kafka](https://kafka.apache.org/) brokers. +menu: + flux_0_x_ref: + name: kafka.to + parent: kafka + identifier: kafka/to +weight: 101 +flux/v0.x/tags: [outputs] +--- + + + +`kafka.to()` sends data to [Apache Kafka](https://kafka.apache.org/) brokers. + + + +##### Function type signature + +```js +( + <-tables: stream[A], + brokers: [string], + topic: string, + ?balancer: string, + ?name: string, + ?nameColumn: string, + ?tagColumns: [string], + ?timeColumn: string, + ?valueColumns: [string], +) => stream[A] where A: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### brokers +({{< req >}}) +List of Kafka brokers to send data to. + + + +### topic +({{< req >}}) +Kafka topic to send data to. + + + +### balancer + +Kafka load balancing strategy. Default is `hash`. + +The load balancing strategy determines how messages are routed to partitions +available on a Kafka cluster. The following strategies are available: +- **hash**: Uses a hash of the group key to determine which Kafka +partition to route messages to. This ensures that messages generated from +rows in the table are routed to the same partition. +- **round-robin**: Equally distributes messages across all available partitions. +- **least-bytes**: Routes messages to the partition that has received the +least amount of data. + +### name + +Kafka metric name. Default is the value of the `nameColumn`. + + + +### nameColumn + +Column to use as the Kafka metric name. +Default is `_measurement`. + + + +### timeColumn + +Time column. Default is `_time`. + + + +### tagColumns + +List of tag columns in input data. + + + +### valueColumns + +List of value columns in input data. Default is `["_value"]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +### Send data to Kafka + +```js +import "kafka" +import "sampledata" + +sampledata.int() + |> kafka.to( + brokers: ["http://127.0.0.1:9092"], + topic: "example-topic", + name: "example-metric-name", + tagColumns: ["tag"], + ) +``` + diff --git a/content/flux/v0.x/stdlib/math/_index.md b/content/flux/v0.x/stdlib/math/_index.md index e444fdab2..47ea79adc 100644 --- a/content/flux/v0.x/stdlib/math/_index.md +++ b/content/flux/v0.x/stdlib/math/_index.md @@ -1,54 +1,80 @@ --- -title: Flux math package -list_title: math package +title: math package description: > - The Flux `math` package provides basic constants and mathematical functions. - Import the `math` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/ - - /influxdb/v2.0/reference/flux/stdlib/math/ - - /influxdb/cloud/reference/flux/stdlib/math/ + The `math` package provides basic constants and mathematical functions menu: flux_0_x_ref: - name: math - parent: Standard library + name: math + parent: stdlib + identifier: math weight: 11 -flux/v0.x/tags: [math, functions] -related: - - /{{< latest "influxdb" >}}/query-data/flux/mathematic-operations/ -introduced: 0.22.0 +cascade: + + introduced: 0.22.0 --- -The Flux `math` package provides basic constants and mathematical functions. -Import the `math` package. + + +The `math` package provides basic constants and mathematical functions +Import the `math` package: ```js import "math" ``` -## Mathematical constants -That `math` package includes the following mathematical constants. +## Constants ```js -math.e = 2.71828182845904523536028747135266249775724709369995957496696763 // https ://oeis.org/A001113 -math.pi = 3.14159265358979323846264338327950288419716939937510582097494459 // https ://oeis.org/A000796 -math.phi = 1.61803398874989484820458683436563811772030917980576286213544862 // https ://oeis.org/A001622 - -math.sqrt2 = 1.41421356237309504880168872420969807856967187537694807317667974 // https ://oeis.org/A002193 -math.sqrte = 1.64872127070012814684865078781416357165377610071014801157507931 // https ://oeis.org/A019774 -math.sqrtpi = 1.77245385090551602729816748334114518279754945612238712821380779 // https ://oeis.org/A002161 -math.sqrtphi = 1.27201964951406896425242246173749149171560804184009624861664038 // https ://oeis.org/A139339 - -math.ln2 = 0.693147180559945309417232121458176568075500134360255254120680009 // https://oeis.org/A002162 -math.log2e = 1 ÷ math.ln2 -math.ln10 = 2.30258509299404568401799145468436420760110148862877297603332790 // https ://oeis.org/A002392 -math.log10e = 1 ÷ math.ln10 - -math.maxfloat = 1.797693134862315708145274237317043567981e+308 // 2**1023 * (2**53 - 1) / 2**52 -math.maxint = 1<<63 - 1 -math.minint = -1 << 63 -math.maxuint = 1<<64 - 1 +math.e +math.ln10 +math.ln2 +math.log10e +math.log2e +math.maxfloat +math.maxint +math.maxuint +math.minint +math.phi +math.pi +math.smallestNonzeroFloat +math.sqrt2 +math.sqrte +math.sqrtphi +math.sqrtpi ``` -## Mathematical functions +- **math.e** represents the base of the natural logarithm, also known as Euler's number. +- **math.ln10** represents the natural logarithm of 10. +- **math.ln2** represents the natural logarithm of 2. +- **math.log10e** represents the base 10 logarithm of **e** (`math.e`). +- **math.log2e** represents the base 2 logarithm of **e** (`math.e`). +- **math.maxfloat** represents the maximum float value. +- **math.maxint** represents the maximum integer value (`2^63 - 1`). +- **math.maxuint** representes the maximum unsigned integer value (`2^64 - 1`). +- **math.minint** represents the minimum integer value (`-2^63`). +- **math.phi** represents the [Golden Ratio](https://www.britannica.com/science/golden-ratio). +- **math.pi** represents pi (π). +- **math.smallestNonzeroFloat** represents the smallest nonzero float value. +- **math.sqrt2** represents the square root of 2. +- **math.sqrte** represents the square root of **e** (`math.e`). +- **math.sqrtphi** represents the square root of phi (`math.phi`), the Golden Ratio. +- **math.sqrtpi** represents the square root of pi (π). + + +## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/math/abs.md b/content/flux/v0.x/stdlib/math/abs.md index 2c00184be..5e5a0c720 100644 --- a/content/flux/v0.x/stdlib/math/abs.md +++ b/content/flux/v0.x/stdlib/math/abs.md @@ -1,37 +1,115 @@ --- title: math.abs() function -description: The math.abs() function returns the absolute value of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/abs/ - - /influxdb/v2.0/reference/flux/stdlib/math/abs/ - - /influxdb/cloud/reference/flux/stdlib/math/abs/ +description: > + `math.abs()` returns the absolute value of `x`. menu: flux_0_x_ref: name: math.abs parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/abs +weight: 101 --- -The `math.abs()` function returns the absolute value of `x`. + + +`math.abs()` returns the absolute value of `x`. + + + +##### Function type signature ```js -import "math" - -math.abs(x: -1.22) - -// Returns 1.22 +(x: float) => float ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### x {data-type="float"} -The value used in the operation. +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the absolute value](#return-the-absolute-value) +- [Use math.abs in map](#use-mathabs-in-map) + +### Return the absolute value -## Special cases ```js -math.abs(x: ±Inf) // Returns +Inf -math.abs(x: NaN) // Returns NaN +math.abs(x: -1.22)// 1.22 + ``` + + +### Use math.abs in map + +```js +sampledata.float() + |> map(fn: (r) => ({r with _value: math.abs(x: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2.18 | t1 | +| 2021-01-01T00:00:10Z | 10.92 | t1 | +| 2021-01-01T00:00:20Z | 7.35 | t1 | +| 2021-01-01T00:00:30Z | 17.53 | t1 | +| 2021-01-01T00:00:40Z | 15.23 | t1 | +| 2021-01-01T00:00:50Z | 4.43 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19.85 | t2 | +| 2021-01-01T00:00:10Z | 4.97 | t2 | +| 2021-01-01T00:00:20Z | 3.75 | t2 | +| 2021-01-01T00:00:30Z | 19.77 | t2 | +| 2021-01-01T00:00:40Z | 13.86 | t2 | +| 2021-01-01T00:00:50Z | 1.86 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/acos.md b/content/flux/v0.x/stdlib/math/acos.md index 11c4a8786..957dd63c1 100644 --- a/content/flux/v0.x/stdlib/math/acos.md +++ b/content/flux/v0.x/stdlib/math/acos.md @@ -1,38 +1,120 @@ --- title: math.acos() function -description: The math.acos() function returns the arccosine of `x` in radians. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/acos/ - - /influxdb/v2.0/reference/flux/stdlib/math/acos/ - - /influxdb/cloud/reference/flux/stdlib/math/acos/ +description: > + `math.acos()` returns the acosine of `x` in radians. menu: flux_0_x_ref: name: math.acos parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/acos +weight: 101 --- -The `math.acos()` function returns the arccosine of `x` in radians. + + +`math.acos()` returns the acosine of `x` in radians. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + +`x` should be greater than -1 and less than 1. Otherwise, the operation +will return `NaN`. + + +## Examples + +- [Return the acosine of a value](#return-the-acosine-of-a-value) +- [Use math.acos in map](#use-mathacos-in-map) + +### Return the acosine of a value ```js import "math" -math.acos(x: 0.22) +math.acos(x: 0.22)// 1.3489818562981022 -// Returns 1.3489818562981022 ``` -## Parameters -### x {data-type="float"} -`x` should be greater than -1 and less than 1. -Otherwise, the operation will return `NaN`. +### Use math.acos in map -## Special cases ```js -math.acos(x: <-1) // Returns NaN -math.acos(x: >1) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({r with _value: math.acos(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | --------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.021800000000000003 | t1 | +| 2021-01-01T00:00:10Z | 0.1092 | t1 | +| 2021-01-01T00:00:20Z | 0.0735 | t1 | +| 2021-01-01T00:00:30Z | 0.1753 | t1 | +| 2021-01-01T00:00:40Z | 0.15230000000000002 | t1 | +| 2021-01-01T00:00:50Z | 0.0443 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.1985 | t2 | +| 2021-01-01T00:00:10Z | 0.0497 | t2 | +| 2021-01-01T00:00:20Z | -0.0375 | t2 | +| 2021-01-01T00:00:30Z | 0.1977 | t2 | +| 2021-01-01T00:00:40Z | 0.1386 | t2 | +| 2021-01-01T00:00:50Z | 0.018600000000000002 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | 1.592598053869604 | t1 | +| 2021-01-01T00:00:10Z | 1.461378125419181 | t1 | +| 2021-01-01T00:00:20Z | 1.4972299878346804 | t1 | +| 2021-01-01T00:00:30Z | 1.3945858483452276 | t1 | +| 2021-01-01T00:00:40Z | 1.417901321254124 | t1 | +| 2021-01-01T00:00:50Z | 1.5264818242659286 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | 1.3709690985581462 | t2 | +| 2021-01-01T00:00:10Z | 1.5210758434398064 | t2 | +| 2021-01-01T00:00:20Z | 1.6083051214238853 | t2 | +| 2021-01-01T00:00:30Z | 1.3717852736930785 | t2 | +| 2021-01-01T00:00:40Z | 1.4317486962850596 | t2 | +| 2021-01-01T00:00:50Z | 1.5521952541518969 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/acosh.md b/content/flux/v0.x/stdlib/math/acosh.md index 653e9432a..421f91d40 100644 --- a/content/flux/v0.x/stdlib/math/acosh.md +++ b/content/flux/v0.x/stdlib/math/acosh.md @@ -1,39 +1,118 @@ --- title: math.acosh() function -description: The math.acosh() function returns the inverse hyperbolic cosine of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/acosh/ - - /influxdb/v2.0/reference/flux/stdlib/math/acosh/ - - /influxdb/cloud/reference/flux/stdlib/math/acosh/ +description: > + `math.acosh()` returns the inverse hyperbolic cosine of `x`. menu: flux_0_x_ref: name: math.acosh parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/acosh +weight: 101 --- -The `math.acosh()` function returns the inverse hyperbolic cosine of `x`. + + +`math.acosh()` returns the inverse hyperbolic cosine of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + +`x` should be greater than 1. If less than 1 the operation will return `NaN`. + + +## Examples + +- [Return the inverse hyperbolic cosine of a value](#return-the-inverse-hyperbolic-cosine-of-a-value) +- [Use math.acosh in map](#use-mathacosh-in-map) + +### Return the inverse hyperbolic cosine of a value ```js import "math" math.acosh(x: 1.22) - -// Returns 0.6517292837263385 ``` -## Parameters -### x {data-type="float"} -`x` should be greater than 1. -If less than 1, the operation will return `NaN`. +### Use math.acosh in map -## Special cases ```js -math.acosh(x: +Inf) // Returns +Inf -math.acosh(x: <1) // Returns NaN -math.acosh(x: NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({r with _value: math.acosh(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.21800000000000003 | t1 | +| 2021-01-01T00:00:10Z | 1.092 | t1 | +| 2021-01-01T00:00:20Z | 0.735 | t1 | +| 2021-01-01T00:00:30Z | 1.7530000000000001 | t1 | +| 2021-01-01T00:00:40Z | 1.5230000000000001 | t1 | +| 2021-01-01T00:00:50Z | 0.443 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 1.9850000000000003 | t2 | +| 2021-01-01T00:00:10Z | 0.497 | t2 | +| 2021-01-01T00:00:20Z | -0.375 | t2 | +| 2021-01-01T00:00:30Z | 1.977 | t2 | +| 2021-01-01T00:00:40Z | 1.3860000000000001 | t2 | +| 2021-01-01T00:00:50Z | 0.18600000000000003 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | NaN | t1 | +| 2021-01-01T00:00:10Z | 0.42572984537574377 | t1 | +| 2021-01-01T00:00:20Z | NaN | t1 | +| 2021-01-01T00:00:30Z | 1.1608966388962805 | t1 | +| 2021-01-01T00:00:40Z | 0.9827177940622978 | t1 | +| 2021-01-01T00:00:50Z | NaN | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | 1.308254013849232 | t2 | +| 2021-01-01T00:00:10Z | NaN | t2 | +| 2021-01-01T00:00:20Z | NaN | t2 | +| 2021-01-01T00:00:30Z | 1.3035758471451702 | t2 | +| 2021-01-01T00:00:40Z | 0.8525776257667146 | t2 | +| 2021-01-01T00:00:50Z | NaN | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/asin.md b/content/flux/v0.x/stdlib/math/asin.md index 5cc3a0d67..f84159131 100644 --- a/content/flux/v0.x/stdlib/math/asin.md +++ b/content/flux/v0.x/stdlib/math/asin.md @@ -1,40 +1,119 @@ --- title: math.asin() function -description: The math.asin() function returns the arcsine of `x` in radians. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/asin/ - - /influxdb/v2.0/reference/flux/stdlib/math/asin/ - - /influxdb/cloud/reference/flux/stdlib/math/asin/ +description: > + `math.asin()` returns the arcsine of `x` in radians. menu: flux_0_x_ref: name: math.asin parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/asin +weight: 101 --- -The `math.asin()` function returns the arcsine of `x` in radians. + + +`math.asin()` returns the arcsine of `x` in radians. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + +`x` should be greater than -1 and less than 1. Otherwise the function will +return `NaN`. + + +## Examples + +- [Return the arcsine of a value](#return-the-arcsine-of-a-value) +- [Use math.asin in map](#use-mathasin-in-map) + +### Return the arcsine of a value ```js import "math" math.asin(x: 0.22) - -// Returns 0.22181447049679442 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. -`x` should be greater than -1 and less than 1. -Otherwise, the function will return `NaN`. +### Use math.asin in map -## Special cases ```js -math.asin(x: ±0) // Returns ±0 -math.asin(x: <-1) // Returns NaN -math.asin(x: >1) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({r with _value: math.asin(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | --------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.021800000000000003 | t1 | +| 2021-01-01T00:00:10Z | 0.1092 | t1 | +| 2021-01-01T00:00:20Z | 0.0735 | t1 | +| 2021-01-01T00:00:30Z | 0.1753 | t1 | +| 2021-01-01T00:00:40Z | 0.15230000000000002 | t1 | +| 2021-01-01T00:00:50Z | 0.0443 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.1985 | t2 | +| 2021-01-01T00:00:10Z | 0.0497 | t2 | +| 2021-01-01T00:00:20Z | -0.0375 | t2 | +| 2021-01-01T00:00:30Z | 0.1977 | t2 | +| 2021-01-01T00:00:40Z | 0.1386 | t2 | +| 2021-01-01T00:00:50Z | 0.018600000000000002 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | --------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.021801727074707577 | t1 | +| 2021-01-01T00:00:10Z | 0.10941820137571553 | t1 | +| 2021-01-01T00:00:20Z | 0.07356633896021608 | t1 | +| 2021-01-01T00:00:30Z | 0.17621047844966892 | t1 | +| 2021-01-01T00:00:40Z | 0.1528950055407725 | t1 | +| 2021-01-01T00:00:50Z | 0.044314502528968014 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.1998272282367503 | t2 | +| 2021-01-01T00:00:10Z | 0.04972048335509017 | t2 | +| 2021-01-01T00:00:20Z | -0.03750879462898862 | t2 | +| 2021-01-01T00:00:30Z | 0.19901105310181802 | t2 | +| 2021-01-01T00:00:40Z | 0.13904763050983682 | t2 | +| 2021-01-01T00:00:50Z | 0.0186010726429996 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/asinh.md b/content/flux/v0.x/stdlib/math/asinh.md index 639c4d2e5..259370cf0 100644 --- a/content/flux/v0.x/stdlib/math/asinh.md +++ b/content/flux/v0.x/stdlib/math/asinh.md @@ -1,38 +1,120 @@ --- title: math.asinh() function -description: The math.asinh() function returns the inverse hyperbolic sine of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/asinh/ - - /influxdb/v2.0/reference/flux/stdlib/math/asinh/ - - /influxdb/cloud/reference/flux/stdlib/math/asinh/ +description: > + `math.asinh()` returns the inverse hyperbolic sine of `x`. menu: flux_0_x_ref: name: math.asinh parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/asinh +weight: 101 --- -The `math.asinh()` function returns the inverse hyperbolic sine of `x`. + + +`math.asinh()` returns the inverse hyperbolic sine of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the inverse hyperbolic sine of a value](#return-the-inverse-hyperbolic-sine-of-a-value) +- [Use math.asinh in map](#use-mathasinh-in-map) + +### Return the inverse hyperbolic sine of a value ```js import "math" -math.asinh(x: 3.14) +math.asinh(x: 3.14)// 1.8618125572133835 -// Returns 1.8618125572133835 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.asinh in map -## Special cases ```js -math.asinh(x: ±0) // Returns ±0 -math.asinh(x: ±Inf) // Returns ±Inf -math.asinh(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.asinh(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | -1.5213531182383162 | t1 | +| 2021-01-01T00:00:10Z | 3.0858330878095224 | t1 | +| 2021-01-01T00:00:20Z | 2.692443398164797 | t1 | +| 2021-01-01T00:00:30Z | 3.5578734234029126 | t1 | +| 2021-01-01T00:00:40Z | 3.4174904141531415 | t1 | +| 2021-01-01T00:00:50Z | 2.1940489315838474 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 3.681985066226324 | t2 | +| 2021-01-01T00:00:10Z | 2.3065378213935075 | t2 | +| 2021-01-01T00:00:20Z | -2.0322246215338136 | t2 | +| 2021-01-01T00:00:30Z | 3.6779518317559377 | t2 | +| 2021-01-01T00:00:40Z | 3.323453049376607 | t2 | +| 2021-01-01T00:00:50Z | 1.3792134765550192 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/atan.md b/content/flux/v0.x/stdlib/math/atan.md index ff4a3a180..bb56cb1b0 100644 --- a/content/flux/v0.x/stdlib/math/atan.md +++ b/content/flux/v0.x/stdlib/math/atan.md @@ -1,37 +1,120 @@ --- title: math.atan() function -description: The math.atan() function returns the arctangent of `x` in radians. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/atan/ - - /influxdb/v2.0/reference/flux/stdlib/math/atan/ - - /influxdb/cloud/reference/flux/stdlib/math/atan/ +description: > + `math.atan()` returns the arctangent of `x` in radians. menu: flux_0_x_ref: name: math.atan parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/atan +weight: 101 --- -The `math.atan()` function returns the arctangent of `x` in radians. + + +`math.atan()` returns the arctangent of `x` in radians. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the arctangent of a value](#return-the-arctangent-of-a-value) +- [Use math.atan in map](#use-mathatan-in-map) + +### Return the arctangent of a value ```js import "math" -math.atan(x: 3.14) +math.atan(x: 3.14)// 1.262480664599468 -// Returns 1.262480664599468 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.atan in map -## Special cases ```js -math.atan(x: ±0) // Returns ±0 -math.atan(x: ±Inf) // Returns ±Pi/2 +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.atan(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | -1.140718191739034 | t1 | +| 2021-01-01T00:00:10Z | 1.4794759377086963 | t1 | +| 2021-01-01T00:00:20Z | 1.4355721950708649 | t1 | +| 2021-01-01T00:00:30Z | 1.5138130181922385 | t1 | +| 2021-01-01T00:00:40Z | 1.5052305597197282 | t1 | +| 2021-01-01T00:00:50Z | 1.3487837105541014 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 1.5204610466686876 | t2 | +| 2021-01-01T00:00:10Z | 1.3722402258799695 | t2 | +| 2021-01-01T00:00:20Z | -1.3101939350475555 | t2 | +| 2021-01-01T00:00:30Z | 1.520257709140084 | t2 | +| 2021-01-01T00:00:40Z | 1.4987710606562659 | t2 | +| 2021-01-01T00:00:50Z | 1.0774963946058176 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/atan2.md b/content/flux/v0.x/stdlib/math/atan2.md index d18ecf596..a457a467f 100644 --- a/content/flux/v0.x/stdlib/math/atan2.md +++ b/content/flux/v0.x/stdlib/math/atan2.md @@ -1,58 +1,56 @@ --- title: math.atan2() function description: > - The math.atan2() function returns the arc tangent of `y`/`x`, using the signs of - the parameters to determine the quadrant of the return value. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/atan2/ - - /influxdb/v2.0/reference/flux/stdlib/math/atan2/ - - /influxdb/cloud/reference/flux/stdlib/math/atan2/ + `math.atan2()` returns the artangent of `x/y`, using the signs + of the two to determine the quadrant of the return value. menu: flux_0_x_ref: name: math.atan2 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/atan2 +weight: 101 --- -The `math.atan2()` function returns the arc tangent of `y`/`x`, using the signs + + +`math.atan2()` returns the artangent of `x/y`, using the signs of the two to determine the quadrant of the return value. -_**Output data type:** Float_ + + +##### Function type signature ```js -import "math" - -math.atan2(y: 1.22, x: 3.14) - -// Returns 0.3705838802763881 +(x: float, y: float) => float ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### y {data-type="float"} -The y coordinate used in the operation. +### y +({{< req >}}) +y-coordinate to use in the operation. + + + +### x +({{< req >}}) +x-corrdinate to use in the operation. + -### x {data-type="float"} -The x coordinate used in the operation. -## Special cases -```js -math.atan2(y:y, x:NaN) // Returns NaN -math.atan2(y: NaN, x:x) // Returns NaN -math.atan2(y: +0, x: >=0) // Returns +0 -math.atan2(y: -0, x: >=0) // Returns -0 -math.atan2(y: +0, x: <=-0) // Returns +Pi -math.atan2(y: -0, x: <=-0) // Returns -Pi -math.atan2(y: >0, x: 0) // Returns +Pi/2 -math.atan2(y: <0, x: 0) // Returns -Pi/2 -math.atan2(y: +Inf, x: +Inf) // Returns +Pi/4 -math.atan2(y: -Inf, x: +Inf) // Returns -Pi/4 -math.atan2(y: +Inf, x: -Inf) // Returns 3Pi/4 -math.atan2(y: -Inf, x: -Inf) // Returns -3Pi/4 -math.atan2(y:y, x: +Inf) // Returns 0 -math.atan2(y: >0, x: -Inf) // Returns +Pi -math.atan2(y: <0, x: -Inf) // Returns -Pi -math.atan2(y: +Inf, x:x) // Returns +Pi/2 -math.atan2(y: -Inf, x:x) // Returns -Pi/2 -``` diff --git a/content/flux/v0.x/stdlib/math/atanh.md b/content/flux/v0.x/stdlib/math/atanh.md index 00454bf82..2d1137017 100644 --- a/content/flux/v0.x/stdlib/math/atanh.md +++ b/content/flux/v0.x/stdlib/math/atanh.md @@ -1,43 +1,120 @@ --- title: math.atanh() function -description: The math.atanh() function returns the inverse hyperbolic tangent of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/atanh/ - - /influxdb/v2.0/reference/flux/stdlib/math/atanh/ - - /influxdb/cloud/reference/flux/stdlib/math/atanh/ +description: > + `math.atanh()` returns the inverse hyperbolic tangent of `x`. menu: flux_0_x_ref: name: math.atanh parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/atanh +weight: 101 --- -The `math.atanh()` function returns the inverse hyperbolic tangent of `x`. + + +`math.atanh()` returns the inverse hyperbolic tangent of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + +`x` should be greater than -1 and less than 1. Otherwise the operation +will return `NaN`. + + +## Examples + +- [Return the hyperbolic tangent of a value](#return-the-hyperbolic-tangent-of-a-value) +- [Use math.atanh in map](#use-mathatanh-in-map) + +### Return the hyperbolic tangent of a value ```js import "math" -math.atanh(x: 0.22) +math.atanh(x: 0.22)// 0.22365610902183242 -// Returns 0.22365610902183242 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. -`x` should be greater than -1 and less than 1. -Otherwise, the operation will return `NaN`. +### Use math.atanh in map -## Special cases ```js -math.atanh(x: 1) // Returns +Inf -math.atanh(x: ±0) // Returns ±0 -math.atanh(x: -1) // Returns -Inf -math.atanh(x: <-1) // Returns NaN -math.atanh(x: >1) // Returns NaN -math.atanh(x: NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({r with _value: math.atanh(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | --------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.021800000000000003 | t1 | +| 2021-01-01T00:00:10Z | 0.1092 | t1 | +| 2021-01-01T00:00:20Z | 0.0735 | t1 | +| 2021-01-01T00:00:30Z | 0.1753 | t1 | +| 2021-01-01T00:00:40Z | 0.15230000000000002 | t1 | +| 2021-01-01T00:00:50Z | 0.0443 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.1985 | t2 | +| 2021-01-01T00:00:10Z | 0.0497 | t2 | +| 2021-01-01T00:00:20Z | -0.0375 | t2 | +| 2021-01-01T00:00:30Z | 0.1977 | t2 | +| 2021-01-01T00:00:40Z | 0.1386 | t2 | +| 2021-01-01T00:00:50Z | 0.018600000000000002 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | --------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.021803454395720394 | t1 | +| 2021-01-01T00:00:10Z | 0.10963718917920522 | t1 | +| 2021-01-01T00:00:20Z | 0.07363278579671062 | t1 | +| 2021-01-01T00:00:30Z | 0.17712951464974935 | t1 | +| 2021-01-01T00:00:40Z | 0.1534942122028045 | t1 | +| 2021-01-01T00:00:50Z | 0.04432901360668446 | t1 | + +| _time | _value | *tag | +| -------------------- | --------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.2011705409124157 | t2 | +| 2021-01-01T00:00:10Z | 0.049740981912241244 | t2 | +| 2021-01-01T00:00:20Z | -0.037517592971457035 | t2 | +| 2021-01-01T00:00:30Z | 0.20033786359692538 | t2 | +| 2021-01-01T00:00:40Z | 0.13949787194848565 | t2 | +| 2021-01-01T00:00:50Z | 0.01860214539735061 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/cbrt.md b/content/flux/v0.x/stdlib/math/cbrt.md index 0393e2ec8..c5f8a7962 100644 --- a/content/flux/v0.x/stdlib/math/cbrt.md +++ b/content/flux/v0.x/stdlib/math/cbrt.md @@ -1,38 +1,120 @@ --- title: math.cbrt() function -description: The math.cbrt() function returns the cube root of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/cbrt/ - - /influxdb/v2.0/reference/flux/stdlib/math/cbrt/ - - /influxdb/cloud/reference/flux/stdlib/math/cbrt/ +description: > + `math.cbrt()` returns the cube root of x. menu: flux_0_x_ref: name: math.cbrt parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/cbrt +weight: 101 --- -The `math.cbrt()` function returns the cube root of `x`. + + +`math.cbrt()` returns the cube root of x. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the cube root of a value](#return-the-cube-root-of-a-value) +- [Use math.cbrt in map](#use-mathcbrt-in-map) + +### Return the cube root of a value ```js import "math" -math.cbrt(x: 1728.0) +math.cbrt(x: 1728.0)// 12.0 -// Returns 12.0 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.cbrt in map -## Special cases ```js -math.cbrt(±0) // Returns ±0 -math.cbrt(±Inf) // Returns ±Inf -math.cbrt(NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.cbrt(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | -1.296638256974172 | t1 | +| 2021-01-01T00:00:10Z | 2.2185755003939347 | t1 | +| 2021-01-01T00:00:20Z | 1.9442962850073848 | t1 | +| 2021-01-01T00:00:30Z | 2.5977297737212623 | t1 | +| 2021-01-01T00:00:40Z | 2.478753275547562 | t1 | +| 2021-01-01T00:00:50Z | 1.6423582966480554 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 2.7076145363999617 | t2 | +| 2021-01-01T00:00:10Z | 1.7065491319882757 | t2 | +| 2021-01-01T00:00:20Z | -1.5536162529769295 | t2 | +| 2021-01-01T00:00:30Z | 2.703972205402708 | t2 | +| 2021-01-01T00:00:40Z | 2.402081527496116 | t2 | +| 2021-01-01T00:00:50Z | 1.2298089464641 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/ceil.md b/content/flux/v0.x/stdlib/math/ceil.md index 14386ae72..708b4e708 100644 --- a/content/flux/v0.x/stdlib/math/ceil.md +++ b/content/flux/v0.x/stdlib/math/ceil.md @@ -1,38 +1,120 @@ --- title: math.ceil() function -description: The math.ceil() function returns the least integer value greater than or equal to `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/ceil/ - - /influxdb/v2.0/reference/flux/stdlib/math/ceil/ - - /influxdb/cloud/reference/flux/stdlib/math/ceil/ +description: > + `math.ceil()` returns the least integer value greater than or equal to `x`. menu: flux_0_x_ref: name: math.ceil parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/ceil +weight: 101 --- -The `math.ceil()` function returns the least integer value greater than or equal to `x`. + + +`math.ceil()` returns the least integer value greater than or equal to `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Round a value up to the nearest integer](#round-a-value-up-to-the-nearest-integer) +- [Use math.ceil in map](#use-mathceil-in-map) + +### Round a value up to the nearest integer ```js import "math" -math.ceil(x: 3.14) +math.ceil(x: 3.14)// 4.0 -// Returns 4.0 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.ceil in map -## Special cases ```js -math.ceil(±0) // Returns ±0 -math.ceil(±Inf) // Returns ±Inf -math.ceil(NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.ceil(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 11 | t1 | +| 2021-01-01T00:00:20Z | 8 | t1 | +| 2021-01-01T00:00:30Z | 18 | t1 | +| 2021-01-01T00:00:40Z | 16 | t1 | +| 2021-01-01T00:00:50Z | 5 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 20 | t2 | +| 2021-01-01T00:00:10Z | 5 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 20 | t2 | +| 2021-01-01T00:00:40Z | 14 | t2 | +| 2021-01-01T00:00:50Z | 2 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/copysign.md b/content/flux/v0.x/stdlib/math/copysign.md index 8fa3babae..5f9134bbe 100644 --- a/content/flux/v0.x/stdlib/math/copysign.md +++ b/content/flux/v0.x/stdlib/math/copysign.md @@ -1,34 +1,104 @@ --- title: math.copysign() function -description: The math.copysign() function returns a value with the magnitude of `x` and the sign of `y`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/copysign/ - - /influxdb/v2.0/reference/flux/stdlib/math/copysign/ - - /influxdb/cloud/reference/flux/stdlib/math/copysign/ +description: > + `math.copysign()` returns a value with the magnitude `x` and the sign of `y`. menu: flux_0_x_ref: name: math.copysign parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/copysign +weight: 101 --- -The `math.copysign()` function returns a value with the magnitude of `x` and the sign of `y`. + + +`math.copysign()` returns a value with the magnitude `x` and the sign of `y`. + + + +##### Function type signature + +```js +(x: float, y: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Magnitude to use in the operation. + + + +### y +({{< req >}}) +Sign to use in the operation. + + + + +## Examples + +- [Return the copysign of two columns](#return-the-copysign-of-two-columns) +- [Use math.copysign in map](#use-mathcopysign-in-map) + +### Return the copysign of two columns ```js import "math" math.copysign(x: 1.0, y: 2.0) - -// Returns 1.0 ``` -## Parameters -### x {data-type="float"} -The magnitude used in the operation. +### Use math.copysign in map -### y {data-type="float"} -The sign used in the operation. +```js +import "math" + +data + |> map(fn: (r) => ({_time: r._time, _value: math.copysign(x: r.x, y: r.y)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | x | y | +| -------------------- | --- | --- | +| 2021-01-01T00:00:00Z | 1.2 | 3.9 | +| 2021-01-01T01:00:00Z | 2.4 | 4.2 | +| 2021-01-01T02:00:00Z | 3.6 | 5.3 | +| 2021-01-01T03:00:00Z | 4.8 | 6.8 | +| 2021-01-01T04:00:00Z | 5.1 | 7.5 | + + +#### Output data + +| _time | _value | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | 1.2 | +| 2021-01-01T01:00:00Z | 2.4 | +| 2021-01-01T02:00:00Z | 3.6 | +| 2021-01-01T03:00:00Z | 4.8 | +| 2021-01-01T04:00:00Z | 5.1 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/cos.md b/content/flux/v0.x/stdlib/math/cos.md index 2fa0d92ae..4b3dd4ef2 100644 --- a/content/flux/v0.x/stdlib/math/cos.md +++ b/content/flux/v0.x/stdlib/math/cos.md @@ -1,37 +1,61 @@ --- title: math.cos() function -description: The math.cos() function returns the cosine of the radian argument `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/cos/ - - /influxdb/v2.0/reference/flux/stdlib/math/cos/ - - /influxdb/cloud/reference/flux/stdlib/math/cos/ +description: > + `math.cos()` returns the cosine of the radian argument `x`. menu: flux_0_x_ref: name: math.cos parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/cos +weight: 101 --- -The `math.cos()` function returns the cosine of the radian argument `x`. + + +`math.cos()` returns the cosine of the radian argument `x`. + + + +##### Function type signature ```js -import "math" - -math.cos(x: 3.14) - -// Returns -0.9999987317275396 +(x: float) => float ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### x {data-type="float"} -The value used in the operation. +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +### Use math.cos in map -## Special cases ```js -math.cos(±Inf) // Returns NaN -math.cos(NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({_time: r._time, _value: math.cos(x: r._value)})) ``` + diff --git a/content/flux/v0.x/stdlib/math/cosh.md b/content/flux/v0.x/stdlib/math/cosh.md index d98d8f2a7..1a7ffa178 100644 --- a/content/flux/v0.x/stdlib/math/cosh.md +++ b/content/flux/v0.x/stdlib/math/cosh.md @@ -1,38 +1,61 @@ --- title: math.cosh() function -description: The math.cosh() function returns the hyperbolic cosine of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/cosh/ - - /influxdb/v2.0/reference/flux/stdlib/math/cosh/ - - /influxdb/cloud/reference/flux/stdlib/math/cosh/ +description: > + `math.cosh()` returns the hyperbolic cosine of `x`. menu: flux_0_x_ref: name: math.cosh parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/cosh +weight: 101 --- -The `math.cosh()` function returns the hyperbolic cosine of `x`. + + +`math.cosh()` returns the hyperbolic cosine of `x`. + + + +##### Function type signature ```js -import "math" - -math.cosh(x: 1.22) - -// Returns 1.8412089502726743 +(x: float) => float ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### x {data-type="float"} -The value used in the operation. +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +### Use math.cosh in map -## Special cases ```js -math.cosh(±0) // Returns 1 -math.cosh(±Inf) // Returns +Inf -math.cosh(NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({_time: r._time, _value: math.cosh(x: r._value)})) ``` + diff --git a/content/flux/v0.x/stdlib/math/dim.md b/content/flux/v0.x/stdlib/math/dim.md index 15033cd14..c7f1bd10c 100644 --- a/content/flux/v0.x/stdlib/math/dim.md +++ b/content/flux/v0.x/stdlib/math/dim.md @@ -1,42 +1,105 @@ --- title: math.dim() function -description: The math.dim() function returns the maximum of `x`-`y` or 0. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/dim/ - - /influxdb/v2.0/reference/flux/stdlib/math/dim/ - - /influxdb/cloud/reference/flux/stdlib/math/dim/ +description: > + `math.dim()` returns the maximum of `x - y` or `0`. menu: flux_0_x_ref: name: math.dim parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/dim +weight: 101 --- -The `math.dim()` function returns the maximum of `x - y` or 0. + + +`math.dim()` returns the maximum of `x - y` or `0`. + + + +##### Function type signature + +```js +(x: float, y: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +x-value to use in the operation. + + + +### y +({{< req >}}) +y-value to use in the operation. + + + + +## Examples + +- [Return the maximum difference betwee two values](#return-the-maximum-difference-betwee-two-values) +- [Use math.dim in map](#use-mathdim-in-map) + +### Return the maximum difference betwee two values ```js import "math" -math.dim(x: 12.2, y: 8.1) +math.dim(x: 12.2, y: 8.1)// 4.1 -// Returns 4.1 ``` -## Parameters -### x {data-type="float"} -The X value used in the operation. +### Use math.dim in map -### y {data-type="float"} -The Y value used in the operation. - -## Special cases ```js -math.dim(x: +Inf, y: +Inf) // Returns NaN -math.dim(x: -Inf, y: -Inf) // Returns NaN -math.dim(x:x, y : NaN) // Returns NaN -math.dim(x: NaN, y :y) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({_time: r._time, _value: math.dim(x: r.x, y: r.y)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | x | y | +| -------------------- | --- | --- | +| 2021-01-01T00:00:00Z | 3.9 | 1.2 | +| 2021-01-01T01:00:00Z | 4.2 | 2.4 | +| 2021-01-01T02:00:00Z | 5.3 | 3.6 | +| 2021-01-01T03:00:00Z | 6.8 | 4.8 | +| 2021-01-01T04:00:00Z | 7.5 | 5.1 | + + +#### Output data + +| _time | _value | +| -------------------- | ------------------ | +| 2021-01-01T00:00:00Z | 2.7 | +| 2021-01-01T01:00:00Z | 1.8000000000000003 | +| 2021-01-01T02:00:00Z | 1.6999999999999997 | +| 2021-01-01T03:00:00Z | 2 | +| 2021-01-01T04:00:00Z | 2.4000000000000004 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/erf.md b/content/flux/v0.x/stdlib/math/erf.md index 570510560..0e10c8fe2 100644 --- a/content/flux/v0.x/stdlib/math/erf.md +++ b/content/flux/v0.x/stdlib/math/erf.md @@ -1,38 +1,120 @@ --- title: math.erf() function -description: The math.erf() function returns the error function of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/erf/ - - /influxdb/v2.0/reference/flux/stdlib/math/erf/ - - /influxdb/cloud/reference/flux/stdlib/math/erf/ +description: > + `math.erf()` returns the error function of `x`. menu: flux_0_x_ref: name: math.erf parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/erf +weight: 101 --- -The `math.erf()` function returns the error function of `x`. + + +`math.erf()` returns the error function of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the error function of a value.](#return-the-error-function-of-a-value) +- [Use math.erf in map](#use-matherf-in-map) + +### Return the error function of a value. ```js import "math" -math.erf(x: 22.6) +math.erf(x: 22.6)// 1.0 -// Returns 1.0 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.erf in map -## Special cases ```js -math.erf(+Inf) // Returns 1 -math.erf(-Inf) // Returns -1 -math.erf(NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.erf(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.9979506490526588 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 1 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 1 | t1 | +| 2021-01-01T00:00:50Z | 0.9999999996270934 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t2 | +| 2021-01-01T00:00:10Z | 0.9999999999979144 | t2 | +| 2021-01-01T00:00:20Z | -0.9999998862727434 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0.9914724883356396 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/erfc.md b/content/flux/v0.x/stdlib/math/erfc.md index 8073ee0a3..2c74baab6 100644 --- a/content/flux/v0.x/stdlib/math/erfc.md +++ b/content/flux/v0.x/stdlib/math/erfc.md @@ -1,38 +1,120 @@ --- title: math.erfc() function -description: The math.erfc() function returns the complementary error function of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/erfc/ - - /influxdb/v2.0/reference/flux/stdlib/math/erfc/ - - /influxdb/cloud/reference/flux/stdlib/math/erfc/ +description: > + `math.erfc()` returns the complementary error function of `x`. menu: flux_0_x_ref: name: math.erfc parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/erfc +weight: 101 --- -The `math.erfc()` function returns the complementary error function of `x`. + + +`math.erfc()` returns the complementary error function of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the complementary error function of a value](#return-the-complementary-error-function-of-a-value) +- [Use math.erfc in map](#use-matherfc-in-map) + +### Return the complementary error function of a value ```js import "math" -math.erfc(x: 22.6) +math.erfc(x: 22.6)// 3.772618913849058e-224 -// Returns 3.7726189138490583e-224 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.erfc in map -## Special cases ```js -math.erfc(+Inf) // Returns 0 -math.erfc(-Inf) // Returns 2 -math.erfc(NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.erfc(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | +| 2021-01-01T00:00:00Z | 1.9979506490526588 | t1 | +| 2021-01-01T00:00:10Z | 0.000000000000000000000000000000000000000000000000000008381980138107252 | t1 | +| 2021-01-01T00:00:20Z | 0.000000000000000000000000262744434287864 | t1 | +| 2021-01-01T00:00:30Z | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011164884065025777 | t1 | +| 2021-01-01T00:00:40Z | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006790933091004747 | t1 | +| 2021-01-01T00:00:50Z | 0.0000000003729065687554446 | t1 | + +| _time | _value | *tag | +| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002144458719979885 | t2 | +| 2021-01-01T00:00:10Z | 0.0000000000020855419929990413 | t2 | +| 2021-01-01T00:00:20Z | 1.9999998862727435 | t2 | +| 2021-01-01T00:00:30Z | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005123973574678553 | t2 | +| 2021-01-01T00:00:40Z | 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000015161509817813512 | t2 | +| 2021-01-01T00:00:50Z | 0.008527511664360422 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/erfcinv.md b/content/flux/v0.x/stdlib/math/erfcinv.md index fb6ef1c65..ed997f76f 100644 --- a/content/flux/v0.x/stdlib/math/erfcinv.md +++ b/content/flux/v0.x/stdlib/math/erfcinv.md @@ -1,42 +1,120 @@ --- title: math.erfcinv() function -description: The math.erfcinv() function returns the inverse of `math.erfc()`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/erfcinv/ - - /influxdb/v2.0/reference/flux/stdlib/math/erfcinv/ - - /influxdb/cloud/reference/flux/stdlib/math/erfcinv/ +description: > + `math.erfcinv()` returns the inverse of `math.erfc()`. menu: flux_0_x_ref: name: math.erfcinv parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/erfcinv +weight: 101 --- -The `math.erfcinv()` function returns the inverse of `math.erfc()`. + + +`math.erfcinv()` returns the inverse of `math.erfc()`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + +`x` should be greater than 0 and less than 2. Otherwise the operation +will return `NaN`. + + +## Examples + +- [Return the inverse complimentary error function](#return-the-inverse-complimentary-error-function) +- [Use math.erfcinv in map](#use-matherfcinv-in-map) + +### Return the inverse complimentary error function ```js import "math" -math.erfcinv(x: 0.42345) +math.erfcinv(x: 0.42345)// 0.5660037715858239 -// Returns 0.5660037715858239 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. -`x` should be greater than 0 and less than 2. -Otherwise, the operation will return `NaN`. +### Use math.erfcinv in map -## Special cases ```js -math.erfcinv(x: 0) // Returns +Inf -math.erfcinv(x: 2) // Returns -Inf -math.erfcinv(x: <0) // Returns NaN -math.erfcinv(x: >2) // Returns NaN -math.erfcinv(x: NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({r with _value: math.erfcinv(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | +| 2021-01-01T00:00:00Z | 1.9979506490526588 | t1 | +| 2021-01-01T00:00:10Z | 0.000000000000000000000000000000000000000000000000000008381980138107252 | t1 | +| 2021-01-01T00:00:20Z | 0.000000000000000000000000262744434287864 | t1 | +| 2021-01-01T00:00:30Z | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011164884065025777 | t1 | +| 2021-01-01T00:00:40Z | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006790933091004747 | t1 | +| 2021-01-01T00:00:50Z | 0.0000000003729065687554446 | t1 | + +| _time | _value | *tag | +| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002144458719979885 | t2 | +| 2021-01-01T00:00:10Z | 0.0000000000020855419929990413 | t2 | +| 2021-01-01T00:00:20Z | 1.9999998862727435 | t2 | +| 2021-01-01T00:00:30Z | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005123973574678553 | t2 | +| 2021-01-01T00:00:40Z | 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000015161509817813512 | t2 | +| 2021-01-01T00:00:50Z | 0.008527511664360422 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | -2.1800000000000006 | t1 | +| 2021-01-01T00:00:10Z | +Inf | t1 | +| 2021-01-01T00:00:20Z | +Inf | t1 | +| 2021-01-01T00:00:30Z | +Inf | t1 | +| 2021-01-01T00:00:40Z | +Inf | t1 | +| 2021-01-01T00:00:50Z | 4.429999992395194 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | +Inf | t2 | +| 2021-01-01T00:00:10Z | 4.969999434158999 | t2 | +| 2021-01-01T00:00:20Z | -3.7500000000779927 | t2 | +| 2021-01-01T00:00:30Z | +Inf | t2 | +| 2021-01-01T00:00:40Z | +Inf | t2 | +| 2021-01-01T00:00:50Z | 1.860000000000001 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/erfinv.md b/content/flux/v0.x/stdlib/math/erfinv.md index 02c9ad3c7..56569ddd4 100644 --- a/content/flux/v0.x/stdlib/math/erfinv.md +++ b/content/flux/v0.x/stdlib/math/erfinv.md @@ -1,42 +1,120 @@ --- title: math.erfinv() function -description: The math.erfinv() function returns the inverse error function of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/erfinv/ - - /influxdb/v2.0/reference/flux/stdlib/math/erfinv/ - - /influxdb/cloud/reference/flux/stdlib/math/erfinv/ +description: > + `math.erfinv()` returns the inverse error function of `x`. menu: flux_0_x_ref: name: math.erfinv parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/erfinv +weight: 101 --- -The `math.erfinv()` function returns the inverse error function of `x`. + + +`math.erfinv()` returns the inverse error function of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + +`x` should be greater than -1 and less than 1. Otherwise, the operation will +return `NaN`. + + +## Examples + +- [Return the inverse error function of a value](#return-the-inverse-error-function-of-a-value) +- [Use math.erfinv in map](#use-matherfinv-in-map) + +### Return the inverse error function of a value ```js import "math" -math.erfinv(x: 0.22) +math.erfinv(x: 0.22)// 0.19750838337227364 -// Returns 0.19750838337227364 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. -`x` should be greater than -1 and less than 1. -Otherwise, the operation will return `NaN`. +### Use math.erfinv in map -## Special cases ```js -math.erfinv(x: 1) // Returns +Inf -math.erfinv(x: -1) // Returns -Inf -math.erfinv(x: <-1) // Returns NaN -math.erfinv(x: > 1) // Returns NaN -math.erfinv(x: NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({r with _value: math.erfinv(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.9979506490526588 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 1 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 1 | t1 | +| 2021-01-01T00:00:50Z | 0.9999999996270934 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t2 | +| 2021-01-01T00:00:10Z | 0.9999999999979144 | t2 | +| 2021-01-01T00:00:20Z | -0.9999998862727434 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0.9914724883356396 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | -2.1800000000000006 | t1 | +| 2021-01-01T00:00:10Z | +Inf | t1 | +| 2021-01-01T00:00:20Z | +Inf | t1 | +| 2021-01-01T00:00:30Z | +Inf | t1 | +| 2021-01-01T00:00:40Z | +Inf | t1 | +| 2021-01-01T00:00:50Z | 4.429999992395194 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | +Inf | t2 | +| 2021-01-01T00:00:10Z | 4.969999434158999 | t2 | +| 2021-01-01T00:00:20Z | -3.7499999999520366 | t2 | +| 2021-01-01T00:00:30Z | +Inf | t2 | +| 2021-01-01T00:00:40Z | +Inf | t2 | +| 2021-01-01T00:00:50Z | 1.860000000000001 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/exp.md b/content/flux/v0.x/stdlib/math/exp.md index 5c06260d0..0719e0964 100644 --- a/content/flux/v0.x/stdlib/math/exp.md +++ b/content/flux/v0.x/stdlib/math/exp.md @@ -1,39 +1,120 @@ --- title: math.exp() function -description: The math.exp() function returns `e**x`, the base-e exponential of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/exp/ - - /influxdb/v2.0/reference/flux/stdlib/math/exp/ - - /influxdb/cloud/reference/flux/stdlib/math/exp/ +description: > + `math.exp()` returns `e**x`, the base-e exponential of `x`. menu: flux_0_x_ref: name: math.exp parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/exp +weight: 101 --- -The `math.exp()` function returns `e**x`, the base-e exponential of `x`. + + +`math.exp()` returns `e**x`, the base-e exponential of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the base-e exponential of a value](#return-the-base-e-exponential-of-a-value) +- [Use math.exp in map](#use-mathexp-in-map) + +### Return the base-e exponential of a value ```js import "math" -math.exp(x: 21.0) +math.exp(x: 21.0)// 1.3188157344832146e+09 -// Returns 1.3188157344832146e+09 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.exp in map -## Special cases ```js -math.exp(x: +Inf) // Returns +Inf -math.exp(x: NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.exp(x: r._value)})) ``` -Very large values overflow to 0 or +Inf. Very small values underflow to 1. +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.11304153064044985 | t1 | +| 2021-01-01T00:00:10Z | 55270.798943169066 | t1 | +| 2021-01-01T00:00:20Z | 1556.1965278371533 | t1 | +| 2021-01-01T00:00:30Z | 41037629.64620374 | t1 | +| 2021-01-01T00:00:40Z | 4114385.297453036 | t1 | +| 2021-01-01T00:00:50Z | 83.93141691026881 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 417585553.5730289 | t2 | +| 2021-01-01T00:00:10Z | 144.02688737091955 | t2 | +| 2021-01-01T00:00:20Z | 0.023517745856009107 | t2 | +| 2021-01-01T00:00:30Z | 385480050.5181745 | t2 | +| 2021-01-01T00:00:40Z | 1045493.9383645338 | t2 | +| 2021-01-01T00:00:50Z | 6.423736771429135 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/exp2.md b/content/flux/v0.x/stdlib/math/exp2.md index 7bc4c4324..b33e3b410 100644 --- a/content/flux/v0.x/stdlib/math/exp2.md +++ b/content/flux/v0.x/stdlib/math/exp2.md @@ -1,39 +1,120 @@ --- title: math.exp2() function -description: The math.exp2() function returns `2**x`, the base-2 exponential of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/exp2/ - - /influxdb/v2.0/reference/flux/stdlib/math/exp2/ - - /influxdb/cloud/reference/flux/stdlib/math/exp2/ +description: > + `math.exp2()` returns `2**x`, the base-2 exponential of `x`. menu: flux_0_x_ref: name: math.exp2 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/exp2 +weight: 101 --- -The `math.exp2()` function returns `2**x`, the base-2 exponential of `x`. + + +`math.exp2()` returns `2**x`, the base-2 exponential of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the base-2 exponential of a value](#return-the-base-2-exponential-of-a-value) +- [Use math.exp2 in map](#use-mathexp2-in-map) + +### Return the base-2 exponential of a value ```js import "math" -math.exp2(x: 21.0) +math.exp2(x: 21.0)// 2.097152e+06 -// Returns 2.097152e+06 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.exp2 in map -## Special cases ```js -math.exp2(x: +Inf) // Returns +Inf -math.exp2(x: NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.exp2(x: r._value)})) ``` -Very large values overflow to 0 or +Inf. Very small values underflow to 1. +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.22067574907266369 | t1 | +| 2021-01-01T00:00:10Z | 1937.5260604940204 | t1 | +| 2021-01-01T00:00:20Z | 163.1437602968655 | t1 | +| 2021-01-01T00:00:30Z | 189258.68751552477 | t1 | +| 2021-01-01T00:00:40Z | 38431.45561643022 | t1 | +| 2021-01-01T00:00:50Z | 21.55573722985104 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 945029.6050826148 | t2 | +| 2021-01-01T00:00:10Z | 31.341449522781655 | t2 | +| 2021-01-01T00:00:20Z | 0.07432544468767006 | t2 | +| 2021-01-01T00:00:30Z | 894052.4842704767 | t2 | +| 2021-01-01T00:00:40Z | 14868.793840716358 | t2 | +| 2021-01-01T00:00:50Z | 3.6300766212686435 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/expm1.md b/content/flux/v0.x/stdlib/math/expm1.md index c4698c09a..69b8b3d03 100644 --- a/content/flux/v0.x/stdlib/math/expm1.md +++ b/content/flux/v0.x/stdlib/math/expm1.md @@ -1,43 +1,119 @@ --- title: math.expm1() function description: > - The math.expm1() function returns `e**x - 1`, the base-e exponential of `x` minus 1. - It is more accurate than `math.exp(x:x) - 1` when `x` is near zero. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/expm1/ - - /influxdb/v2.0/reference/flux/stdlib/math/expm1/ - - /influxdb/cloud/reference/flux/stdlib/math/expm1/ + `math.expm1()` returns `e**x - 1`, the base-e exponential of `x` minus menu: flux_0_x_ref: name: math.expm1 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/expm1 +weight: 101 --- -The `math.expm1()` function returns `e**x - 1`, the base-e exponential of `x` minus 1. -It is more accurate than `math.exp(x:x) - 1` when `x` is near zero. + + +`math.expm1()` returns `e**x - 1`, the base-e exponential of `x` minus + +1. It is more accurate than `math.exp(x:x) - 1` when `x` is near zero. + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Get more accurate base-e exponentials for values near zero](#get-more-accurate-base-e-exponentials-for-values-near-zero) +- [Use math.expm1 in map](#use-mathexpm1-in-map) + +### Get more accurate base-e exponentials for values near zero ```js import "math" -math.expm1(x: 1.22) +math.expm1(x: 0.022)// 0.022243784470438233 -// Returns 2.3871877336213343 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.expm1 in map -## Special cases ```js -math.expm1(+Inf) // Returns +Inf -math.expm1(-Inf) // Returns -1 -math.expm1(NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({r with _value: math.expm1(x: r._value)})) ``` -Very large values overflow to -1 or +Inf. +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | --------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.021800000000000003 | t1 | +| 2021-01-01T00:00:10Z | 0.1092 | t1 | +| 2021-01-01T00:00:20Z | 0.0735 | t1 | +| 2021-01-01T00:00:30Z | 0.1753 | t1 | +| 2021-01-01T00:00:40Z | 0.15230000000000002 | t1 | +| 2021-01-01T00:00:50Z | 0.0443 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.1985 | t2 | +| 2021-01-01T00:00:10Z | 0.0497 | t2 | +| 2021-01-01T00:00:20Z | -0.0375 | t2 | +| 2021-01-01T00:00:30Z | 0.1977 | t2 | +| 2021-01-01T00:00:40Z | 0.1386 | t2 | +| 2021-01-01T00:00:50Z | 0.018600000000000002 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.02156409733567063 | t1 | +| 2021-01-01T00:00:10Z | 0.11538540511625006 | t1 | +| 2021-01-01T00:00:20Z | 0.07626853667189179 | t1 | +| 2021-01-01T00:00:30Z | 0.1916036440887826 | t1 | +| 2021-01-01T00:00:40Z | 0.16450953689549175 | t1 | +| 2021-01-01T00:00:50Z | 0.045295896623819054 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.21957202741425103 | t2 | +| 2021-01-01T00:00:10Z | 0.05095576234958021 | t2 | +| 2021-01-01T00:00:20Z | -0.03680558227917823 | t2 | +| 2021-01-01T00:00:30Z | 0.21859675995131905 | t2 | +| 2021-01-01T00:00:40Z | 0.14866454228127554 | t2 | +| 2021-01-01T00:00:50Z | 0.018774057481622756 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/float64bits.md b/content/flux/v0.x/stdlib/math/float64bits.md index daa5d6a61..f93c1694c 100644 --- a/content/flux/v0.x/stdlib/math/float64bits.md +++ b/content/flux/v0.x/stdlib/math/float64bits.md @@ -1,31 +1,122 @@ --- title: math.float64bits() function -description: The math.float64bits() function returns the IEEE 754 binary representation of `f`, with the sign bit of `f` and the result in the same bit position. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/float64bits/ - - /influxdb/v2.0/reference/flux/stdlib/math/float64bits/ - - /influxdb/cloud/reference/flux/stdlib/math/float64bits/ +description: > + `math.float64bits()` returns the IEEE 754 binary representation of `f`, + with the sign bit of `f` and the result in the same bit position. menu: flux_0_x_ref: name: math.float64bits parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/float64bits +weight: 101 --- -The `math.float64bits()` function returns the IEEE 754 binary representation of `f`, with the sign bit of `f` and the result in the same bit position. + + +`math.float64bits()` returns the IEEE 754 binary representation of `f`, +with the sign bit of `f` and the result in the same bit position. + + + +##### Function type signature + +```js +(f: float) => uint +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### f +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the binary expression of a value](#return-the-binary-expression-of-a-value) +- [Use math.float64bits in map](#use-mathfloat64bits-in-map) + +### Return the binary expression of a value ```js import "math" -math.float64bits(f: 1234.56) +math.float64bits(f: 1234.56)// 4653144467747100426 -// Returns 4653144467747100426 ``` -## Parameters -### f {data-type="float"} -The value used in the operation. +### Use math.float64bits in map + +```js +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.float64bits(f: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 13835463379248627057 | t1 | +| 2021-01-01T00:00:10Z | 4622337031546119127 | t1 | +| 2021-01-01T00:00:20Z | 4619961382742681190 | t1 | +| 2021-01-01T00:00:30Z | 4625627474023866696 | t1 | +| 2021-01-01T00:00:40Z | 4624763345845364982 | t1 | +| 2021-01-01T00:00:50Z | 4616673755014700728 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 4626280495969835418 | t2 | +| 2021-01-01T00:00:10Z | 4617281740964395745 | t2 | +| 2021-01-01T00:00:20Z | 13838998704956112896 | t2 | +| 2021-01-01T00:00:30Z | 4626257977971698565 | t2 | +| 2021-01-01T00:00:40Z | 4623992104409177784 | t2 | +| 2021-01-01T00:00:50Z | 4611055514479556035 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/float64frombits.md b/content/flux/v0.x/stdlib/math/float64frombits.md new file mode 100644 index 000000000..8fd381a60 --- /dev/null +++ b/content/flux/v0.x/stdlib/math/float64frombits.md @@ -0,0 +1,123 @@ +--- +title: math.float64frombits() function +description: > + `math.float64frombits()` returns the floating-point number corresponding to the IEE + 754 binary representation `b`, with the sign bit of `b` and the result in the + same bit position. +menu: + flux_0_x_ref: + name: math.float64frombits + parent: math + identifier: math/float64frombits +weight: 101 +--- + + + +`math.float64frombits()` returns the floating-point number corresponding to the IEE +754 binary representation `b`, with the sign bit of `b` and the result in the +same bit position. + + + +##### Function type signature + +```js +(b: uint) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### b +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Convert bits into a float value](#convert-bits-into-a-float-value) +- [Use math.float64frombits in map](#use-mathfloat64frombits-in-map) + +### Convert bits into a float value + +```js +import "math" + +math.float64frombits(b: uint(v: 4))// 2e-323 + +``` + + +### Use math.float64frombits in map + +```js +import "math" + +data + |> map(fn: (r) => ({r with _value: math.float64frombits(b: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 13835463379248627057 | t1 | +| 2021-01-01T00:00:10Z | 4622337031546119127 | t1 | +| 2021-01-01T00:00:20Z | 4619961382742681190 | t1 | +| 2021-01-01T00:00:30Z | 4625627474023866696 | t1 | +| 2021-01-01T00:00:40Z | 4624763345845364982 | t1 | +| 2021-01-01T00:00:50Z | 4616673755014700728 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 4626280495969835418 | t2 | +| 2021-01-01T00:00:10Z | 4617281740964395745 | t2 | +| 2021-01-01T00:00:20Z | 13838998704956112896 | t2 | +| 2021-01-01T00:00:30Z | 4626257977971698565 | t2 | +| 2021-01-01T00:00:40Z | 4623992104409177784 | t2 | +| 2021-01-01T00:00:50Z | 4611055514479556035 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2.18 | t1 | +| 2021-01-01T00:00:10Z | 10.92 | t1 | +| 2021-01-01T00:00:20Z | 7.35 | t1 | +| 2021-01-01T00:00:30Z | 17.53 | t1 | +| 2021-01-01T00:00:40Z | 15.23 | t1 | +| 2021-01-01T00:00:50Z | 4.43 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19.85 | t2 | +| 2021-01-01T00:00:10Z | 4.97 | t2 | +| 2021-01-01T00:00:20Z | -3.75 | t2 | +| 2021-01-01T00:00:30Z | 19.77 | t2 | +| 2021-01-01T00:00:40Z | 13.86 | t2 | +| 2021-01-01T00:00:50Z | 1.86 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/floor.md b/content/flux/v0.x/stdlib/math/floor.md index 3b6088e53..7607b0cf7 100644 --- a/content/flux/v0.x/stdlib/math/floor.md +++ b/content/flux/v0.x/stdlib/math/floor.md @@ -1,38 +1,120 @@ --- title: math.floor() function -description: The math.floor() function returns the greatest integer value less than or equal to `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/floor/ - - /influxdb/v2.0/reference/flux/stdlib/math/floor/ - - /influxdb/cloud/reference/flux/stdlib/math/floor/ +description: > + `math.floor()` returns the greatest integer value less than or equal to `x`. menu: flux_0_x_ref: name: math.floor parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/floor +weight: 101 --- -The `math.floor()` function returns the greatest integer value less than or equal to `x`. + + +`math.floor()` returns the greatest integer value less than or equal to `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the nearest integer less than a value](#return-the-nearest-integer-less-than-a-value) +- [Use math.floor in map](#use-mathfloor-in-map) + +### Return the nearest integer less than a value ```js import "math" -math.floor(x: 1.22) +math.floor(x: 1.22)// 1.0 -// Returns 1.0 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.floor in map -## Special cases ```js -math.floor(±0) // Returns ±0 -math.floor(±Inf) // Returns ±Inf -math.floor(NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.floor(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -3 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -4 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/frexp.md b/content/flux/v0.x/stdlib/math/frexp.md index 5a9607755..08d44651e 100644 --- a/content/flux/v0.x/stdlib/math/frexp.md +++ b/content/flux/v0.x/stdlib/math/frexp.md @@ -1,43 +1,127 @@ --- title: math.frexp() function description: > - The math.frexp() function breaks `f` into a normalized fraction and an integral power of two. - It returns `frac` and `exp` satisfying `f == frac × 2**exp`, with the absolute - value of `frac` in the interval [½, 1). -aliases: - - /influxdb/v2.0/reference/flux/functions/math/frexp/ - - /influxdb/v2.0/reference/flux/stdlib/math/frexp/ - - /influxdb/cloud/reference/flux/stdlib/math/frexp/ + `math.frexp()` breaks `f` into a normalized fraction and an integral part of two. menu: flux_0_x_ref: name: math.frexp parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/frexp +weight: 101 --- -The `math.frexp()` function breaks `f` into a normalized fraction and an integral power of two. -It returns `frac` and `exp` satisfying `f == frac × 2**exp`, with the absolute value -of `frac` in the interval `[½, 1)`. + + +`math.frexp()` breaks `f` into a normalized fraction and an integral part of two. + +It returns **frac** and **exp** satisfying `f == frac x 2**exp`, +with the absolute value of **frac** in the interval [1/2, 1). + +##### Function type signature + +```js +(f: float) => {frac: float, exp: int} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### f +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the normalize fraction and integral of a value](#return-the-normalize-fraction-and-integral-of-a-value) +- [Use math.frexp in map](#use-mathfrexp-in-map) + +### Return the normalize fraction and integral of a value ```js import "math" -math.frexp(f: 22.0) +math.frexp(f: 22.0)// {exp: 5, frac: 0.6875} -// Returns {frac: 0.6875, exp: 5} ``` -## Parameters -### f {data-type="float"} -The value used in the operation. +### Use math.frexp in map -## Special cases ```js -math.frexp(f: ±0) // Returns {frac: ±0, exp: 0} -math.frexp(f: ±Inf) // Returns {frac: ±Inf, exp: 0} -math.frexp(f: NaN) // Returns {frac: NaN, exp: 0} +import "sampledata" +import "math" + +sampledata.float() + |> map( + fn: (r) => { + result = math.frexp(f: r._value) + + return {r with exp: result.exp, frac: result.frac} + }, + ) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | exp | frac | *tag | +| -------------------- | ------- | ---- | --------- | ---- | +| 2021-01-01T00:00:00Z | -2.18 | 2 | -0.545 | t1 | +| 2021-01-01T00:00:10Z | 10.92 | 4 | 0.6825 | t1 | +| 2021-01-01T00:00:20Z | 7.35 | 3 | 0.91875 | t1 | +| 2021-01-01T00:00:30Z | 17.53 | 5 | 0.5478125 | t1 | +| 2021-01-01T00:00:40Z | 15.23 | 4 | 0.951875 | t1 | +| 2021-01-01T00:00:50Z | 4.43 | 3 | 0.55375 | t1 | + +| _time | _value | exp | frac | *tag | +| -------------------- | ------- | ---- | --------- | ---- | +| 2021-01-01T00:00:00Z | 19.85 | 5 | 0.6203125 | t2 | +| 2021-01-01T00:00:10Z | 4.97 | 3 | 0.62125 | t2 | +| 2021-01-01T00:00:20Z | -3.75 | 2 | -0.9375 | t2 | +| 2021-01-01T00:00:30Z | 19.77 | 5 | 0.6178125 | t2 | +| 2021-01-01T00:00:40Z | 13.86 | 4 | 0.86625 | t2 | +| 2021-01-01T00:00:50Z | 1.86 | 1 | 0.93 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/gamma.md b/content/flux/v0.x/stdlib/math/gamma.md index 6105a7fa9..480e17562 100644 --- a/content/flux/v0.x/stdlib/math/gamma.md +++ b/content/flux/v0.x/stdlib/math/gamma.md @@ -1,41 +1,120 @@ --- title: math.gamma() function -description: The math.gamma() function returns the Gamma function of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/gamma/ - - /influxdb/v2.0/reference/flux/stdlib/math/gamma/ - - /influxdb/cloud/reference/flux/stdlib/math/gamma/ +description: > + `math.gamma()` returns the gamma function of `x`. menu: flux_0_x_ref: name: math.gamma parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/gamma +weight: 101 --- -The `math.gamma()` function returns the Gamma function of `x`. + + +`math.gamma()` returns the gamma function of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the gamma function of a value](#return-the-gamma-function-of-a-value) +- [Use math.gamma in map](#use-mathgamma-in-map) + +### Return the gamma function of a value ```js import "math" -math.gamma(x: 2.12) +math.gamma(x: 2.12)// 1.056821007887572 -// Returns 1.056821007887572 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.gamma in map -## Special cases ```js -math.gamma(x: +Inf) = +Inf -math.gamma(x: +0) = +Inf -math.gamma(x: -0) = -Inf -math.gamma(x: <0) = NaN for integer x < 0 -math.gamma(x: -Inf) = NaN -math.gamma(x: NaN) = NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.gamma(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | -2.4674191070057323 | t1 | +| 2021-01-01T00:00:10Z | 3007373.527042938 | t1 | +| 2021-01-01T00:00:20Z | 1399.634749015074 | t1 | +| 2021-01-01T00:00:30Z | 93234791408407.83 | t1 | +| 2021-01-01T00:00:40Z | 161558763355.0403 | t1 | +| 2021-01-01T00:00:50Z | 10.560583496997582 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 77953108609300690 | t2 | +| 2021-01-01T00:00:10Z | 22.94201890526749 | t2 | +| 2021-01-01T00:00:20Z | 0.26786612886141653 | t2 | +| 2021-01-01T00:00:30Z | 61513013150171220 | t2 | +| 2021-01-01T00:00:40Z | 4328485003.951652 | t2 | +| 2021-01-01T00:00:50Z | 0.9486870416779484 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/hypot.md b/content/flux/v0.x/stdlib/math/hypot.md index d8ea88c1e..aa13b1c1e 100644 --- a/content/flux/v0.x/stdlib/math/hypot.md +++ b/content/flux/v0.x/stdlib/math/hypot.md @@ -1,45 +1,107 @@ --- title: math.hypot() function description: > - The math.hypot() function returns the square root of `p*p + q*q`, - taking care to avoid unnecessary overflow and underflow. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/hypot/ - - /influxdb/v2.0/reference/flux/stdlib/math/hypot/ - - /influxdb/cloud/reference/flux/stdlib/math/hypot/ + `math.hypot()` returns the square root of `p*p + q*q`, taking care to avoid overflow + and underflow. menu: flux_0_x_ref: name: math.hypot parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/hypot +weight: 101 --- -The `math.hypot()` function returns the square root of `p*p + q*q`, -taking care to avoid overflow and underflow. + + +`math.hypot()` returns the square root of `p*p + q*q`, taking care to avoid overflow +and underflow. + + + +##### Function type signature + +```js +(p: float, q: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### p +({{< req >}}) +p-value to use in the operation. + + + +### q +({{< req >}}) +q-value to use in the operation. + + + + +## Examples + +- [Return the hypotenuse of two values](#return-the-hypotenuse-of-two-values) +- [Use math.hypot in map](#use-mathhypot-in-map) + +### Return the hypotenuse of two values ```js import "math" -math.hypot(p: 2.0, q: 5.0) +math.hypot(p: 2.0, q: 5.0)// 5.385164807134505 -// Returns 5.385164807134505 ``` -## Parameters -### p {data-type="float"} -The p value used in the operation. +### Use math.hypot in map -### q {data-type="float"} -The q value used in the operation. - -## Special cases ```js -math.hypot(p: ±Inf, q:q) // Returns +Inf -math.hypot(p:p, q: ±Inf) // Returns +Inf -math.hypot(p: NaN, q:q) // Returns NaN -math.hypot(p:p, q: NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({r with _value: math.hypot(p: r.a, q: r.b)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| triangle | a | b | +| --------- | ----- | ---- | +| t1 | 12.3 | 11.7 | +| t2 | 109.6 | 23.3 | +| t3 | 8.2 | 34.2 | +| t4 | 33.9 | 28 | +| t5 | 25 | 25 | + + +#### Output data + +| _value | a | b | triangle | +| ------------------ | ----- | ---- | --------- | +| 16.975865220954127 | 12.3 | 11.7 | t1 | +| 112.04931949815669 | 109.6 | 23.3 | t2 | +| 35.16930479836074 | 8.2 | 34.2 | t3 | +| 43.9682840238279 | 33.9 | 28 | t4 | +| 35.35533905932738 | 25 | 25 | t5 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/ilogb.md b/content/flux/v0.x/stdlib/math/ilogb.md index 639154e26..f34825810 100644 --- a/content/flux/v0.x/stdlib/math/ilogb.md +++ b/content/flux/v0.x/stdlib/math/ilogb.md @@ -1,38 +1,120 @@ --- title: math.ilogb() function -description: The math.ilogb() function returns the binary exponent of `x` as an integer. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/ilogb/ - - /influxdb/v2.0/reference/flux/stdlib/math/ilogb/ - - /influxdb/cloud/reference/flux/stdlib/math/ilogb/ +description: > + `math.ilogb()` returns the binary exponent of `x` as an integer. menu: flux_0_x_ref: name: math.ilogb parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/ilogb +weight: 101 --- -The `math.ilogb()` function returns the binary exponent of `x` as an integer. + + +`math.ilogb()` returns the binary exponent of `x` as an integer. + + + +##### Function type signature + +```js +(x: float) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the binary exponent of a value](#return-the-binary-exponent-of-a-value) +- [Use math.ilogb in map](#use-mathilogb-in-map) + +### Return the binary exponent of a value ```js import "math" -math.ilogb(x: 123.45) +math.ilogb(x: 123.45)// 6 -// Returns 6.0 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.ilogb in map -## Special cases ```js -math.ilogb(x: ±Inf) // Returns MaxInt32 -math.ilogb(x: 0) // Returns MinInt32 -math.ilogb(x: NaN) // Returns MaxInt32 +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.ilogb(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 3 | t1 | +| 2021-01-01T00:00:20Z | 2 | t1 | +| 2021-01-01T00:00:30Z | 4 | t1 | +| 2021-01-01T00:00:40Z | 3 | t1 | +| 2021-01-01T00:00:50Z | 2 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 4 | t2 | +| 2021-01-01T00:00:10Z | 2 | t2 | +| 2021-01-01T00:00:20Z | 1 | t2 | +| 2021-01-01T00:00:30Z | 4 | t2 | +| 2021-01-01T00:00:40Z | 3 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/isinf.md b/content/flux/v0.x/stdlib/math/isinf.md index 126f8e8ab..12ba9dcee 100644 --- a/content/flux/v0.x/stdlib/math/isinf.md +++ b/content/flux/v0.x/stdlib/math/isinf.md @@ -1,39 +1,127 @@ --- title: math.isInf() function -description: The math.isInf() function reports whether `f` is an infinity, according to `sign`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/isinf/ - - /influxdb/v2.0/reference/flux/stdlib/math/isinf/ - - /influxdb/cloud/reference/flux/stdlib/math/isinf/ +description: > + `math.isInf()` reports whether `f` is an infinity, according to `sign`. menu: flux_0_x_ref: name: math.isInf parent: math -weight: 301 -flux/v0.x/tags: [tests] -introduced: 0.22.0 + identifier: math/isInf +weight: 101 --- -The `math.isInf()` function reports whether `f` is an infinity, according to sign. + + +`math.isInf()` reports whether `f` is an infinity, according to `sign`. + +If `sign > 0`, math.isInf reports whether `f` is positive infinity. +If `sign < 0`, math.isInf reports whether `f` is negative infinity. +If `sign == 0`, math.isInf reports whether `f` is either infinity. + +##### Function type signature + +```js +(f: float, sign: int) => bool +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### f +({{< req >}}) +is the value used in the evaluation. + + + +### sign +({{< req >}}) +is the sign used in the eveluation. + + + + +## Examples + +- [Test if a value is an infinity value](#test-if-a-value-is-an-infinity-value) +- [Use math.isInf in map](#use-mathisinf-in-map) + +### Test if a value is an infinity value ```js import "math" -math.isInf(f: 2.12, sign: 3) +math.isInf(f: 2.12, sign: 3)// false -// Returns false ``` -## Parameters -### f {data-type="float"} -The value used in the evaluation. +### Use math.isInf in map -### sign {data-type="int"} -The sign used in the evaluation. +```js +import "math" + +data + |> map(fn: (r) => ({r with _value: math.isInf(f: r._value, sign: 1)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | +Inf | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | +Inf | +| 2021-01-01T00:00:40Z | t1 | +Inf | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | +Inf | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | +Inf | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | false | t1 | +| 2021-01-01T00:00:10Z | true | t1 | +| 2021-01-01T00:00:20Z | false | t1 | +| 2021-01-01T00:00:30Z | true | t1 | +| 2021-01-01T00:00:40Z | true | t1 | +| 2021-01-01T00:00:50Z | false | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | true | t2 | +| 2021-01-01T00:00:10Z | false | t2 | +| 2021-01-01T00:00:20Z | false | t2 | +| 2021-01-01T00:00:30Z | false | t2 | +| 2021-01-01T00:00:40Z | true | t2 | +| 2021-01-01T00:00:50Z | false | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/isnan.md b/content/flux/v0.x/stdlib/math/isnan.md index f1c76d82e..ec6a5a048 100644 --- a/content/flux/v0.x/stdlib/math/isnan.md +++ b/content/flux/v0.x/stdlib/math/isnan.md @@ -1,32 +1,119 @@ --- title: math.isNaN() function -description: The math.isNaN() function reports whether `f` is an IEEE 754 “not-a-number” value. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/isnan/ - - /influxdb/v2.0/reference/flux/stdlib/math/isnan/ - - /influxdb/cloud/reference/flux/stdlib/math/isnan/ +description: > + `math.isNaN()` reports whether `f` is an IEEE 754 "not-a-number" value. menu: flux_0_x_ref: name: math.isNaN parent: math -weight: 301 -flux/v0.x/tags: [tests] -introduced: 0.22.0 + identifier: math/isNaN +weight: 101 --- -The `math.isNaN()` function reports whether `f` is an IEEE 754 “not-a-number” value. + + +`math.isNaN()` reports whether `f` is an IEEE 754 "not-a-number" value. + + + +##### Function type signature + +```js +(f: float) => bool +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### f +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Check if a value is a NaN float value](#check-if-a-value-is-a-nan-float-value) +- [Use math.isNaN in map](#use-mathisnan-in-map) + +### Check if a value is a NaN float value ```js import "math" -math.isNaN(f: 12.345) +math.isNaN(f: 12.345)// false -// Returns false ``` -## Parameters -### f {data-type="float"} -The value used in the evaluation. +### Use math.isNaN in map + +```js +import "math" + +data + |> map(fn: (r) => ({r with _value: math.isNaN(f: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | NaN | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | NaN | +| 2021-01-01T00:00:40Z | t1 | NaN | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | NaN | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | NaN | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | false | t1 | +| 2021-01-01T00:00:10Z | true | t1 | +| 2021-01-01T00:00:20Z | false | t1 | +| 2021-01-01T00:00:30Z | true | t1 | +| 2021-01-01T00:00:40Z | true | t1 | +| 2021-01-01T00:00:50Z | false | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | true | t2 | +| 2021-01-01T00:00:10Z | false | t2 | +| 2021-01-01T00:00:20Z | false | t2 | +| 2021-01-01T00:00:30Z | false | t2 | +| 2021-01-01T00:00:40Z | true | t2 | +| 2021-01-01T00:00:50Z | false | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/j0.md b/content/flux/v0.x/stdlib/math/j0.md index 8b4aa8f88..7d71c13c3 100644 --- a/content/flux/v0.x/stdlib/math/j0.md +++ b/content/flux/v0.x/stdlib/math/j0.md @@ -1,38 +1,120 @@ --- title: math.j0() function -description: The math.j0() function returns the order-zero Bessel function of the first kind. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/j0/ - - /influxdb/v2.0/reference/flux/stdlib/math/j0/ - - /influxdb/cloud/reference/flux/stdlib/math/j0/ +description: > + `math.j0()` returns the order-zero Bessel function of the first kind. menu: flux_0_x_ref: name: math.j0 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/j0 +weight: 101 --- -The `math.j0()` function returns the order-zero Bessel function of the first kind. + + +`math.j0()` returns the order-zero Bessel function of the first kind. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the order-zero Bessel function of a value](#return-the-order-zero-bessel-function-of-a-value) +- [Use math.j0 in map](#use-mathj0-in-map) + +### Return the order-zero Bessel function of a value ```js import "math" -math.j0(x: 1.23) +math.j0(x: 1.23)// 0.656070571706025 -// Returns 0.656070571706025 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.j0 in map -## Special cases ```js -math.j0(x: ±Inf) // Returns 0 -math.j0(x: 0) // Returns 1 -math.j0(x: NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.j0(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.12150949471274336 | t1 | +| 2021-01-01T00:00:10Z | -0.1848208162077201 | t1 | +| 2021-01-01T00:00:20Z | 0.2837448367876356 | t1 | +| 2021-01-01T00:00:30Z | -0.09816636158288365 | t1 | +| 2021-01-01T00:00:40Z | -0.0602560278685108 | t1 | +| 2021-01-01T00:00:50Z | -0.3360414225378073 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.17516950223786715 | t2 | +| 2021-01-01T00:00:10Z | -0.18737219444686604 | t2 | +| 2021-01-01T00:00:20Z | -0.4014060549361743 | t2 | +| 2021-01-01T00:00:30Z | 0.1779340476167977 | t2 | +| 2021-01-01T00:00:40Z | 0.18809934034815845 | t2 | +| 2021-01-01T00:00:50Z | 0.30507973268984145 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/j1.md b/content/flux/v0.x/stdlib/math/j1.md index 225131cb9..dfb4de258 100644 --- a/content/flux/v0.x/stdlib/math/j1.md +++ b/content/flux/v0.x/stdlib/math/j1.md @@ -1,37 +1,120 @@ --- title: math.j1() function -description: The math.j1() function returns the order-one Bessel function of the first kind. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/j1/ - - /influxdb/v2.0/reference/flux/stdlib/math/j1/ - - /influxdb/cloud/reference/flux/stdlib/math/j1/ +description: > + `math.j1()` is a funciton that returns the order-one Bessel function for the first kind. menu: flux_0_x_ref: name: math.j1 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/j1 +weight: 101 --- -The `math.j1()` function returns the order-one Bessel function of the first kind. + + +`math.j1()` is a funciton that returns the order-one Bessel function for the first kind. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the order-one Bessel function of a value](#return-the-order-one-bessel-function-of-a-value) +- [Use math.j1 in map](#use-mathj1-in-map) + +### Return the order-one Bessel function of a value ```js import "math" -math.j1(x: 1.23) +math.j1(x: 1.23)// 0.5058005726280961 -// Returns 0.5058005726280961 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.j1 in map -## Special cases ```js -math.j1(±Inf) // Returns 0 -math.j1(NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.j1(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.5587345375771166 | t1 | +| 2021-01-01T00:00:10Z | -0.16378152627369913 | t1 | +| 2021-01-01T00:00:20Z | 0.096261851305172 | t1 | +| 2021-01-01T00:00:30Z | -0.16615705227678823 | t1 | +| 2021-01-01T00:00:40Z | 0.19344160659360385 | t1 | +| 2021-01-01T00:00:50Z | -0.21154289673897086 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.041529757669801666 | t2 | +| 2021-01-01T00:00:10Z | -0.3240653024080138 | t2 | +| 2021-01-01T00:00:20Z | -0.03322934912967974 | t2 | +| 2021-01-01T00:00:30Z | 0.027537686650143067 | t2 | +| 2021-01-01T00:00:40Z | 0.10941596518105894 | t2 | +| 2021-01-01T00:00:50Z | 0.5817926469097867 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/jn.md b/content/flux/v0.x/stdlib/math/jn.md index cdb565aa5..a8739fe7d 100644 --- a/content/flux/v0.x/stdlib/math/jn.md +++ b/content/flux/v0.x/stdlib/math/jn.md @@ -1,40 +1,126 @@ --- title: math.jn() function -description: The math.jn() function returns the order-n Bessel function of the first kind. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/jn/ - - /influxdb/v2.0/reference/flux/stdlib/math/jn/ - - /influxdb/cloud/reference/flux/stdlib/math/jn/ +description: > + `math.jn()` returns the order-n Bessel funciton of the first kind. menu: flux_0_x_ref: name: math.jn parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/jn +weight: 101 --- -The `math.jn()` function returns the order-n Bessel function of the first kind. + + +`math.jn()` returns the order-n Bessel funciton of the first kind. + + + +##### Function type signature + +```js +(n: int, x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### n +({{< req >}}) +Order number. + + + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the order-n Bessel function of a value](#return-the-order-n-bessel-function-of-a-value) +- [Use math.jn in map](#use-mathjn-in-map) + +### Return the order-n Bessel function of a value ```js import "math" -math.jn(n: 2, x: 1.23) +math.jn(n: 2, x: 1.23)// 0.16636938378681407 -// Returns 0.16636938378681407 ``` -## Parameters -### n {data-type="int"} -The order number. +### Use math.jn in map -### x {data-type="float"} -The value used in the operation. - -## Special cases ```js -math.jn(n:n, x: ±Inf) // Returns 0 -math.jn(n:n, x: NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.jn(n: 4, x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | --------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.046148335742456664 | t1 | +| 2021-01-01T00:00:10Z | -0.03367382202216673 | t1 | +| 2021-01-01T00:00:20Z | 0.06455053599079605 | t1 | +| 2021-01-01T00:00:30Z | -0.016152633110842446 | t1 | +| 2021-01-01T00:00:40Z | -0.15300380439231542 | t1 | +| 2021-01-01T00:00:50Z | 0.3401384178914538 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.14801732445932958 | t2 | +| 2021-01-01T00:00:10Z | 0.3896093468299793 | t2 | +| 2021-01-01T00:00:20Z | 0.24301709268606153 | t2 | +| 2021-01-01T00:00:30Z | 0.15603599253486927 | t2 | +| 2021-01-01T00:00:40Z | 0.10341672446511223 | t2 | +| 2021-01-01T00:00:50Z | 0.026150267042506597 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/ldexp.md b/content/flux/v0.x/stdlib/math/ldexp.md index c7e81b130..0979e77a6 100644 --- a/content/flux/v0.x/stdlib/math/ldexp.md +++ b/content/flux/v0.x/stdlib/math/ldexp.md @@ -1,42 +1,125 @@ --- title: math.ldexp() function -description: The math.ldexp() function is the inverse of `math.frexp()`. It returns `frac × 2**exp`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/ldexp/ - - /influxdb/v2.0/reference/flux/stdlib/math/ldexp/ - - /influxdb/cloud/reference/flux/stdlib/math/ldexp/ +description: > + `math.ldexp()` is the inverse of `math.frexp()`. It returns `frac x 2**exp`. menu: flux_0_x_ref: name: math.ldexp parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/ldexp +weight: 101 --- -The `math.ldexp()` function is the inverse of [`math.frexp()`](/flux/v0.x/stdlib/math/frexp). -It returns `frac × 2**exp`. + + +`math.ldexp()` is the inverse of `math.frexp()`. It returns `frac x 2**exp`. + + + +##### Function type signature + +```js +(exp: int, frac: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### frac +({{< req >}}) +Fraction to use in the operation. + + + +### exp +({{< req >}}) +Exponent to use in the operation. + + + + +## Examples + +- [Return the inverse of math.frexp](#return-the-inverse-of-mathfrexp) +- [Use math.ldexp in map](#use-mathldexp-in-map) + +### Return the inverse of math.frexp ```js import "math" -math.ldexp(frac: 0.5, exp: 6) +math.ldexp(frac: 0.5, exp: 6)// 32.0 -// Returns 32.0 ``` -## Parameters -### frac {data-type="float"} -The fraction used in the operation. +### Use math.ldexp in map -### exp {data-type="int"} -The exponent used in the operation. - -## Special cases ```js -math.ldexp(frac: ±0, exp:exp) // Returns ±0 -math.ldexp(frac: ±Inf, exp:exp) // Returns ±Inf -math.ldexp(frac: NaN, exp:exp) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({_time: r._time, tag: r.tag, _value: math.ldexp(frac: r.frac, exp: r.exp)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| *tag | _time | exp | frac | +| ---- | -------------------- | ---- | --------- | +| t1 | 2021-01-01T00:00:00Z | 2 | -0.545 | +| t1 | 2021-01-01T00:00:10Z | 4 | 0.6825 | +| t1 | 2021-01-01T00:00:20Z | 3 | 0.91875 | +| t1 | 2021-01-01T00:00:30Z | 5 | 0.5478125 | +| t1 | 2021-01-01T00:00:40Z | 4 | 0.951875 | +| t1 | 2021-01-01T00:00:50Z | 3 | 0.55375 | + +| *tag | _time | exp | frac | +| ---- | -------------------- | ---- | --------- | +| t2 | 2021-01-01T00:00:00Z | 5 | 0.6203125 | +| t2 | 2021-01-01T00:00:10Z | 3 | 0.62125 | +| t2 | 2021-01-01T00:00:20Z | 2 | -0.9375 | +| t2 | 2021-01-01T00:00:30Z | 5 | 0.6178125 | +| t2 | 2021-01-01T00:00:40Z | 4 | 0.86625 | +| t2 | 2021-01-01T00:00:50Z | 1 | 0.93 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2.18 | t1 | +| 2021-01-01T00:00:10Z | 10.92 | t1 | +| 2021-01-01T00:00:20Z | 7.35 | t1 | +| 2021-01-01T00:00:30Z | 17.53 | t1 | +| 2021-01-01T00:00:40Z | 15.23 | t1 | +| 2021-01-01T00:00:50Z | 4.43 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19.85 | t2 | +| 2021-01-01T00:00:10Z | 4.97 | t2 | +| 2021-01-01T00:00:20Z | -3.75 | t2 | +| 2021-01-01T00:00:30Z | 19.77 | t2 | +| 2021-01-01T00:00:40Z | 13.86 | t2 | +| 2021-01-01T00:00:50Z | 1.86 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/lgamma.md b/content/flux/v0.x/stdlib/math/lgamma.md index 7a42dce97..17dab773d 100644 --- a/content/flux/v0.x/stdlib/math/lgamma.md +++ b/content/flux/v0.x/stdlib/math/lgamma.md @@ -1,40 +1,126 @@ --- title: math.lgamma() function -description: The math.lgamma() function returns the natural logarithm and sign (-1 or +1) of `math.gamma(x:x)`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/lgamma/ - - /influxdb/v2.0/reference/flux/stdlib/math/lgamma/ - - /influxdb/cloud/reference/flux/stdlib/math/lgamma/ +description: > + `math.lgamma()` returns the natural logarithm and sign (-1 or +1) of `math.gamma(x:x)`. menu: flux_0_x_ref: name: math.lgamma parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/lgamma +weight: 101 --- -The `math.lgamma()` function returns the natural logarithm and sign (-1 or +1) of `math.gamma(x:x)`. + + +`math.lgamma()` returns the natural logarithm and sign (-1 or +1) of `math.gamma(x:x)`. + + + +##### Function type signature + +```js +(x: float) => {sign: int, lgamma: float} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the natural logarithm and sign of a gamma function](#return-the-natural-logarithm-and-sign-of-a-gamma-function) +- [Use math.lgamma in map](#use-mathlgamma-in-map) + +### Return the natural logarithm and sign of a gamma function ```js import "math" -math.lgamma(x: 3.14) +math.lgamma(x: 3.14)// {lgamma: 0.8261387047770286, sign: 1} -// Returns {lgamma: 0.8261387047770286, sign: 1} ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.lgamma in map -## Special cases ```js -math.lgamma(x: +Inf) // Returns +Inf -math.lgamma(x: 0) // Returns +Inf -math.lgamma(x: -integer) // Returns +Inf -math.lgamma(x: -Inf) // Returns -Inf -math.lgamma(x: NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map( + fn: (r) => { + result = math.lgamma(x: r._value) + + return {r with lgamma: result.lgamma, sign: result.sign} + }, + ) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | lgamma | sign | *tag | +| -------------------- | ------- | ------------------ | ----- | ---- | +| 2021-01-01T00:00:00Z | -2.18 | 0.9031727084064437 | -1 | t1 | +| 2021-01-01T00:00:10Z | 10.92 | 14.916577673425685 | 1 | t1 | +| 2021-01-01T00:00:20Z | 7.35 | 7.243966588004043 | 1 | t1 | +| 2021-01-01T00:00:30Z | 17.53 | 32.16614206633506 | 1 | t1 | +| 2021-01-01T00:00:40Z | 15.23 | 25.808134773211734 | 1 | t1 | +| 2021-01-01T00:00:50Z | 4.43 | 2.3571285321490905 | 1 | t1 | + +| _time | _value | lgamma | sign | *tag | +| -------------------- | ------- | --------------------- | ----- | ---- | +| 2021-01-01T00:00:00Z | 19.85 | 38.8948838691485 | 1 | t2 | +| 2021-01-01T00:00:10Z | 4.97 | 3.132970115904918 | 1 | t2 | +| 2021-01-01T00:00:20Z | -3.75 | -1.3172679424463634 | 1 | t2 | +| 2021-01-01T00:00:30Z | 19.77 | 38.65802514327764 | 1 | t2 | +| 2021-01-01T00:00:40Z | 13.86 | 22.188483434123324 | 1 | t2 | +| 2021-01-01T00:00:50Z | 1.86 | -0.052676311706898016 | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/log.md b/content/flux/v0.x/stdlib/math/log.md index 2f1fcf1ea..dd48abc42 100644 --- a/content/flux/v0.x/stdlib/math/log.md +++ b/content/flux/v0.x/stdlib/math/log.md @@ -1,39 +1,74 @@ --- title: math.log() function -description: The math.log() function returns the natural logarithm of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/log/ - - /influxdb/v2.0/reference/flux/stdlib/math/log/ - - /influxdb/cloud/reference/flux/stdlib/math/log/ +description: > + `math.log()` returns the natural logarithm of `x`. menu: flux_0_x_ref: name: math.log parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/log +weight: 101 --- -The `math.log()` function returns the natural logarithm of `x`. + + +`math.log()` returns the natural logarithm of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the natural logarithm of a value](#return-the-natural-logarithm-of-a-value) +- [Use math.log in map](#use-mathlog-in-map) + +### Return the natural logarithm of a value ```js import "math" -math.log(x: 3.14) +math.log(x: 3.14)// 1.144222799920162 -// Returns 1.144222799920162 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.log in map -## Special cases ```js -math.log(x: +Inf) // Returns +Inf -math.log(x: 0) // Returns -Inf -math.log(x: <0) // Returns NaN -math.log(x: NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.log(x: r._value)})) ``` + diff --git a/content/flux/v0.x/stdlib/math/log10.md b/content/flux/v0.x/stdlib/math/log10.md index 8a718ed44..e2610b618 100644 --- a/content/flux/v0.x/stdlib/math/log10.md +++ b/content/flux/v0.x/stdlib/math/log10.md @@ -1,39 +1,74 @@ --- title: math.log10() function -description: The math.log10() function returns the decimal logarithm of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/log10/ - - /influxdb/v2.0/reference/flux/stdlib/math/log10/ - - /influxdb/cloud/reference/flux/stdlib/math/log10/ +description: > + `math.log10()` returns the decimal logarithm of x. menu: flux_0_x_ref: name: math.log10 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/log10 +weight: 101 --- -The `math.log10()` function returns the decimal logarithm of `x`. + + +`math.log10()` returns the decimal logarithm of x. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the decimal lagarithm of a value](#return-the-decimal-lagarithm-of-a-value) +- [Use math.log10 in map](#use-mathlog10-in-map) + +### Return the decimal lagarithm of a value ```js import "math" -math.log10(x: 3.14) +math.log10(x: 3.14)// 0.4969296480732149 -// Returns 0.4969296480732149 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.log10 in map -## Special cases ```js -math.log10(x: +Inf) // Returns +Inf -math.log10(x: 0) // Returns -Inf -math.log10(x: <0) // Returns NaN -math.log10(x: NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.log10(x: r._value)})) ``` + diff --git a/content/flux/v0.x/stdlib/math/log1p.md b/content/flux/v0.x/stdlib/math/log1p.md index 9d4be6722..0968d2aac 100644 --- a/content/flux/v0.x/stdlib/math/log1p.md +++ b/content/flux/v0.x/stdlib/math/log1p.md @@ -1,43 +1,123 @@ --- title: math.log1p() function description: > - The math.log1p() function returns the natural logarithm of 1 plus its argument `x`. - It is more accurate than `math.log(x: 1 + x)` when `x` is near zero. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/log1p/ - - /influxdb/v2.0/reference/flux/stdlib/math/log1p/ - - /influxdb/cloud/reference/flux/stdlib/math/log1p/ + `math.log1p()` returns the natural logarithm of 1 plus `x`. + This operation is more accurate than `math.log(x: 1 + x)` when `x` is + near zero. menu: flux_0_x_ref: name: math.log1p parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/log1p +weight: 101 --- -The `math.log1p()` function returns the natural logarithm of 1 plus its argument `x`. -It is more accurate than `math.log(x: 1 + x)` when `x` is near zero. + + +`math.log1p()` returns the natural logarithm of 1 plus `x`. +This operation is more accurate than `math.log(x: 1 + x)` when `x` is +near zero. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the natural logarithm of values near zero](#return-the-natural-logarithm-of-values-near-zero) +- [Use math.log1p in map](#use-mathlog1p-in-map) + +### Return the natural logarithm of values near zero ```js import "math" -math.log1p(x: 0.56) +math.log1p(x: 0.56)// 0.44468582126144574 -// Returns 0.44468582126144574 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.log1p in map -## Special cases ```js -math.log1p(x: +Inf) // Returns +Inf -math.log1p(x: ±0) // Returns ±0 -math.log1p(x: -1) // Returns -Inf -math.log1p(x: <-1) // Returns NaN -math.log1p(x: NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({r with _value: math.log1p(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | --------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.021800000000000003 | t1 | +| 2021-01-01T00:00:10Z | 0.1092 | t1 | +| 2021-01-01T00:00:20Z | 0.0735 | t1 | +| 2021-01-01T00:00:30Z | 0.1753 | t1 | +| 2021-01-01T00:00:40Z | 0.15230000000000002 | t1 | +| 2021-01-01T00:00:50Z | 0.0443 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.1985 | t2 | +| 2021-01-01T00:00:10Z | 0.0497 | t2 | +| 2021-01-01T00:00:20Z | -0.0375 | t2 | +| 2021-01-01T00:00:30Z | 0.1977 | t2 | +| 2021-01-01T00:00:40Z | 0.1386 | t2 | +| 2021-01-01T00:00:50Z | 0.018600000000000002 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.02204113087688024 | t1 | +| 2021-01-01T00:00:10Z | 0.10363903475948592 | t1 | +| 2021-01-01T00:00:20Z | 0.07092433833669866 | t1 | +| 2021-01-01T00:00:30Z | 0.1615234341566714 | t1 | +| 2021-01-01T00:00:40Z | 0.14175994503783176 | t1 | +| 2021-01-01T00:00:50Z | 0.04334680450336586 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.181070774892302 | t2 | +| 2021-01-01T00:00:10Z | 0.048504409059614985 | t2 | +| 2021-01-01T00:00:20Z | -0.03822121282019776 | t2 | +| 2021-01-01T00:00:30Z | 0.18040305097132403 | t2 | +| 2021-01-01T00:00:40Z | 0.12979943753484446 | t2 | +| 2021-01-01T00:00:50Z | 0.018429135468367195 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/log2.md b/content/flux/v0.x/stdlib/math/log2.md index 333d347e5..b0f1cc455 100644 --- a/content/flux/v0.x/stdlib/math/log2.md +++ b/content/flux/v0.x/stdlib/math/log2.md @@ -1,39 +1,120 @@ --- title: math.log2() function -description: The math.log2() function returns the binary logarithm of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/log2/ - - /influxdb/v2.0/reference/flux/stdlib/math/log2/ - - /influxdb/cloud/reference/flux/stdlib/math/log2/ +description: > + `math.log2()` is a function returns the binary logarithm of `x`. menu: flux_0_x_ref: name: math.log2 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/log2 +weight: 101 --- -The `math.log2()` function returns the binary logarithm of `x`. + + +`math.log2()` is a function returns the binary logarithm of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +the value used in the operation. + + + + +## Examples + +- [Return the binary logarithm of a value](#return-the-binary-logarithm-of-a-value) +- [Use math.log2 in map](#use-mathlog2-in-map) + +### Return the binary logarithm of a value ```js import "math" -math.log2(x: 3.14) +math.log2(x: 3.14)// 1.6507645591169022 -// Returns 1.6507645591169022 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.log2 in map -## Special cases ```js -math.log2(x: +Inf) // Returns +Inf -math.log2(x: 0) // Returns -Inf -math.log2(x: <0) // Returns NaN -math.log2(x: NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.log2(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | NaN | t1 | +| 2021-01-01T00:00:10Z | 3.4489009511451276 | t1 | +| 2021-01-01T00:00:20Z | 2.877744249949002 | t1 | +| 2021-01-01T00:00:30Z | 4.131754090984813 | t1 | +| 2021-01-01T00:00:40Z | 3.9288440367125674 | t1 | +| 2021-01-01T00:00:50Z | 2.1473066987802936 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | 4.3110671022555955 | t2 | +| 2021-01-01T00:00:10Z | 2.3132458517875616 | t2 | +| 2021-01-01T00:00:20Z | NaN | t2 | +| 2021-01-01T00:00:30Z | 4.305240965954483 | t2 | +| 2021-01-01T00:00:40Z | 3.792855352362489 | t2 | +| 2021-01-01T00:00:50Z | 0.8953026213333067 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/logb.md b/content/flux/v0.x/stdlib/math/logb.md index be3f5fda0..6b90030f9 100644 --- a/content/flux/v0.x/stdlib/math/logb.md +++ b/content/flux/v0.x/stdlib/math/logb.md @@ -1,38 +1,120 @@ --- title: math.logb() function -description: The math.logb() function returns the binary exponent of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/logb/ - - /influxdb/v2.0/reference/flux/stdlib/math/logb/ - - /influxdb/cloud/reference/flux/stdlib/math/logb/ +description: > + `math.logb()` returns the binary exponent of `x`. menu: flux_0_x_ref: name: math.logb parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/logb +weight: 101 --- -The `math.logb()` function returns the binary exponent of `x`. + + +`math.logb()` returns the binary exponent of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the binary exponent of a value](#return-the-binary-exponent-of-a-value) +- [Use math.logb in map](#use-mathlogb-in-map) + +### Return the binary exponent of a value ```js import "math" -math.logb(x: 3.14) +math.logb(x: 3.14)// 1 -// Returns 1.0 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.logb in map -## Special cases ```js -math.logb(x: ±Inf) // Returns +Inf -math.logb(x: 0) // Returns -Inf -math.logb(x: NaN) // Returns NaN +import "sampledata" +import "math" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.logb(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 3 | t1 | +| 2021-01-01T00:00:20Z | 2 | t1 | +| 2021-01-01T00:00:30Z | 4 | t1 | +| 2021-01-01T00:00:40Z | 3 | t1 | +| 2021-01-01T00:00:50Z | 2 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 4 | t2 | +| 2021-01-01T00:00:10Z | 2 | t2 | +| 2021-01-01T00:00:20Z | 1 | t2 | +| 2021-01-01T00:00:30Z | 4 | t2 | +| 2021-01-01T00:00:40Z | 3 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/minf.md b/content/flux/v0.x/stdlib/math/minf.md index 75736070d..e0365d9b4 100644 --- a/content/flux/v0.x/stdlib/math/minf.md +++ b/content/flux/v0.x/stdlib/math/minf.md @@ -1,32 +1,122 @@ --- title: math.mInf() function -description: The math.mInf() function returns positive infinity if `sign >= 0`, negative infinity if `sign < 0`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/m_inf/ - - /influxdb/v2.0/reference/flux/stdlib/math/m_inf/ - - /influxdb/v2.0/reference/flux/stdlib/math/minf/ - - /influxdb/cloud/reference/flux/stdlib/math/minf/ +description: > + `math.mInf()` returns positive infinity if `sign >= 0`, negative infinity + if `sign < 0` menu: flux_0_x_ref: name: math.mInf parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/mInf +weight: 101 --- -The `math.mInf()` function returns positive infinity if `sign >= 0`, negative infinity if `sign < 0`. + + +`math.mInf()` returns positive infinity if `sign >= 0`, negative infinity +if `sign < 0` + + + +##### Function type signature + +```js +(sign: int) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### sign +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return an infinity float value from a positive or negative sign value](#return-an-infinity-float-value-from-a-positive-or-negative-sign-value) +- [Use math.mInf in map](#use-mathminf-in-map) + +### Return an infinity float value from a positive or negative sign value ```js import "math" -math.mInf(sign: 1) +math.mInf(sign: 1)// +Inf -// Returns +Inf ``` -## Parameters -### sign {data-type="int"} -The sign value used in the operation. +### Use math.mInf in map + +```js +import "sampledata" +import "math" + +sampledata.int() + |> map(fn: (r) => ({r with _value: math.mInf(sign: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -Inf | t1 | +| 2021-01-01T00:00:10Z | +Inf | t1 | +| 2021-01-01T00:00:20Z | +Inf | t1 | +| 2021-01-01T00:00:30Z | +Inf | t1 | +| 2021-01-01T00:00:40Z | +Inf | t1 | +| 2021-01-01T00:00:50Z | +Inf | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | +Inf | t2 | +| 2021-01-01T00:00:10Z | +Inf | t2 | +| 2021-01-01T00:00:20Z | -Inf | t2 | +| 2021-01-01T00:00:30Z | +Inf | t2 | +| 2021-01-01T00:00:40Z | +Inf | t2 | +| 2021-01-01T00:00:50Z | +Inf | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/mmax.md b/content/flux/v0.x/stdlib/math/mmax.md index 42a083079..8fc0ec254 100644 --- a/content/flux/v0.x/stdlib/math/mmax.md +++ b/content/flux/v0.x/stdlib/math/mmax.md @@ -1,46 +1,107 @@ --- title: math.mMax() function -description: The math.mMax() function returns the larger of `x` or `y`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/m_max/ - - /influxdb/v2.0/reference/flux/stdlib/math/m_max/ - - /influxdb/v2.0/reference/flux/stdlib/math/mmax/ - - /influxdb/cloud/reference/flux/stdlib/math/mmax/ +description: > + `math.mMax()` returns the larger of `x` or `y`. menu: flux_0_x_ref: name: math.mMax parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/mMax +weight: 101 --- -The `math.mMax()` function returns the larger of `x` or `y`. + + +`math.mMax()` returns the larger of `x` or `y`. + + + +##### Function type signature + +```js +(x: float, y: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +x-value to use in the operation. + + + +### y +({{< req >}}) +y-value to use in the operation. + + + + +## Examples + +- [Return the larger of two values](#return-the-larger-of-two-values) +- [Use math.mMax in map](#use-mathmmax-in-map) + +### Return the larger of two values ```js import "math" -math.mMax(x: 1.23, y: 4.56) +math.mMax(x: 1.23, y: 4.56)// 4.56 -// Returns 4.56 ``` -## Parameters -### x {data-type="float"} -The X value used in the operation. +### Use math.mMax in map -### y {data-type="float"} -The Y value used in the operation. - -## Special cases ```js -math.mMax(x:x, y:+Inf) // Returns +Inf -math.mMax(x: +Inf, y:y) // Returns +Inf -math.mMax(x:x, y: NaN) // Returns NaN -math.mMax(x: NaN, y:y) // Returns NaN -math.mMax(x: +0, y: ±0) // Returns +0 -math.mMax(x: ±0, y: +0) // Returns +0 -math.mMax(x: -0, y: -0) // Returns -0 +import "math" + +data + |> map(fn: (r) => ({_time: r._time, _value: math.mMax(x: r.t1, y: r.t2)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | t1 | t2 | +| -------------------- | ----- | ----- | +| 2021-01-01T00:00:00Z | -2.18 | 19.85 | +| 2021-01-01T00:00:10Z | 10.92 | 4.97 | +| 2021-01-01T00:00:20Z | 7.35 | -3.75 | +| 2021-01-01T00:00:30Z | 17.53 | 19.77 | +| 2021-01-01T00:00:40Z | 15.23 | 13.86 | +| 2021-01-01T00:00:50Z | 4.43 | 1.86 | + + +#### Output data + +| _time | _value | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | 19.85 | +| 2021-01-01T00:00:10Z | 10.92 | +| 2021-01-01T00:00:20Z | 7.35 | +| 2021-01-01T00:00:30Z | 19.77 | +| 2021-01-01T00:00:40Z | 15.23 | +| 2021-01-01T00:00:50Z | 4.43 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/mmin.md b/content/flux/v0.x/stdlib/math/mmin.md index ceb33f2bb..3df51eddd 100644 --- a/content/flux/v0.x/stdlib/math/mmin.md +++ b/content/flux/v0.x/stdlib/math/mmin.md @@ -1,45 +1,107 @@ --- title: math.mMin() function -description: The math.mMin() function returns the smaller of `x` or `y`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/m_min/ - - /influxdb/v2.0/reference/flux/stdlib/math/m_min/ - - /influxdb/v2.0/reference/flux/stdlib/math/mmin/ - - /influxdb/cloud/reference/flux/stdlib/math/mmin/ +description: > + `math.mMin()` is a function taht returns the lessser of `x` or `y`. menu: flux_0_x_ref: name: math.mMin parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/mMin +weight: 101 --- -The `math.mMin()` function returns the smaller of `x` or `y`. + + +`math.mMin()` is a function taht returns the lessser of `x` or `y`. + + + +##### Function type signature + +```js +(x: float, y: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +x-value to use in the operation. + + + +### y +({{< req >}}) +y-value to use in the operation. + + + + +## Examples + +- [Return the lesser of two values](#return-the-lesser-of-two-values) +- [Use math.mMin in map](#use-mathmmin-in-map) + +### Return the lesser of two values ```js import "math" -math.mMin(x: 1.23, y: 4.56) +math.mMin(x: 1.23, y: 4.56)// 1.23 -// Returns 1.23 ``` -## Parameters -### x {data-type="float"} -The X value used in the operation. +### Use math.mMin in map -### y {data-type="float"} -The Y value used in the operation. - -## Special cases ```js -math.mMin(x:x, y: -Inf) // Returns -Inf -math.mMin(x: -Inf, y:y) // Returns -Inf -math.mMin(x:x, y: NaN) // Returns NaN -math.mMin(x: NaN, y:y) // Returns NaN -math.mMin(x: -0, y: ±0) // Returns -0 -math.mMin(x: ±0, y: -0) // Returns -0 +import "math" + +data + |> map(fn: (r) => ({_time: r._time, _value: math.mMin(x: r.t1, y: r.t2)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | t1 | t2 | +| -------------------- | ----- | ----- | +| 2021-01-01T00:00:00Z | -2.18 | 19.85 | +| 2021-01-01T00:00:10Z | 10.92 | 4.97 | +| 2021-01-01T00:00:20Z | 7.35 | -3.75 | +| 2021-01-01T00:00:30Z | 17.53 | 19.77 | +| 2021-01-01T00:00:40Z | 15.23 | 13.86 | +| 2021-01-01T00:00:50Z | 4.43 | 1.86 | + + +#### Output data + +| _time | _value | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | -2.18 | +| 2021-01-01T00:00:10Z | 4.97 | +| 2021-01-01T00:00:20Z | -3.75 | +| 2021-01-01T00:00:30Z | 17.53 | +| 2021-01-01T00:00:40Z | 13.86 | +| 2021-01-01T00:00:50Z | 1.86 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/mod.md b/content/flux/v0.x/stdlib/math/mod.md index 80a0baedd..24bdd0a39 100644 --- a/content/flux/v0.x/stdlib/math/mod.md +++ b/content/flux/v0.x/stdlib/math/mod.md @@ -1,46 +1,111 @@ --- title: math.mod() function description: > - The math.mod() function returns the floating-point remainder of `x`/`y`. - The magnitude of the result is less than `y` and its sign agrees with that of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/mod/ - - /influxdb/v2.0/reference/flux/stdlib/math/mod/ - - /influxdb/cloud/reference/flux/stdlib/math/mod/ + `math.mod()` returns a floating-point remainder of `x/y`. menu: flux_0_x_ref: name: math.mod parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/mod +weight: 101 --- -The `math.mod()` function returns the floating-point remainder of `x`/`y`. -The magnitude of the result is less than `y` and its sign agrees with that of `x`. + + +`math.mod()` returns a floating-point remainder of `x/y`. + +The magnitude of the result is less than `y` and its sign agrees +with that of `x`. + +**Note**: `math.mod()` performs the same operation as the modulo operator (`%`). +For example: `4.56 % 1.23` + +##### Function type signature + +```js +(x: float, y: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +x-value to use in the operation. + + + +### y +({{< req >}}) +y-value to use in the operation. + + + + +## Examples + +- [Return the modulo of two values](#return-the-modulo-of-two-values) +- [Use math.mod in map](#use-mathmod-in-map) + +### Return the modulo of two values ```js import "math" -math.mod(x: 1.23, y: 4.56) +math.mod(x: 4.56, y: 1.23)// 0.8699999999999997 -// Returns 1.23 ``` -## Parameters -### x {data-type="float"} -The X value used in the operation. +### Use math.mod in map -### y {data-type="float"} -The Y value used in the operation. - -## Special cases ```js -math.mod(x: ±Inf, y:y) // Returns NaN -math.mod(x: NaN, y:y) // Returns NaN -math.mod(x:x, y: 0) // Returns NaN -math.mod(x:x, y: ±Inf) // Returns x -math.mod(x:x, y: NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({_time: r._time, _value: math.mod(x: r.t1, y: r.t2)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | t1 | t2 | +| -------------------- | ----- | ----- | +| 2021-01-01T00:00:00Z | -2.18 | 19.85 | +| 2021-01-01T00:00:10Z | 10.92 | 4.97 | +| 2021-01-01T00:00:20Z | 7.35 | -3.75 | +| 2021-01-01T00:00:30Z | 17.53 | 19.77 | +| 2021-01-01T00:00:40Z | 15.23 | 13.86 | +| 2021-01-01T00:00:50Z | 4.43 | 1.86 | + + +#### Output data + +| _time | _value | +| -------------------- | ------------------ | +| 2021-01-01T00:00:00Z | -2.18 | +| 2021-01-01T00:00:10Z | 0.9800000000000004 | +| 2021-01-01T00:00:20Z | 3.5999999999999996 | +| 2021-01-01T00:00:30Z | 17.53 | +| 2021-01-01T00:00:40Z | 1.370000000000001 | +| 2021-01-01T00:00:50Z | 0.7099999999999995 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/modf.md b/content/flux/v0.x/stdlib/math/modf.md index f1a3afebe..9a1cc1e5f 100644 --- a/content/flux/v0.x/stdlib/math/modf.md +++ b/content/flux/v0.x/stdlib/math/modf.md @@ -1,40 +1,123 @@ --- title: math.modf() function description: > - The math.modf() function returns integer and fractional floating-point numbers that sum to `f`. - Both values have the same sign as `f`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/modf/ - - /influxdb/v2.0/reference/flux/stdlib/math/modf/ - - /influxdb/cloud/reference/flux/stdlib/math/modf/ + `math.modf()` returns integer and fractional floating-point numbers that sum to `f`. menu: flux_0_x_ref: name: math.modf parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/modf +weight: 101 --- -The `math.modf()` function returns integer and fractional floating-point numbers that sum to `f`. + + +`math.modf()` returns integer and fractional floating-point numbers that sum to `f`. + Both values have the same sign as `f`. -_**Output data format:** Record_ +##### Function type signature + +```js +(f: float) => {int: float, frac: float} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### f +({{< req >}}) +Value to operate on + + + + +## Examples + +- [Return the integer and float that sum to a value](#return-the-integer-and-float-that-sum-to-a-value) +- [Use math.modf in map](#use-mathmodf-in-map) + +### Return the integer and float that sum to a value ```js import "math" -math.modf(f: 3.14) +math.modf(f: 3.14)// {frac: 0.14000000000000012, int: 3} -// Returns {int: 3, frac: 0.14000000000000012} ``` -## Parameters -### f {data-type="float"} -The value used in the operation. +### Use math.modf in map -## Special cases ```js -math.modf(f: ±Inf) // Returns {int: ±Inf, frac: NaN} -math.modf(f: NaN) // Returns {int: NaN, frac: NaN} +import "math" +import "sampledata" + +sampledata.float() + |> map( + fn: (r) => { + result = math.modf(f: r._value) + + return {_time: r._time, int: result.int, frac: result.frac} + }, + ) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | frac | int | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.18000000000000016 | -2 | +| 2021-01-01T00:00:10Z | 0.9199999999999999 | 10 | +| 2021-01-01T00:00:20Z | 0.34999999999999964 | 7 | +| 2021-01-01T00:00:30Z | 0.5300000000000011 | 17 | +| 2021-01-01T00:00:40Z | 0.23000000000000043 | 15 | +| 2021-01-01T00:00:50Z | 0.4299999999999997 | 4 | +| 2021-01-01T00:00:00Z | 0.8500000000000014 | 19 | +| 2021-01-01T00:00:10Z | 0.9699999999999998 | 4 | +| 2021-01-01T00:00:20Z | -0.75 | -3 | +| 2021-01-01T00:00:30Z | 0.7699999999999996 | 19 | +| 2021-01-01T00:00:40Z | 0.8599999999999994 | 13 | +| 2021-01-01T00:00:50Z | 0.8600000000000001 | 1 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/nan.md b/content/flux/v0.x/stdlib/math/nan.md index a0e935cf2..8df5704db 100644 --- a/content/flux/v0.x/stdlib/math/nan.md +++ b/content/flux/v0.x/stdlib/math/nan.md @@ -1,24 +1,51 @@ --- title: math.NaN() function -description: The math.NaN() function returns an IEEE 754 “not-a-number” value. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/nan/ - - /influxdb/v2.0/reference/flux/stdlib/math/nan/ - - /influxdb/cloud/reference/flux/stdlib/math/nan/ +description: > + `math.NaN()` returns a IEEE 754 "not-a-number" value. menu: flux_0_x_ref: name: math.NaN parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/NaN +weight: 101 --- -The `math.NaN()` function returns an IEEE 754 “not-a-number” value. + + +`math.NaN()` returns a IEEE 754 "not-a-number" value. + + + +##### Function type signature + +```js +() => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + + +## Examples + +### Return a NaN value ```js import "math" math.NaN() - -// Returns NaN ``` + diff --git a/content/flux/v0.x/stdlib/math/nextafter.md b/content/flux/v0.x/stdlib/math/nextafter.md index 1ba5e31fb..8a8591aef 100644 --- a/content/flux/v0.x/stdlib/math/nextafter.md +++ b/content/flux/v0.x/stdlib/math/nextafter.md @@ -1,41 +1,107 @@ --- title: math.nextafter() function -description: The math.nextafter() function returns the next representable float value after `x` towards `y`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/nextafter/ - - /influxdb/v2.0/reference/flux/stdlib/math/nextafter/ - - /influxdb/cloud/reference/flux/stdlib/math/nextafter/ +description: > + `math.nextafter()` returns the next representable float value after `x` towards `y`. menu: flux_0_x_ref: name: math.nextafter parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/nextafter +weight: 101 --- -The `math.nextafter()` function returns the next representable float value after `x` towards `y`. + + +`math.nextafter()` returns the next representable float value after `x` towards `y`. + + + +##### Function type signature + +```js +(x: float, y: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +x-value to use in the operation. + + + +### y +({{< req >}}) +y-value to use in the operation. + + + + +## Examples + +- [Return the next possible float value](#return-the-next-possible-float-value) +- [Use math.nextafter in map](#use-mathnextafter-in-map) + +### Return the next possible float value ```js import "math" -math.nextafter(x: 1.23, y: 4.56) +math.nextafter(x: 1.23, y: 4.56)// 1.2300000000000002 -// Returns 1.2300000000000002 ``` -## Parameters -### x {data-type="float"} -The X value used in the operation. +### Use math.nextafter in map -### y {data-type="float"} -The Y value used in the operation. - -## Special cases ```js -math.nextafter(x:x, y:x) // Returns x -math.nextafter(x: NaN, y:y) // Returns NaN -math.nextafter(x:x, y:NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({_time: r._time, _value: math.nextafter(x: r.t1, y: r.t2)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | t1 | t2 | +| -------------------- | ----- | ----- | +| 2021-01-01T00:00:00Z | -2.18 | 19.85 | +| 2021-01-01T00:00:10Z | 10.92 | 4.97 | +| 2021-01-01T00:00:20Z | 7.35 | -3.75 | +| 2021-01-01T00:00:30Z | 17.53 | 19.77 | +| 2021-01-01T00:00:40Z | 15.23 | 13.86 | +| 2021-01-01T00:00:50Z | 4.43 | 1.86 | + + +#### Output data + +| _time | _value | +| -------------------- | ------------------- | +| 2021-01-01T00:00:00Z | -2.1799999999999997 | +| 2021-01-01T00:00:10Z | 10.919999999999998 | +| 2021-01-01T00:00:20Z | 7.349999999999999 | +| 2021-01-01T00:00:30Z | 17.530000000000005 | +| 2021-01-01T00:00:40Z | 15.229999999999999 | +| 2021-01-01T00:00:50Z | 4.429999999999999 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/pow.md b/content/flux/v0.x/stdlib/math/pow.md index e914dd4fd..de1aca9e4 100644 --- a/content/flux/v0.x/stdlib/math/pow.md +++ b/content/flux/v0.x/stdlib/math/pow.md @@ -1,59 +1,107 @@ --- title: math.pow() function -description: The math.pow() function returns `x**y`, the base-x exponential of y. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/pow/ - - /influxdb/v2.0/reference/flux/stdlib/math/pow/ - - /influxdb/cloud/reference/flux/stdlib/math/pow/ +description: > + `math.pow()` returns `x**y`, the base-x exponential of `y`. menu: flux_0_x_ref: name: math.pow parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/pow +weight: 101 --- -The `math.pow()` function returns `x**y`, the base-x exponential of y. + + +`math.pow()` returns `x**y`, the base-x exponential of `y`. + + + +##### Function type signature + +```js +(x: float, y: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Base value to operate on. + + + +### y +({{< req >}}) +Exponent value. + + + + +## Examples + +- [Return the base-x exponential of a value](#return-the-base-x-exponential-of-a-value) +- [Use math.pow in map](#use-mathpow-in-map) + +### Return the base-x exponential of a value ```js import "math" -math.pow(x: 2.0, y: 3.0) +math.pow(x: 2.0, y: 3.0)// 8.0 -// Returns 8.0 ``` -## Parameters -### x {data-type="float"} -The X value used in the operation. +### Use math.pow in map -### y {data-type="float"} -The Y value used in the operation. - -## Special cases ```js -// In order of priority -math.pow(x:x, y:±0) // Returns 1 for any x -math.pow(x:1, y:y) // Returns 1 for any y -math.pow(x:X, y:1) // Returns x for any x -math.pow(x:NaN, y:y) // Returns NaN -math.pow(x:x, y:NaN) // Returns NaN -math.pow(x:±0, y:y) // Returns ±Inf for y an odd integer < 0 -math.pow(x:±0, y:-Inf) // Returns +Inf -math.pow(x:±0, y:+Inf) // Returns +0 -math.pow(x:±0, y:y) // Returns +Inf for finite y < 0 and not an odd integer -math.pow(x:±0, y:y) // Returns ±0 for y an odd integer > 0 -math.pow(x:±0, y:y) // Returns +0 for finite y > 0 and not an odd integer -math.pow(x:-1, y:±Inf) // Returns 1 -math.pow(x:x, y:+Inf) // Returns +Inf for |x| > 1 -math.pow(x:x, y:-Inf) // Returns +0 for |x| > 1 -math.pow(x:x, y:+Inf) // Returns +0 for |x| < 1 -math.pow(x:x, y:-Inf) // Returns +Inf for |x| < 1 -math.pow(x:+Inf, y:y) // Returns +Inf for y > 0 -math.pow(x:+Inf, y:y) // Returns +0 for y < 0 -math.pow(x:-Inf, y:y) // Returns math.pow(-0, -y) -math.pow(x:x, y:y) // Returns NaN for finite x < 0 and finite non-integer y +import "math" + +data + |> map(fn: (r) => ({_time: r._time, _value: math.pow(x: r.t1, y: r.t2)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | t1 | t2 | +| -------------------- | ----- | ----- | +| 2021-01-01T00:00:00Z | -2.18 | 19.85 | +| 2021-01-01T00:00:10Z | 10.92 | 4.97 | +| 2021-01-01T00:00:20Z | 7.35 | -3.75 | +| 2021-01-01T00:00:30Z | 17.53 | 19.77 | +| 2021-01-01T00:00:40Z | 15.23 | 13.86 | +| 2021-01-01T00:00:50Z | 4.43 | 1.86 | + + +#### Output data + +| _time | _value | +| -------------------- | ------------------------- | +| 2021-01-01T00:00:00Z | NaN | +| 2021-01-01T00:00:10Z | 144532.83209763622 | +| 2021-01-01T00:00:20Z | 0.0005641862251143407 | +| 2021-01-01T00:00:30Z | 3886587782891166000000000 | +| 2021-01-01T00:00:40Z | 24672926229934220 | +| 2021-01-01T00:00:50Z | 15.933490684011332 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/pow10.md b/content/flux/v0.x/stdlib/math/pow10.md index f24570ffb..66cd11525 100644 --- a/content/flux/v0.x/stdlib/math/pow10.md +++ b/content/flux/v0.x/stdlib/math/pow10.md @@ -1,37 +1,120 @@ --- title: math.pow10() function -description: The math.pow10() function returns `10**n`, the base-10 exponential of `n`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/pow10/ - - /influxdb/v2.0/reference/flux/stdlib/math/pow10/ - - /influxdb/cloud/reference/flux/stdlib/math/pow10/ +description: > + `math.pow10()` returns 10**n, the base-10 exponential of `n`. menu: flux_0_x_ref: name: math.pow10 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/pow10 +weight: 101 --- -The `math.pow10()` function returns `10**n`, the base-10 exponential of `n`. + + +`math.pow10()` returns 10**n, the base-10 exponential of `n`. + + + +##### Function type signature + +```js +(n: int) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### n +({{< req >}}) +Exponent value. + + + + +## Examples + +- [Return the base-10 exponential of n](#return-the-base-10-exponential-of-n) +- [Use math.pow10 in map](#use-mathpow10-in-map) + +### Return the base-10 exponential of n ```js import "math" -math.pow10(n: 3) +math.pow10(n: 3)// 1000.0 -// Returns 1000 ``` -## Parameters -### n {data-type="int"} -The value used in the operation. +### Use math.pow10 in map -## Special cases ```js -math.pow10(n: <-323) // Returns 0 -math.pow10(n: >308) // Returns +Inf +import "math" +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with _value: math.pow10(n: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | 0.01 | t1 | +| 2021-01-01T00:00:10Z | 10000000000 | t1 | +| 2021-01-01T00:00:20Z | 10000000 | t1 | +| 2021-01-01T00:00:30Z | 100000000000000000 | t1 | +| 2021-01-01T00:00:40Z | 1000000000000000 | t1 | +| 2021-01-01T00:00:50Z | 10000 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 10000000000000000000 | t2 | +| 2021-01-01T00:00:10Z | 10000 | t2 | +| 2021-01-01T00:00:20Z | 0.001 | t2 | +| 2021-01-01T00:00:30Z | 10000000000000000000 | t2 | +| 2021-01-01T00:00:40Z | 10000000000000 | t2 | +| 2021-01-01T00:00:50Z | 10 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/remainder.md b/content/flux/v0.x/stdlib/math/remainder.md index 369bef582..1344cff10 100644 --- a/content/flux/v0.x/stdlib/math/remainder.md +++ b/content/flux/v0.x/stdlib/math/remainder.md @@ -1,43 +1,107 @@ --- title: math.remainder() function -description: The math.remainder() function returns the IEEE 754 floating-point remainder of `x / y`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/remainder/ - - /influxdb/v2.0/reference/flux/stdlib/math/remainder/ - - /influxdb/cloud/reference/flux/stdlib/math/remainder/ +description: > + `math.remainder()` returns the IEEE 754 floating-point remainder of `x/y`. menu: flux_0_x_ref: name: math.remainder parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/remainder +weight: 101 --- -The `math.remainder()` function returns the IEEE 754 floating-point remainder of `x / y`. + + +`math.remainder()` returns the IEEE 754 floating-point remainder of `x/y`. + + + +##### Function type signature + +```js +(x: float, y: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Numerator to use in the operation. + + + +### y +({{< req >}}) +Denominator to use in the operation. + + + + +## Examples + +- [Return the remainder of division between two values](#return-the-remainder-of-division-between-two-values) +- [Use math.remainder in map](#use-mathremainder-in-map) + +### Return the remainder of division between two values ```js import "math" -math.remainder(x: 21.0, y: 4.0) +math.remainder(x: 21.0, y: 4.0)// 1.0 -// Returns 1.0 ``` -## Parameters -### x {data-type="float"} -The numerator used in the operation. +### Use math.remainder in map -### y {data-type="float"} -The denominator used in the operation. - -## Special cases ```js -math.remainder(x: ±Inf, y:y) // Returns NaN -math.remainder(x: NaN, y:y) // Returns NaN -math.remainder(x:x, y: 0) // Returns NaN -math.remainder(x:x, y: ±Inf) // Returns x -math.remainder(x:x, y: NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({_time: r._time, _value: math.remainder(x: r.t1, y: r.t2)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | t1 | t2 | +| -------------------- | ----- | ----- | +| 2021-01-01T00:00:00Z | -2.18 | 19.85 | +| 2021-01-01T00:00:10Z | 10.92 | 4.97 | +| 2021-01-01T00:00:20Z | 7.35 | -3.75 | +| 2021-01-01T00:00:30Z | 17.53 | 19.77 | +| 2021-01-01T00:00:40Z | 15.23 | 13.86 | +| 2021-01-01T00:00:50Z | 4.43 | 1.86 | + + +#### Output data + +| _time | _value | +| -------------------- | -------------------- | +| 2021-01-01T00:00:00Z | -2.18 | +| 2021-01-01T00:00:10Z | 0.9800000000000004 | +| 2021-01-01T00:00:20Z | -0.15000000000000036 | +| 2021-01-01T00:00:30Z | -2.2399999999999984 | +| 2021-01-01T00:00:40Z | 1.370000000000001 | +| 2021-01-01T00:00:50Z | 0.7099999999999995 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/round.md b/content/flux/v0.x/stdlib/math/round.md index 6335a7e32..037fe77ce 100644 --- a/content/flux/v0.x/stdlib/math/round.md +++ b/content/flux/v0.x/stdlib/math/round.md @@ -1,38 +1,120 @@ --- title: math.round() function -description: The math.round() function returns the nearest integer, rounding half away from zero. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/round/ - - /influxdb/v2.0/reference/flux/stdlib/math/round/ - - /influxdb/cloud/reference/flux/stdlib/math/round/ +description: > + `math.round()` returns the nearest integer, rounding half away from zero. menu: flux_0_x_ref: name: math.round parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/round +weight: 101 --- -The `math.round()` function returns the nearest integer, rounding half away from zero. + + +`math.round()` returns the nearest integer, rounding half away from zero. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Round a value to the nearest whole number](#round-a-value-to-the-nearest-whole-number) +- [Use math.round in map](#use-mathround-in-map) + +### Round a value to the nearest whole number ```js import "math" -math.round(x: 2.12) +math.round(x: 2.12)// 2.0 -// Returns 2.0 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.round in map -## Special cases ```js -math.round(x: ±0) // Returns ±0 -math.round(x: ±Inf) // Returns ±Inf -math.round(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.round(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 11 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 18 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 20 | t2 | +| 2021-01-01T00:00:10Z | 5 | t2 | +| 2021-01-01T00:00:20Z | -4 | t2 | +| 2021-01-01T00:00:30Z | 20 | t2 | +| 2021-01-01T00:00:40Z | 14 | t2 | +| 2021-01-01T00:00:50Z | 2 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/roundtoeven.md b/content/flux/v0.x/stdlib/math/roundtoeven.md index 796527faf..0b1b208b7 100644 --- a/content/flux/v0.x/stdlib/math/roundtoeven.md +++ b/content/flux/v0.x/stdlib/math/roundtoeven.md @@ -1,40 +1,123 @@ --- title: math.roundtoeven() function -description: The math.roundtoeven() function returns the nearest integer, rounding ties to even. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/roundtoeven/ - - /influxdb/v2.0/reference/flux/stdlib/math/roundtoeven/ - - /influxdb/cloud/reference/flux/stdlib/math/roundtoeven/ +description: > + `math.roundtoeven()` returns the nearest integer, rounding ties to even. menu: flux_0_x_ref: name: math.roundtoeven parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/roundtoeven +weight: 101 --- -The `math.roundtoeven()` function returns the nearest integer, rounding ties to even. + + +`math.roundtoeven()` returns the nearest integer, rounding ties to even. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Round a value to the nearest integer](#round-a-value-to-the-nearest-integer) +- [Use math.roundtoeven in map](#use-mathroundtoeven-in-map) + +### Round a value to the nearest integer ```js import "math" math.roundtoeven(x: 3.14) -// Returns 3.0 -math.roundtoeven(x: 3.5) -// Returns 4.0 +// 3.0 +math.roundtoeven(x: 3.5)// 4.0 + ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.roundtoeven in map -## Special cases ```js -math.roundtoeven(x: ±0) // Returns ±0 -math.roundtoeven(x: ±Inf) // Returns ±Inf -math.roundtoeven(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.roundtoeven(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 11 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 18 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 20 | t2 | +| 2021-01-01T00:00:10Z | 5 | t2 | +| 2021-01-01T00:00:20Z | -4 | t2 | +| 2021-01-01T00:00:30Z | 20 | t2 | +| 2021-01-01T00:00:40Z | 14 | t2 | +| 2021-01-01T00:00:50Z | 2 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/signbit.md b/content/flux/v0.x/stdlib/math/signbit.md index f54329ae0..c0ad76a9b 100644 --- a/content/flux/v0.x/stdlib/math/signbit.md +++ b/content/flux/v0.x/stdlib/math/signbit.md @@ -1,31 +1,119 @@ --- title: math.signbit() function -description: The math.signbit() function reports whether `x` is negative or negative zero. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/signbit/ - - /influxdb/v2.0/reference/flux/stdlib/math/signbit/ - - /influxdb/cloud/reference/flux/stdlib/math/signbit/ +description: > + `math.signbit()` reports whether `x` is negative or negative zero. menu: flux_0_x_ref: name: math.signbit parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/signbit +weight: 101 --- -The `math.signbit()` function reports whether `x` is negative or negative zero. + + +`math.signbit()` reports whether `x` is negative or negative zero. + + + +##### Function type signature + +```js +(x: float) => bool +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to evaluate. + + + + +## Examples + +- [Test if a value is negative](#test-if-a-value-is-negative) +- [Use math.signbit in map](#use-mathsignbit-in-map) + +### Test if a value is negative ```js import "math" -math.signbit(x: -1.2) +math.signbit(x: -1.2)// true -// Returns true ``` -## Parameters -### x {data-type="float"} -The value used in the evaluation. +### Use math.signbit in map + +```js +import "math" + +data + |> map(fn: (r) => ({r with _value: math.signbit(x: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | -0 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | -0 | +| 2021-01-01T00:00:40Z | t1 | -0 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | -0 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | -0 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | true | t1 | +| 2021-01-01T00:00:10Z | true | t1 | +| 2021-01-01T00:00:20Z | false | t1 | +| 2021-01-01T00:00:30Z | true | t1 | +| 2021-01-01T00:00:40Z | true | t1 | +| 2021-01-01T00:00:50Z | false | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | true | t2 | +| 2021-01-01T00:00:10Z | false | t2 | +| 2021-01-01T00:00:20Z | true | t2 | +| 2021-01-01T00:00:30Z | false | t2 | +| 2021-01-01T00:00:40Z | true | t2 | +| 2021-01-01T00:00:50Z | false | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/sin.md b/content/flux/v0.x/stdlib/math/sin.md index 4602a9080..001faf7f8 100644 --- a/content/flux/v0.x/stdlib/math/sin.md +++ b/content/flux/v0.x/stdlib/math/sin.md @@ -1,38 +1,120 @@ --- title: math.sin() function -description: The math.sin() function returns the sine of the radian argument `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/sin/ - - /influxdb/v2.0/reference/flux/stdlib/math/sin/ - - /influxdb/cloud/reference/flux/stdlib/math/sin/ +description: > + `math.sin()` returns the sine of the radian argument `x`. menu: flux_0_x_ref: name: math.sin parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/sin +weight: 101 --- -The `math.sin()` function returns the sine of the radian argument `x`. + + +`math.sin()` returns the sine of the radian argument `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Radian value to use in the operation. + + + + +## Examples + +- [Return the sine of a radian value](#return-the-sine-of-a-radian-value) +- [Use math.sin in map](#use-mathsin-in-map) + +### Return the sine of a radian value ```js import "math" -math.sin(x: 3.14) +math.sin(x: 3.14)// 0.0015926529164868282 -// Returns 0.0015926529164868282 ``` -## Parameters -### x {data-type="float"} -The radian value used in the operation. +### Use math.sin in map -## Special cases ```js -math.sin(x: ±0) // Returns ±0 -math.sin(x: ±Inf) // Returns NaN -math.sin(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.sin(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.8201039476213742 | t1 | +| 2021-01-01T00:00:10Z | -0.9971456224759652 | t1 | +| 2021-01-01T00:00:20Z | 0.8756667135928823 | t1 | +| 2021-01-01T00:00:30Z | -0.9686047952311415 | t1 | +| 2021-01-01T00:00:40Z | 0.4599716480084409 | t1 | +| 2021-01-01T00:00:50Z | -0.9603924882355435 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.8417108384451784 | t2 | +| 2021-01-01T00:00:10Z | -0.9670013802437661 | t2 | +| 2021-01-01T00:00:20Z | 0.5715613187423438 | t2 | +| 2021-01-01T00:00:30Z | 0.7958705732618963 | t2 | +| 2021-01-01T00:00:40Z | 0.9618345122584524 | t2 | +| 2021-01-01T00:00:50Z | 0.9584712830789142 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/sincos.md b/content/flux/v0.x/stdlib/math/sincos.md index a31bad39d..a86e2e656 100644 --- a/content/flux/v0.x/stdlib/math/sincos.md +++ b/content/flux/v0.x/stdlib/math/sincos.md @@ -1,38 +1,123 @@ --- title: math.sincos() function -description: The math.sincos() function returns the values of `math.sin(x:x)` and `math.cos(x:x)`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/sincos/ - - /influxdb/v2.0/reference/flux/stdlib/math/sincos/ - - /influxdb/cloud/reference/flux/stdlib/math/sincos/ +description: > + `math.sincos()` returns the values of `math.sin(x:x)` and `math.cos(x:x)`. menu: flux_0_x_ref: name: math.sincos parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/sincos +weight: 101 --- -The `math.sincos()` function returns the values of `math.sin(x:x)` and `math.cos(x:x)`. + + +`math.sincos()` returns the values of `math.sin(x:x)` and `math.cos(x:x)`. + + + +##### Function type signature + +```js +(x: float) => {sin: float, cos: float} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the sine and cosine of a value](#return-the-sine-and-cosine-of-a-value) +- [Use math.sincos in map](#use-mathsincos-in-map) + +### Return the sine and cosine of a value ```js import "math" -math.sincos(x: 1.23) +math.sincos(x: 1.23)// {cos: 0.3342377271245026, sin: 0.9424888019316975} -// Returns {sin: 0.9424888019316975, cos: 0.3342377271245026} ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.sincos in map -## Special cases ```js -math.sincos(x: ±0) // Returns {sin: ±0, cos: 1} -math.sincos(x: ±Inf) // Returns {sin: NaN, cos: NaN} -math.sincos(x: NaN) // Returns {sin: NaN, cos: NaN} +import "math" +import "sampledata" + +sampledata.float() + |> map( + fn: (r) => { + result = math.sincos(x: r._value) + + return {_time: r._time, tag: r._tag, sin: result.sin, cos: result.cos} + }, + ) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | cos | sin | +| -------------------- | -------------------- | ------------------- | +| 2021-01-01T00:00:00Z | -0.5722145708524368 | -0.8201039476213742 | +| 2021-01-01T00:00:10Z | -0.07550236802260023 | -0.9971456224759652 | +| 2021-01-01T00:00:20Z | 0.4829159416559379 | 0.8756667135928823 | +| 2021-01-01T00:00:30Z | 0.248605612678472 | -0.9686047952311415 | +| 2021-01-01T00:00:40Z | -0.887933602826472 | 0.4599716480084409 | +| 2021-01-01T00:00:50Z | -0.2786508003590546 | -0.9603924882355435 | +| 2021-01-01T00:00:00Z | 0.5399285734649675 | 0.8417108384451784 | +| 2021-01-01T00:00:10Z | 0.25477113377824295 | -0.9670013802437661 | +| 2021-01-01T00:00:20Z | -0.8205593573395606 | 0.5715613187423438 | +| 2021-01-01T00:00:30Z | 0.6054667873763024 | 0.7958705732618963 | +| 2021-01-01T00:00:40Z | 0.2736318165501685 | 0.9618345122584524 | +| 2021-01-01T00:00:50Z | -0.28518905924502086 | 0.9584712830789142 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/sinh.md b/content/flux/v0.x/stdlib/math/sinh.md index ba9f9d5b6..ebb54b38d 100644 --- a/content/flux/v0.x/stdlib/math/sinh.md +++ b/content/flux/v0.x/stdlib/math/sinh.md @@ -1,38 +1,120 @@ --- title: math.sinh() function -description: The math.sinh() function returns the hyperbolic sine of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/sinh/ - - /influxdb/v2.0/reference/flux/stdlib/math/sinh/ - - /influxdb/cloud/reference/flux/stdlib/math/sinh/ +description: > + `math.sinh()` returns the hyperbolic sine of `x`. menu: flux_0_x_ref: name: math.sinh parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/sinh +weight: 101 --- -The `math.sinh()` function returns the hyperbolic sine of `x`. + + +`math.sinh()` returns the hyperbolic sine of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the hyperbolic sine of a value](#return-the-hyperbolic-sine-of-a-value) +- [Use math.sinh in map](#use-mathsinh-in-map) + +### Return the hyperbolic sine of a value ```js import "math" -math.sinh(x: 1.23) +math.sinh(x: 1.23)// 1.564468479304407 -// Returns 1.564468479304407 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.sinh in map -## Special cases ```js -math.sinh(x: ±0) // Returns ±0 -math.sinh(x: ±Inf) // Returns ±Inf -math.sinh(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.sinh(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | -4.366632364040217 | t1 | +| 2021-01-01T00:00:10Z | 27635.399462538164 | t1 | +| 2021-01-01T00:00:20Z | 778.0979426223964 | t1 | +| 2021-01-01T00:00:30Z | 20518814.82310186 | t1 | +| 2021-01-01T00:00:40Z | 2057192.6487263965 | t1 | +| 2021-01-01T00:00:50Z | 41.95975121029801 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 208792776.78651446 | t2 | +| 2021-01-01T00:00:10Z | 72.00997211144241 | t2 | +| 2021-01-01T00:00:20Z | -21.248782127103386 | t2 | +| 2021-01-01T00:00:30Z | 192740025.25908726 | t2 | +| 2021-01-01T00:00:40Z | 522746.9691817887 | t2 | +| 2021-01-01T00:00:50Z | 3.134032070530569 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/sqrt.md b/content/flux/v0.x/stdlib/math/sqrt.md index 5a05cbfaf..585a61462 100644 --- a/content/flux/v0.x/stdlib/math/sqrt.md +++ b/content/flux/v0.x/stdlib/math/sqrt.md @@ -1,39 +1,120 @@ --- title: math.sqrt() function -description: The math.sqrt() function returns the square root of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/sqrt/ - - /influxdb/v2.0/reference/flux/stdlib/math/sqrt/ - - /influxdb/cloud/reference/flux/stdlib/math/sqrt/ +description: > + `math.sqrt()` returns the square root of `x`. menu: flux_0_x_ref: name: math.sqrt parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/sqrt +weight: 101 --- -The `math.sqrt()` function returns the square root of `x`. + + +`math.sqrt()` returns the square root of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the square root of a value](#return-the-square-root-of-a-value) +- [Use math.sqrt in map](#use-mathsqrt-in-map) + +### Return the square root of a value ```js import "math" -math.sqrt(x: 4.0) +math.sqrt(x: 4.0)// 2.0 -// Returns 2.0 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.sqrt in map -## Special cases ```js -math.sqrt(x: +Inf) // Returns +Inf -math.sqrt(x: ±0) // Returns ±0 -math.sqrt(x: <0) // Returns NaN -math.sqrt(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.sqrt(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | NaN | t1 | +| 2021-01-01T00:00:10Z | 3.304542328371661 | t1 | +| 2021-01-01T00:00:20Z | 2.711088342345192 | t1 | +| 2021-01-01T00:00:30Z | 4.186884283091665 | t1 | +| 2021-01-01T00:00:40Z | 3.9025632602175713 | t1 | +| 2021-01-01T00:00:50Z | 2.1047565179849186 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | 4.455333881989093 | t2 | +| 2021-01-01T00:00:10Z | 2.2293496809607953 | t2 | +| 2021-01-01T00:00:20Z | NaN | t2 | +| 2021-01-01T00:00:30Z | 4.446346815083142 | t2 | +| 2021-01-01T00:00:40Z | 3.722902093797257 | t2 | +| 2021-01-01T00:00:50Z | 1.3638181696985856 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/tan.md b/content/flux/v0.x/stdlib/math/tan.md index 202b37621..7de6b72b0 100644 --- a/content/flux/v0.x/stdlib/math/tan.md +++ b/content/flux/v0.x/stdlib/math/tan.md @@ -1,38 +1,120 @@ --- title: math.tan() function -description: The math.tan() function returns the tangent of the radian argument `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/tan/ - - /influxdb/v2.0/reference/flux/stdlib/math/tan/ - - /influxdb/cloud/reference/flux/stdlib/math/tan/ +description: > + `math.tan()` returns the tangent of the radian argument `x`. menu: flux_0_x_ref: name: math.tan parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/tan +weight: 101 --- -The `math.tan()` function returns the tangent of the radian argument `x`. + + +`math.tan()` returns the tangent of the radian argument `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the tangent of a radian value](#return-the-tangent-of-a-radian-value) +- [Use math.tan in map](#use-mathtan-in-map) + +### Return the tangent of a radian value ```js import "math" -math.tan(x: 3.14) +math.tan(x: 3.14)// -0.001592654936407223 -// Returns -0.001592654936407223 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.tan in map -## Special cases ```js -math.tan(x: ±0) // Returns ±0 -math.tan(x: ±Inf) // Returns NaN -math.tan(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.tan(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 1.4332105287001917 | t1 | +| 2021-01-01T00:00:10Z | 13.206812562189944 | t1 | +| 2021-01-01T00:00:20Z | 1.8132901361470621 | t1 | +| 2021-01-01T00:00:30Z | -3.8961501504145963 | t1 | +| 2021-01-01T00:00:40Z | -0.5180248236402568 | t1 | +| 2021-01-01T00:00:50Z | 3.446580763443108 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 1.5589299766884657 | t2 | +| 2021-01-01T00:00:10Z | -3.7955688539089367 | t2 | +| 2021-01-01T00:00:20Z | -0.6965508511114601 | t2 | +| 2021-01-01T00:00:30Z | 1.3144743689586664 | t2 | +| 2021-01-01T00:00:40Z | 3.515068256260714 | t2 | +| 2021-01-01T00:00:50Z | -3.3608276755646553 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/tanh.md b/content/flux/v0.x/stdlib/math/tanh.md index 8277a9716..9744003bd 100644 --- a/content/flux/v0.x/stdlib/math/tanh.md +++ b/content/flux/v0.x/stdlib/math/tanh.md @@ -1,38 +1,120 @@ --- title: math.tanh() function -description: The math.tanh() function returns the hyperbolic tangent of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/tanh/ - - /influxdb/v2.0/reference/flux/stdlib/math/tanh/ - - /influxdb/cloud/reference/flux/stdlib/math/tanh/ +description: > + `math.tanh()` returns the hyperbolic tangent of `x`. menu: flux_0_x_ref: name: math.tanh parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/tanh +weight: 101 --- -The `math.tanh()` function returns the hyperbolic tangent of `x`. + + +`math.tanh()` returns the hyperbolic tangent of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the hyperbolic tangent of a value](#return-the-hyperbolic-tangent-of-a-value) +- [Use math.tanh in map](#use-mathtanh-in-map) + +### Return the hyperbolic tangent of a value ```js import "math" -math.tanh(x: 1.23) +math.tanh(x: 1.23)// 0.8425793256589296 -// Returns 0.8425793256589296 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.tanh in map -## Special cases ```js -math.tanh(x: ±0) // Returns ±0 -math.tanh(x: ±Inf) // Returns ±1 -math.tanh(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.tanh(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.9747656786413226 | t1 | +| 2021-01-01T00:00:10Z | 0.9999999993453058 | t1 | +| 2021-01-01T00:00:20Z | 0.9999991741504578 | t1 | +| 2021-01-01T00:00:30Z | 0.9999999999999988 | t1 | +| 2021-01-01T00:00:40Z | 0.9999999999998819 | t1 | +| 2021-01-01T00:00:50Z | 0.9997161301684341 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t2 | +| 2021-01-01T00:00:10Z | 0.9999035900383996 | t2 | +| 2021-01-01T00:00:20Z | -0.9988944427261528 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 0.9999999999981702 | t2 | +| 2021-01-01T00:00:50Z | 0.9526788436890776 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/trunc.md b/content/flux/v0.x/stdlib/math/trunc.md index 47774bb36..d18c5efb7 100644 --- a/content/flux/v0.x/stdlib/math/trunc.md +++ b/content/flux/v0.x/stdlib/math/trunc.md @@ -1,38 +1,120 @@ --- title: math.trunc() function -description: The math.trunc() function returns the integer value of `x`. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/trunc/ - - /influxdb/v2.0/reference/flux/stdlib/math/trunc/ - - /influxdb/cloud/reference/flux/stdlib/math/trunc/ +description: > + `math.trunc()` returns the integer value of `x`. menu: flux_0_x_ref: name: math.trunc parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/trunc +weight: 101 --- -The `math.trunc()` function returns the integer value of `x`. + + +`math.trunc()` returns the integer value of `x`. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Truncate a value at the decimal](#truncate-a-value-at-the-decimal) +- [Use math.trunc in map](#use-mathtrunc-in-map) + +### Truncate a value at the decimal ```js import "math" -math.trunc(x: 3.14) +math.trunc(x: 3.14)// 3.0 -// Returns 3.0 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.trunc in map -## Special cases ```js -math.trunc(x: ±0) // Returns ±0 -math.trunc(x: ±Inf) // Returns ±Inf -math.trunc(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.trunc(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/y0.md b/content/flux/v0.x/stdlib/math/y0.md index 4f1e1e8cd..ee21b78d5 100644 --- a/content/flux/v0.x/stdlib/math/y0.md +++ b/content/flux/v0.x/stdlib/math/y0.md @@ -1,39 +1,120 @@ --- title: math.y0() function -description: The math.y0() function returns the order-zero Bessel function of the second kind. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/y0/ - - /influxdb/v2.0/reference/flux/stdlib/math/y0/ - - /influxdb/cloud/reference/flux/stdlib/math/y0/ +description: > + `math.y0()` returns the order-zero Bessel function of the second kind. menu: flux_0_x_ref: name: math.y0 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/y0 +weight: 101 --- -The `math.y0()` function returns the order-zero Bessel function of the second kind. + + +`math.y0()` returns the order-zero Bessel function of the second kind. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the order-zero Bessel function of a value](#return-the-order-zero-bessel-function-of-a-value) +- [Use math.y0 in map](#use-mathy0-in-map) + +### Return the order-zero Bessel function of a value ```js import "math" -math.y0(x: 3.14) +math.y0(x: 3.14)// 0.3289375969127807 -// Returns 0.3289375969127807 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.y0 in map -## Special cases ```js -math.y0(x: +Inf) // Returns 0 -math.y0(x: 0) // Returns -Inf -math.y0(x: <0) // Returns NaN -math.y0(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.y0(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | NaN | t1 | +| 2021-01-01T00:00:10Z | -0.15517570189175475 | t1 | +| 2021-01-01T00:00:20Z | 0.07687091351245329 | t1 | +| 2021-01-01T00:00:30Z | -0.16329326302215585 | t1 | +| 2021-01-01T00:00:40Z | 0.19531314382470338 | t1 | +| 2021-01-01T00:00:50Z | -0.17300760424559283 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 0.03710847827981653 | t2 | +| 2021-01-01T00:00:10Z | -0.3039299357361664 | t2 | +| 2021-01-01T00:00:20Z | NaN | t2 | +| 2021-01-01T00:00:30Z | 0.023033101962350977 | t2 | +| 2021-01-01T00:00:40Z | 0.10257274599514705 | t2 | +| 2021-01-01T00:00:50Z | 0.4897750655109666 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/y1.md b/content/flux/v0.x/stdlib/math/y1.md index 1af531233..6e5431fc6 100644 --- a/content/flux/v0.x/stdlib/math/y1.md +++ b/content/flux/v0.x/stdlib/math/y1.md @@ -1,39 +1,120 @@ --- title: math.y1() function -description: The math.y1() function returns the order-one Bessel function of the second kind. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/y1/ - - /influxdb/v2.0/reference/flux/stdlib/math/y1/ - - /influxdb/cloud/reference/flux/stdlib/math/y1/ +description: > + `math.y1()` returns the order-one Bessel function of the second kind. menu: flux_0_x_ref: name: math.y1 parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/y1 +weight: 101 --- -The `math.y1()` function returns the order-one Bessel function of the second kind. + + +`math.y1()` returns the order-one Bessel function of the second kind. + + + +##### Function type signature + +```js +(x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the order-one Bessel function of a value](#return-the-order-one-bessel-function-of-a-value) +- [Use math.y1 in map](#use-mathy1-in-map) + +### Return the order-one Bessel function of a value ```js import "math" -math.y1(x: 3.14) +math.y1(x: 3.14)// 0.35853138083924085 -// Returns 0.35853138083924085 ``` -## Parameters -### x {data-type="float"} -The value used in the operation. +### Use math.y1 in map -## Special cases ```js -math.y1(x: +Inf) // Returns 0 -math.y1(x: 0) // Returns -Inf -math.y1(x: <0) // Returns NaN -math.y1(x: NaN) // Returns NaN +import "math" +import "sampledata" + +sampledata.float() + |> map(fn: (r) => ({r with _value: math.y1(x: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:00Z | NaN | t1 | +| 2021-01-01T00:00:10Z | 0.17792152059156155 | t1 | +| 2021-01-01T00:00:20Z | -0.279177585983904 | t1 | +| 2021-01-01T00:00:30Z | 0.09355230538878848 | t1 | +| 2021-01-01T00:00:40Z | 0.06669358775929306 | t1 | +| 2021-01-01T00:00:50Z | 0.318734411734819 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | -0.17429072159140693 | t2 | +| 2021-01-01T00:00:10Z | 0.15797094698544048 | t2 | +| 2021-01-01T00:00:20Z | NaN | t2 | +| 2021-01-01T00:00:30Z | -0.17740857181789169 | t2 | +| 2021-01-01T00:00:40Z | -0.18452518993372807 | t2 | +| 2021-01-01T00:00:50Z | -0.18788912184316153 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/math/yn.md b/content/flux/v0.x/stdlib/math/yn.md index 9e8dde8de..13b7e7e5f 100644 --- a/content/flux/v0.x/stdlib/math/yn.md +++ b/content/flux/v0.x/stdlib/math/yn.md @@ -1,43 +1,105 @@ --- title: math.yn() function -description: The math.yn() function returns the order-n Bessel function of the second kind. -aliases: - - /influxdb/v2.0/reference/flux/functions/math/yn/ - - /influxdb/v2.0/reference/flux/stdlib/math/yn/ - - /influxdb/cloud/reference/flux/stdlib/math/yn/ +description: > + `math.yn()` returns the order-n Bessel function of the second kind. menu: flux_0_x_ref: name: math.yn parent: math -weight: 301 -introduced: 0.22.0 + identifier: math/yn +weight: 101 --- -The `math.yn()` function returns the order-n Bessel function of the second kind. + + +`math.yn()` returns the order-n Bessel function of the second kind. + + + +##### Function type signature + +```js +(n: int, x: float) => float +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### n +({{< req >}}) +Order number to use in the operation. + + + +### x +({{< req >}}) +Value to operate on. + + + + +## Examples + +- [Return the order-n Bessel function of a value](#return-the-order-n-bessel-function-of-a-value) +- [Use math.yn in map](#use-mathyn-in-map) + +### Return the order-n Bessel function of a value ```js import "math" -math.yn(n: 3, x: 3.14) +math.yn(n: 3, x: 3.14)// -0.4866506930335083 -// Returns -0.4866506930335083 ``` -## Parameters -### n {data-type="int"} -The order number used in the operation. +### Use math.yn in map -### x {data-type="float"} -The value used in the operation. - -## Special cases ```js -math.yn(n:n, x: +Inf) // Returns 0 -math.yn(n: ≥0, x: 0) // Returns -Inf -math.yn(n: <0, x: 0) // Returns +Inf if n is odd, -Inf if n is even -math.yn(n:n, x: <0) // Returns NaN -math.yn(n:n, x:NaN) // Returns NaN +import "math" + +data + |> map(fn: (r) => ({_time: r._time, _value: math.yn(n: r.n, x: r.x)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | x | n | +| -------------------- | --- | -- | +| 2021-01-01T00:00:00Z | 1.2 | 3 | +| 2021-01-01T01:00:00Z | 2.4 | 4 | +| 2021-01-01T02:00:00Z | 3.6 | 5 | +| 2021-01-01T03:00:00Z | 4.8 | 6 | +| 2021-01-01T04:00:00Z | 5.1 | 7 | + + +#### Output data + +| _time | _value | +| -------------------- | ------------------- | +| 2021-01-01T00:00:00Z | -3.589899629613186 | +| 2021-01-01T01:00:00Z | -1.6023565737844263 | +| 2021-01-01T02:00:00Z | -1.0581497196727103 | +| 2021-01-01T03:00:00Z | -0.8050704522628885 | +| 2021-01-01T04:00:00Z | -1.1643613692219157 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/pagerduty/_index.md b/content/flux/v0.x/stdlib/pagerduty/_index.md index f424d6891..ecb45b86b 100644 --- a/content/flux/v0.x/stdlib/pagerduty/_index.md +++ b/content/flux/v0.x/stdlib/pagerduty/_index.md @@ -1,43 +1,56 @@ --- -title: Flux pagerduty package -list_title: pagerduty package +title: pagerduty package description: > - The Flux `pagerduty` package provides functions for sending data to - [PagerDuty](https://www.pagerduty.com/). - Import the `pagerduty` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/pagerduty/ - - /influxdb/v2.0/reference/flux/stdlib/pagerduty/ - - /influxdb/cloud/reference/flux/stdlib/pagerduty/ + The `pagerduty` package provides functions for sending data to PagerDuty. menu: flux_0_x_ref: - name: pagerduty - parent: Standard library + name: pagerduty + parent: stdlib + identifier: pagerduty weight: 11 -flux/v0.x/tags: [functions, pagerduty, package] -introduced: 0.43.0 +cascade: + + introduced: 0.43.0 --- -The Flux `pagerduty` package provides functions for sending data to -[PagerDuty](https://www.pagerduty.com/). + + +The `pagerduty` package provides functions for sending data to PagerDuty. Import the `pagerduty` package: ```js import "pagerduty" ``` + + ## Options -The `pagerduty` package provides the following options: ```js -import "pagerduty" - option pagerduty.defaultURL = "https://events.pagerduty.com/v2/enqueue" ``` + +### defaultURL + +`defaultURL` is the default PagerDuty URL used by functions in the `pagerduty` package. + + -### defaultURL {data-type="string"} -Default PagerDuty events API URL. -Default is `https://events.pagerduty.com/v2/enqueue`. ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/pagerduty/actionfromlevel.md b/content/flux/v0.x/stdlib/pagerduty/actionfromlevel.md new file mode 100644 index 000000000..ff4d1ecff --- /dev/null +++ b/content/flux/v0.x/stdlib/pagerduty/actionfromlevel.md @@ -0,0 +1,61 @@ +--- +title: pagerduty.actionFromLevel() function +description: > + `pagerduty.actionFromLevel()` converts a monitoring level to a PagerDuty action. +menu: + flux_0_x_ref: + name: pagerduty.actionFromLevel + parent: pagerduty + identifier: pagerduty/actionFromLevel +weight: 101 +--- + + + +`pagerduty.actionFromLevel()` converts a monitoring level to a PagerDuty action. + +- `ok` converts to `resolve`. +- All other levels convert to `trigger`. + +##### Function type signature + +```js +(level: string) => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### level +({{< req >}}) +Monitoring level to convert to a PagerDuty action. + + + + +## Examples + +### Convert a monitoring level to a PagerDuty action + +```js +import "pagerduty" + +pagerduty.actionFromLevel(level: "crit")// Returns trigger + +``` + diff --git a/content/flux/v0.x/stdlib/pagerduty/actionfromseverity.md b/content/flux/v0.x/stdlib/pagerduty/actionfromseverity.md index a999b8bdc..79f4de279 100644 --- a/content/flux/v0.x/stdlib/pagerduty/actionfromseverity.md +++ b/content/flux/v0.x/stdlib/pagerduty/actionfromseverity.md @@ -1,32 +1,61 @@ --- title: pagerduty.actionFromSeverity() function description: > - The `pagerduty.actionFromSeverity()` function converts a severity to a PagerDuty action. -aliases: - - /influxdb/v2.0/reference/flux/functions/pagerduty/actionfromseverity/ - - /influxdb/v2.0/reference/flux/stdlib/pagerduty/actionfromseverity/ - - /influxdb/cloud/reference/flux/stdlib/pagerduty/actionfromseverity/ + `pagerduty.actionFromSeverity()` converts a severity to a PagerDuty action. menu: flux_0_x_ref: name: pagerduty.actionFromSeverity parent: pagerduty -weight: 202 -introduced: 0.43.0 + identifier: pagerduty/actionFromSeverity +weight: 101 --- -The `pagerduty.actionFromSeverity()` function converts a severity to a PagerDuty action. -`ok` converts to `resolve`. -All other severities convert to `trigger`. + + +`pagerduty.actionFromSeverity()` converts a severity to a PagerDuty action. + +- `ok` converts to `resolve`. +- All other severities convert to `trigger`. + +##### Function type signature + +```js +(severity: string) => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### severity +({{< req >}}) +Severity to convert to a PagerDuty action. + + + + +## Examples + +### Convert a severity to a PagerDuty action ```js import "pagerduty" -pagerduty.actionFromSeverity(severity: "ok") +pagerduty.actionFromSeverity(severity: "crit")// Returns trigger -// Returns "resolve" ``` -## Parameters - -### severity {data-type="float"} -The severity to convert to a PagerDuty action. diff --git a/content/flux/v0.x/stdlib/pagerduty/dedupkey.md b/content/flux/v0.x/stdlib/pagerduty/dedupkey.md index ee80c2151..d2903fa9a 100644 --- a/content/flux/v0.x/stdlib/pagerduty/dedupkey.md +++ b/content/flux/v0.x/stdlib/pagerduty/dedupkey.md @@ -1,52 +1,120 @@ --- title: pagerduty.dedupKey() function description: > - The `pagerduty.dedupKey()` function uses the group key of an input table to - generate and store a deduplication key in the `_pagerdutyDedupKey` column. -aliases: - - /influxdb/v2.0/reference/flux/functions/pagerduty/dedupkey/ - - /influxdb/v2.0/reference/flux/stdlib/pagerduty/dedupkey/ - - /influxdb/cloud/reference/flux/stdlib/pagerduty/dedupkey/ + `pagerduty.dedupKey()` uses the group key of an input table to generate and store a + deduplication key in the `_pagerdutyDedupKey`column. + The function sorts, newline-concatenates, SHA256-hashes, and hex-encodes the + group key to create a unique deduplication key for each input table. menu: flux_0_x_ref: name: pagerduty.dedupKey parent: pagerduty -weight: 202 -introduced: 0.43.0 + identifier: pagerduty/dedupKey +weight: 101 --- -The `pagerduty.dedupKey()` function uses the group key of an input table to -generate and store a deduplication key in the `_pagerdutyDedupKey` column. -The function sorts, newline-concatenates, SHA256-hashes, and hex-encodes -the group key to create a unique deduplication key for each input table. + + +`pagerduty.dedupKey()` uses the group key of an input table to generate and store a +deduplication key in the `_pagerdutyDedupKey`column. +The function sorts, newline-concatenates, SHA256-hashes, and hex-encodes the +group key to create a unique deduplication key for each input table. + + + +##### Function type signature ```js -import "pagerduty" - -pagerduty.dedupKey( - exclude: ["_start", "_stop", "_level"], -) +(<-tables: stream[A], ?exclude: [string]) => stream[{A with _pagerdutyDedupKey: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### exclude {data-type="array of strings"} +### exclude + Group key columns to exclude when generating the deduplication key. -Default is `["_start", "_stop", "_level"]`. +Default is ["_start", "_stop", "_level"]. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -##### Add a PagerDuty deduplication key to output data +### Add a PagerDuty deduplication key to output data + ```js import "pagerduty" +import "sampledata" -from(bucket: "default") - |> range(start: -5m) - |> filter(fn: (r) => r._measurement == "mem") +sampledata.int() |> pagerduty.dedupKey() ``` -{{% expand "View function updates" %}} -#### v1.18.0 -- Add `exclude` parameter to exclude group key columns when generating the deduplication key. +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | _pagerdutyDedupKey | +| -------------------- | ------- | ---- | ---------------------------------------------------------------- | +| 2021-01-01T00:00:00Z | -2 | t1 | 18fae60f7253ebb11c5cc79e69037f0320fec216b1be0c101a5575086a3ebd08 | +| 2021-01-01T00:00:10Z | 10 | t1 | 18fae60f7253ebb11c5cc79e69037f0320fec216b1be0c101a5575086a3ebd08 | +| 2021-01-01T00:00:20Z | 7 | t1 | 18fae60f7253ebb11c5cc79e69037f0320fec216b1be0c101a5575086a3ebd08 | +| 2021-01-01T00:00:30Z | 17 | t1 | 18fae60f7253ebb11c5cc79e69037f0320fec216b1be0c101a5575086a3ebd08 | +| 2021-01-01T00:00:40Z | 15 | t1 | 18fae60f7253ebb11c5cc79e69037f0320fec216b1be0c101a5575086a3ebd08 | +| 2021-01-01T00:00:50Z | 4 | t1 | 18fae60f7253ebb11c5cc79e69037f0320fec216b1be0c101a5575086a3ebd08 | + +| _time | _value | *tag | _pagerdutyDedupKey | +| -------------------- | ------- | ---- | ---------------------------------------------------------------- | +| 2021-01-01T00:00:00Z | 19 | t2 | e137b67e3ecac75539ab3f0c139e421433c389c7a9932a878aff5405712dc384 | +| 2021-01-01T00:00:10Z | 4 | t2 | e137b67e3ecac75539ab3f0c139e421433c389c7a9932a878aff5405712dc384 | +| 2021-01-01T00:00:20Z | -3 | t2 | e137b67e3ecac75539ab3f0c139e421433c389c7a9932a878aff5405712dc384 | +| 2021-01-01T00:00:30Z | 19 | t2 | e137b67e3ecac75539ab3f0c139e421433c389c7a9932a878aff5405712dc384 | +| 2021-01-01T00:00:40Z | 13 | t2 | e137b67e3ecac75539ab3f0c139e421433c389c7a9932a878aff5405712dc384 | +| 2021-01-01T00:00:50Z | 1 | t2 | e137b67e3ecac75539ab3f0c139e421433c389c7a9932a878aff5405712dc384 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/pagerduty/endpoint.md b/content/flux/v0.x/stdlib/pagerduty/endpoint.md index 53545cffa..84d4c36bf 100644 --- a/content/flux/v0.x/stdlib/pagerduty/endpoint.md +++ b/content/flux/v0.x/stdlib/pagerduty/endpoint.md @@ -1,102 +1,66 @@ --- title: pagerduty.endpoint() function description: > - The `pagerduty.endpoint()` function sends a message to PagerDuty that includes output data. -aliases: - - /influxdb/v2.0/reference/flux/functions/pagerduty/endpoint/ - - /influxdb/v2.0/reference/flux/stdlib/pagerduty/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/pagerduty/endpoint/ + `pagerduty.endpoint()` returns a function that sends a message to PagerDuty that includes output data. menu: flux_0_x_ref: name: pagerduty.endpoint parent: pagerduty -weight: 202 -flux/v0.x/tags: [notification endpoints] -introduced: 0.43.0 + identifier: pagerduty/endpoint +weight: 101 --- -The `pagerduty.endpoint()` function returns a function that can be used to send -a message to PagerDuty that includes output data. + + +`pagerduty.endpoint()` returns a function that sends a message to PagerDuty that includes output data. + + + +##### Function type signature ```js -import "pagerduty" - -pagerduty.endpoint( - url: "https://events.pagerduty.com/v2/enqueue" -) +( + ?url: string, +) => ( + mapFn: ( + r: {A with _pagerdutyDedupKey: string}, + ) => { + B with + timestamp: t11, + summary: t10, + source: J, + severity: I, + routingKey: H, + group: G, + eventAction: F, + clientURL: E, + client: D, + class: C, + }, +) => (<-tables: stream[A]) => stream[{A with _status: string, _sent: string, _pagerdutyDedupKey: string}] ``` -## Output data -For each input row, `pagerduty.endpoint()` sends an event to the PagerDuty API -and outputs a corresponding output row with the following additional columns: - -- **sent**: Sent succesfully _(bool)_ -- **\_status**: HTTP response status code _(string)_ +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### url {data-type="string"} +### url + PagerDuty v2 Events API URL. + Default is `https://events.pagerduty.com/v2/enqueue`. -## Usage -`pagerduty.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. -See the [PagerDuty v2 Events API documentation](https://developer.pagerduty.com/api-reference/reference/events-v2/openapiv3.json) -for more information about these parameters. - -### mapFn {data-type="function"} -({{< req >}}) A function that builds the record used to generate the POST request. -Requires an `r` parameter. - -`mapFn` accepts a table row (`r`) and returns a record that must include the following fields: - -- `routingKey` -- `client` -- `client_url` -- `class` -- `eventAction` -- `group` -- `severity` -- `component` -- `source` -- `summary` -- `component` -- `timestamp` -- `customDetails` - -_For more information, see [`pagerduty.sendEvent()`](/flux/v0.x/stdlib/pagerduty/sendevent/)_ - -## Examples - -##### Send critical statuses to a PagerDuty endpoint -```js -import "pagerduty" -import "influxdata/influxdb/secrets" - -routingKey = secrets.get(key: "PAGERDUTY_ROUTING_KEY") -toPagerDuty = pagerduty.endpoint() - -crit_statuses = from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and r.status == "crit") - -crit_statuses - |> toPagerDuty( - mapFn: (r) => ({r with - routingKey: routingKey, - client: r.client, - clientURL: r.clientURL, - class: r.class, - eventAction: r.eventAction, - group: r.group, - severity: r.severity, - component: r.component, - source: r.source, - summary: r.summary, - component: r.component, - timestamp: r._time, - customDetails: {"ping time": lastReported.ping, load: lastReported.load}, - }), - )() -``` diff --git a/content/flux/v0.x/stdlib/pagerduty/sendevent.md b/content/flux/v0.x/stdlib/pagerduty/sendevent.md index b1edd1ea4..0ebac4a46 100644 --- a/content/flux/v0.x/stdlib/pagerduty/sendevent.md +++ b/content/flux/v0.x/stdlib/pagerduty/sendevent.md @@ -1,139 +1,181 @@ --- title: pagerduty.sendEvent() function description: > - The `pagerduty.sendEvent()` function sends an event to PagerDuty. -aliases: - - /influxdb/v2.0/reference/flux/functions/pagerduty/sendevent/ - - /influxdb/v2.0/reference/flux/stdlib/pagerduty/sendevent/ - - /influxdb/cloud/reference/flux/stdlib/pagerduty/sendevent/ + `pagerduty.sendEvent()` sends an event to PagerDuty and returns the HTTP response code of the request. menu: flux_0_x_ref: name: pagerduty.sendEvent parent: pagerduty -weight: 202 -introduced: 0.43.0 + identifier: pagerduty/sendEvent +weight: 101 +flux/v0.x/tags: [single notification] --- -The `pagerduty.sendEvent()` function sends an event to PagerDuty. + + +`pagerduty.sendEvent()` sends an event to PagerDuty and returns the HTTP response code of the request. + + + +##### Function type signature ```js -import "pagerduty" - -pagerduty.sendEvent( - pagerdutyURL: "https://events.pagerduty.com/v2/enqueue", - routingKey: "ExampleRoutingKey", - client: "ExampleClient", - clientURL: "http://examplepagerdutyclient.com", - dedupKey: "ExampleDedupKey", - class: "cpu usage", - group: "app-stack", - severity: "ok", - eventAction: "trigger", - source: "monitoringtool:vendor:region", - component: "example-component", - summary: "This is an example summary.", - timestamp: "2016-07-17T08:42:58.315+0000", - customDetails: {exampleDetail: "Details"}, -) +( + class: A, + client: B, + clientURL: C, + dedupKey: D, + eventAction: E, + group: F, + routingKey: G, + severity: H, + source: I, + summary: J, + timestamp: t10, + ?component: t11, + ?customDetails: t12, + ?pagerdutyURL: string, +) => int where t12: Equatable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### pagerdutyURL {data-type="string"} -The URL of the PagerDuty endpoint. -Defaults to `https://events.pagerduty.com/v2/enqueue`. +### pagerdutyURL -### routingKey {data-type="string"} -The routing key generated from your PagerDuty integration. +PagerDuty endpoint URL. -### client {data-type="string"} -The name of the client sending the alert. +Default is https://events.pagerduty.com/v2/enqueue. -### clientURL {data-type="string"} -The URL of the client sending the alert. +### routingKey +({{< req >}}) +Routing key generated from your PagerDuty integration. -### dedupKey {data-type="string"} -A per-alert ID that acts as deduplication key and allows you to acknowledge or -change the severity of previous messages. + + +### client +({{< req >}}) +Name of the client sending the alert. + + + +### clientURL +({{< req >}}) +URL of the client sending the alert. + + + +### dedupKey +({{< req >}}) +Per-alert ID that acts as deduplication key and allows you to +acknowledge or change the severity of previous messages. Supports a maximum of 255 characters. -{{% note %}} -When using [`pagerduty.endpoint()`](/flux/v0.x/stdlib/pagerduty/endpoint/) -to send data to PagerDuty, the function uses the [`pagerduty.dedupKey()` function](/flux/v0.x/stdlib/pagerduty/dedupkey/) to populate the `dedupKey` parameter. -{{% /note %}} -### class {data-type="string"} -The class or type of the event. + +### class +({{< req >}}) +Class or type of the event. + Classes are user-defined. For example, `ping failure` or `cpu load`. -### group {data-type="string"} -A logical grouping used by PagerDuty. +### group +({{< req >}}) +Logical grouping used by PagerDuty. + Groups are user-defined. For example, `app-stack`. -### severity {data-type="string"} -The severity of the event. - -**Valid values include:** +### severity +({{< req >}}) +Severity of the event. +Valid values: - `critical` - `error` - `warning` - `info` -### eventAction {data-type="string"} -[Event type](https://developer.pagerduty.com/docs/events-api-v1/overview/#event-types) to send to PagerDuty. - -**Valid values include:** +### eventAction +({{< req >}}) +Event type to send to PagerDuty. +Valid values: - `trigger` - `resolve` - `acknowledge` -### source {data-type="string"} -The unique location of the affected system. +### source +({{< req >}}) +Unique location of the affected system. For example, the hostname or fully qualified domain name (FQDN). -### component {data-type="string"} + + +### component + Component responsible for the event. -### summary {data-type="string"} -A brief text summary of the event used as the summaries or titles of associated alerts. + + +### summary +({{< req >}}) +Brief text summary of the event used as the summaries or titles of associated alerts. The maximum permitted length is 1024 characters. -### timestamp {data-type="string"} -The time the detected event occurred in [RFC3339nano format](https://golang.org/pkg/time/#RFC3339Nano). -### customDetails {data-type="record"} -Additional event details. + +### timestamp +({{< req >}}) +Time the detected event occurred in RFC3339nano format. + + + +### customDetails + +Record with additional details about the event. + + + ## Examples -## Send the last reported status to PagerDuty +### Send an event to PagerDuty + ```js import "pagerduty" -import "influxdata/influxdb/secrets" - -lastReported = from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses") - |> last() - |> findRecord(fn: (key) => true, idx: 0) +import "pagerduty" pagerduty.sendEvent( routingKey: "example-routing-key", - client: lastReported.client, - clientURL: lastReported.clientURL, - class: lastReported.class, - eventAction: lastReported.eventAction, - group: lastReported.group, - severity: lastReported.severity, - component: lastReported.component, - source: lastReported.source, - component: lastReported.component, - summary: lastReported.summary, - timestamp: lastReported._time, - customDetails: {"ping time": lastReported.ping, load: lastReported.load}, + client: "example-client", + clientURL: "http://example-url.com", + class: "example-class", + eventAction: "trigger", + group: "example-group", + severity: "crit", + component: "example-component", + source: "example-source", + component: "example-component", + summary: "example-summary", + timestamp: now(), + customDetails: {"example-key": "example value"}, ) -``` \ No newline at end of file +``` + diff --git a/content/flux/v0.x/stdlib/pagerduty/severityfromlevel.md b/content/flux/v0.x/stdlib/pagerduty/severityfromlevel.md index f2d14e932..471214df0 100644 --- a/content/flux/v0.x/stdlib/pagerduty/severityfromlevel.md +++ b/content/flux/v0.x/stdlib/pagerduty/severityfromlevel.md @@ -1,39 +1,65 @@ --- title: pagerduty.severityFromLevel() function description: > - The `pagerduty.severityFromLevel()` function converts an InfluxDB status level to - a PagerDuty severity. -aliases: - - /influxdb/v2.0/reference/flux/functions/pagerduty/severityfromlevel/ - - /influxdb/v2.0/reference/flux/stdlib/pagerduty/severityfromlevel/ - - /influxdb/cloud/reference/flux/stdlib/pagerduty/severityfromlevel/ + `pagerduty.severityFromLevel()` converts an InfluxDB status level to a PagerDuty severity. menu: flux_0_x_ref: name: pagerduty.severityFromLevel parent: pagerduty -weight: 202 -introduced: 0.43.0 + identifier: pagerduty/severityFromLevel +weight: 101 --- -The `pagerduty.severityFromLevel()` function converts an InfluxDB status level to -a PagerDuty severity. + + +`pagerduty.severityFromLevel()` converts an InfluxDB status level to a PagerDuty severity. + +| Status level | PagerDuty severity | +| :----------- | :----------------- | +| crit | critical | +| warn | warning | +| info | info | +| ok | info | + +##### Function type signature + +```js +(level: string) => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### level +({{< req >}}) +InfluxDB status level to convert to a PagerDuty severity. + + + + +## Examples + +### Convert a status level to a PagerDuty serverity ```js import "pagerduty" -pagerduty.severityFromLevel(level: "crit") +pagerduty.severityFromLevel(level: "crit")// Returns critical -// Returns "critical" ``` -| Status level | PagerDuty severity | -|:------------:|:------------------:| -| `crit` | `critical` | -| `warn` | `warning` | -| `info` | `info` | -| `ok` | `info` | - -## Parameters - -### level {data-type="string"} -The InfluxDB status level to convert to a PagerDuty severity. diff --git a/content/flux/v0.x/stdlib/planner/_index.md b/content/flux/v0.x/stdlib/planner/_index.md new file mode 100644 index 000000000..c87eb8351 --- /dev/null +++ b/content/flux/v0.x/stdlib/planner/_index.md @@ -0,0 +1,52 @@ +--- +title: planner package +description: > + The `planner` package provides an API for interacting with the Flux engine planner. +menu: + flux_0_x_ref: + name: planner + parent: stdlib + identifier: planner +weight: 11 +--- + + + +The `planner` package provides an API for interacting with the Flux engine planner. + + + +## Options + +```js +option planner.disableLogicalRules = [""] + +option planner.disablePhysicalRules = [""] +``` + +### disableLogicalRules + +`disableLogicalRules` is a set of logical planner rules that should NOT be applied. + + + +### disablePhysicalRules + +`disablePhysicalRules` is a set of physical planner rules that should NOT be applied. + + + diff --git a/content/flux/v0.x/stdlib/profiler/_index.md b/content/flux/v0.x/stdlib/profiler/_index.md index 73b5ae1b1..de4cb44ce 100644 --- a/content/flux/v0.x/stdlib/profiler/_index.md +++ b/content/flux/v0.x/stdlib/profiler/_index.md @@ -1,50 +1,55 @@ --- -title: Flux profiler package -list_title: profiler package +title: profiler package description: > - The Flux `profiler` package provides performance profiling tools for Flux queries and operations. - Import the `profiler` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/profiler/ - - /influxdb/cloud/reference/flux/stdlib/profiler/ + The `profiler` package provides performance profiling tools for Flux queries and operations. menu: flux_0_x_ref: - name: profiler - parent: Standard library + name: profiler + parent: stdlib + identifier: profiler weight: 11 -flux/v0.x/tags: [functions, optimize, package] -related: - - /{{< latest "influxdb" >}}/query-data/optimize-queries/ -introduced: 0.82.0 +cascade: + flux/v0.x/tags: [optimize] + introduced: 0.82.0 --- -The Flux `profiler` package provides performance profiling tools for Flux queries and operations. -Import the `profiler` package: + + +The `profiler` package provides performance profiling tools for Flux queries and operations. + +Profile results are returned as an extra result in the response named according to the profiles which are enabled. ## Options -The `profiler` package includes the following options: ```js -import "profiler" - -option profiler.enabledProfilers = ["query", "operator"] +option profiler.enabledProfilers = [""] ``` + +### enabledProfilers -### enabledProfilers {data-type="array of strings"} -List of Flux profilers to enable. +`enabledProfilers` is a list of profilers to enable during execution. ## Available profilers - [query](#query) - [operator](#operator) ### query -The `query` profiler provides statistics about the execution of an entire Flux script. -When enabled, results returned by [`yield()`](/flux/v0.x/stdlib/universe/yield/) -include a table with the following columns: +Provides statistics about the execution of an entire Flux script. +When enabled, results include a table with the following columns: - **TotalDuration**: total query duration in nanoseconds. - **CompileDuration**: number of nanoseconds spent compiling the query. @@ -62,10 +67,10 @@ include a table with the following columns: ### operator The `operator` profiler output statistics about each operation in a query. -[Operations executed in the storage tier](/influxdb/cloud/query-data/optimize-queries/#start-queries-with-pushdown-functions) +[Operations executed in the storage tier](https://docs.influxdata.com/influxdb/cloud/query-data/optimize-queries/#start-queries-with-pushdown-functions) return as a single operation. -When the `operator` profile is enabled, results returned by [`yield()`](/flux/v0.x/stdlib/universe/yield/) -include a table with a row for each operation and the following columns: +When the `operator` profile is enabled, results include a table with a row +for each operation and the following columns: - **Type:** operation type - **Label:** operation name @@ -74,3 +79,4 @@ include a table with a row for each operation and the following columns: - **MaxDuration:** maximum duration of the operation in nanoseconds - **DurationSum:** total duration of all operation executions in nanoseconds - **MeanDuration:** average duration of all operation executions in nanoseconds + diff --git a/content/flux/v0.x/stdlib/pushbullet/_index.md b/content/flux/v0.x/stdlib/pushbullet/_index.md index 7ceaa36f3..f68715054 100644 --- a/content/flux/v0.x/stdlib/pushbullet/_index.md +++ b/content/flux/v0.x/stdlib/pushbullet/_index.md @@ -1,42 +1,56 @@ --- -title: Flux pushbullet package -list_title: pushbullet package +title: pushbullet package description: > - The Flux `pushbullet` package provides functions for sending data to - [Pushbullet](https://www.pushbullet.com/). - Import the `pushbullet` package. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/pushbullet/ - - /influxdb/cloud/reference/flux/stdlib/pushbullet/ + The `pushbullet` package provides functions for sending data to Pushbullet. menu: flux_0_x_ref: - name: pushbullet - parent: Standard library + name: pushbullet + parent: stdlib + identifier: pushbullet weight: 11 -flux/v0.x/tags: [functions, pushbullet, package] -introduced: 0.66.0 +cascade: + + introduced: 0.66.0 --- -The Flux `pushbullet` package provides functions for sending data to -[Pushbullet](https://www.pushbullet.com/). + + +The `pushbullet` package provides functions for sending data to Pushbullet. Import the `pushbullet` package: ```js import "pushbullet" ``` + + ## Options -The `pushbullet` package includes the following options: ```js -import "pushbullet" - option pushbullet.defaultURL = "https://api.pushbullet.com/v2/pushes" ``` + +### defaultURL + +`defaultURL` is the default Pushbullet API URL used by functions in the `pushbullet` package. + + -### defaultURL {data-type="string"} -Default Pushbullet API URL. -Default is `https://api.pushbullet.com/v2/pushes`. ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/pushbullet/endpoint.md b/content/flux/v0.x/stdlib/pushbullet/endpoint.md index dcb4fd55c..7a6f20d10 100644 --- a/content/flux/v0.x/stdlib/pushbullet/endpoint.md +++ b/content/flux/v0.x/stdlib/pushbullet/endpoint.md @@ -1,72 +1,57 @@ --- title: pushbullet.endpoint() function description: > - The `pushbullet.endpoint()` function creates the endpoint for the Pushbullet API - and sends a notification of type `note`. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/pushbullet/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/pushbullet/endpoint/ + `pushbullet.endpoint()` creates the endpoint for the Pushbullet API and sends a notification of type note. menu: flux_0_x_ref: name: pushbullet.endpoint parent: pushbullet -weight: 202 -flux/v0.x/tags: [notification endpoints] -introduced: 0.66.0 + identifier: pushbullet/endpoint +weight: 101 --- -The `pushbullet.endpoint()` function creates the endpoint for the Pushbullet API -and sends a notification of type `note`. + + +`pushbullet.endpoint()` creates the endpoint for the Pushbullet API and sends a notification of type note. + + + +##### Function type signature ```js -import "pushbullet" - -pushbullet.endpoint( - url: "https://api.pushbullet.com/v2/pushes", - token: "", -) +( + ?token: A, + ?url: string, +) => (mapFn: (r: B) => {C with title: E, text: D}) => (<-tables: stream[B]) => stream[{B with _sent: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -Pushbullet API URL. -Defaults to `https://api.pushbullet.com/v2/pushes`. +### url -### token {data-type="string"} -[Pushbullet API token](https://get.pushbullet.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens) -to use when interacting with Pushbullet. -Defaults to `""`. +PushBullet API endpoint URL. Default is `"https://api.pushbullet.com/v2/pushes"`. -## Usage -`pushbullet.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. -### mapFn {data-type="function"} -A function that builds the record used to generate the API request. -Requires an `r` parameter. -`mapFn` accepts a table row (`r`) and returns a record that must include the -following fields (as defined in [`pushbullet.pushNote()`](/flux/v0.x/stdlib/pushbullet/pushnote/#title)): +### token -- `title` -- `text` +Pushbullet API token string. Default is `""`. -## Examples -##### Send the last reported status to Pushbullet -```js -import "pushbullet" -import "influxdata/influxdb/secrets" -token = secrets.get(key: "PUSHBULLET_TOKEN") -e = pushbullet.endpoint(token: token) - -lastReported = from(bucket: "example-bucket") - |> range(start: -10m) - |> filter(fn: (r) => r._measurement == "statuses") - |> last() - -lastReported - |> e(mapFn: (r) => ({r with title: r.title, text: "${string(v: r._time)}: ${r.status}."}))() -``` diff --git a/content/flux/v0.x/stdlib/pushbullet/pushdata.md b/content/flux/v0.x/stdlib/pushbullet/pushdata.md index c22ac7c32..1bba3da65 100644 --- a/content/flux/v0.x/stdlib/pushbullet/pushdata.md +++ b/content/flux/v0.x/stdlib/pushbullet/pushdata.md @@ -1,75 +1,80 @@ --- title: pushbullet.pushData() function description: > - The `pushbullet.pushData()` function sends a push notification to the Pushbullet API. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/pushbullet/pushdata/ - - /influxdb/cloud/reference/flux/stdlib/pushbullet/pushdata/ + `pushbullet.pushData()` sends a push notification to the Pushbullet API. menu: flux_0_x_ref: name: pushbullet.pushData parent: pushbullet -weight: 202 -introduced: 0.66.0 + identifier: pushbullet/pushData +weight: 101 +flux/v0.x/tags: [single notification] --- -The `pushbullet.pushData()` function sends a push notification to the -[Pushbullet API](https://docs.pushbullet.com/). + + +`pushbullet.pushData()` sends a push notification to the Pushbullet API. + + + +##### Function type signature ```js -import "pushbullet" - -pushbullet.pushData( - url: "https://api.pushbullet.com/v2/pushes", - token: "", - data: { - "type": "link", - "title": "This is a notification!", - "body": "This notification came from Flux.", - "url": "http://example.com" - }, - ) +(data: A, ?token: B, ?url: string) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -Pushbullet API URL. -Defaults to `https://api.pushbullet.com/v2/pushes`. +### url -### token {data-type="string"} -[Pushbullet API token](https://get.pushbullet.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens) -to use when interacting with Pushbullet. -Defaults to `""`. +URL of the PushBullet endpoint. Default is `"https://api.pushbullet.com/v2/pushes"`. -### data {data-type="record"} + + +### token + +API token string. Default is `""`. + + + +### data ({{< req >}}) -Data to send to the Pushbullet API. -The function JSON-encodes data before sending it to Pushbullet. +Data to send to the endpoint. Data is JSON-encoded and sent to the Pushbullet's endpoint. + +For how to structure data, see the [Pushbullet API documentation](https://docs.pushbullet.com/#create-push). + ## Examples -##### Send the last reported status to Pushbullet +### Send a push notification to Pushbullet + ```js import "pushbullet" -import "influxdata/influxdb/secrets" - -token = secrets.get(key: "PUSHBULLET_TOKEN") - -lastReported = from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses") - |> last() - |> tableFind(fn: (key) => true) - |> getRecord(idx: 0) pushbullet.pushData( - token: token, + token: "mY5up3Rs3Cre7T0k3n", data: { "type": "link", - "title": "Last reported status", - "body": "${lastReported._time}: ${lastReported.status}.", - "url": "${lastReported.statusURL}", - } + "title": "Example title", + "body": "Example nofication body", + "url": "http://example-url.com", + }, ) ``` + diff --git a/content/flux/v0.x/stdlib/pushbullet/pushnote.md b/content/flux/v0.x/stdlib/pushbullet/pushnote.md index 4aa1bd695..443a8f219 100644 --- a/content/flux/v0.x/stdlib/pushbullet/pushnote.md +++ b/content/flux/v0.x/stdlib/pushbullet/pushnote.md @@ -1,71 +1,81 @@ --- title: pushbullet.pushNote() function description: > - The `pushbullet.pushNote()` function sends a push notification of type `note` - to the Pushbullet API. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/pushbullet/pushnote/ - - /influxdb/cloud/reference/flux/stdlib/pushbullet/pushnote/ + `pushbullet.pushNote()` sends a push notification of type "note" to the Pushbullet API. menu: flux_0_x_ref: name: pushbullet.pushNote parent: pushbullet -weight: 202 -introduced: 0.66.0 + identifier: pushbullet/pushNote +weight: 101 +flux/v0.x/tags: [single notification] --- -The `pushbullet.pushNote()` function sends a push notification of type `note` -to the Pushbullet API. + + +`pushbullet.pushNote()` sends a push notification of type "note" to the Pushbullet API. + + + +##### Function type signature ```js -import "pushbullet" - -pushbullet.pushNote( - url: "https://api.pushbullet.com/v2/pushes", - token: "", - title: "This is a push notification!", - text: "This push notification came from Flux.", -) +(text: A, title: B, ?token: C, ?url: string) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -Pushbullet API URL. -Defaults to `https://api.pushbullet.com/v2/pushes`. +### url -### token {data-type="string"} -[Pushbullet API token](https://get.pushbullet.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens) -to use when interacting with Pushbullet. -Defaults to `""`. +URL of the PushBullet endpoint. Default is `"https://api.pushbullet.com/v2/pushes"`. -### title {data-type="string"} + + +### token + +API token string. Defaults to: `""`. + + + +### title ({{< req >}}) Title of the notification. -### text {data-type="string"} + + +### text ({{< req >}}) Text to display in the notification. + + + ## Examples -##### Send the last reported status to Pushbullet +### Send a push notification note to Pushbullet + ```js import "pushbullet" -import "influxdata/influxdb/secrets" - -token = secrets.get(key: "PUSHBULLET_TOKEN") - -lastReported = from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses") - |> last() - |> tableFind(fn: (key) => true) - |> getRecord(idx: 0) pushbullet.pushNote( - token: token, - title: "Last reported status", - text: "${lastReported._time}: ${lastReported.status}.", + token: "mY5up3Rs3Cre7T0k3n", + data: {"type": "link", "title": "Example title", "text": "Example note text"}, ) ``` + diff --git a/content/flux/v0.x/stdlib/regexp/_index.md b/content/flux/v0.x/stdlib/regexp/_index.md index 945972c88..2425c2cf3 100644 --- a/content/flux/v0.x/stdlib/regexp/_index.md +++ b/content/flux/v0.x/stdlib/regexp/_index.md @@ -1,31 +1,44 @@ --- -title: Flux regexp package -list_title: regexp package +title: regexp package description: > - The Flux `regexp` package includes functions for working with regular expressions. - Import the `regexp` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/regexp/ - - /influxdb/v2.0/reference/flux/stdlib/regexp/ - - /influxdb/cloud/reference/flux/stdlib/regexp/ + The `regexp` package provides tools for working with regular expressions. menu: flux_0_x_ref: - name: regexp - parent: Standard library + name: regexp + parent: stdlib + identifier: regexp weight: 11 -flux/v0.x/tags: [regex, functions] cascade: - related: - - /flux/v0.x/data-types/basic/regexp/ -introduced: 0.33.0 + + introduced: 0.33.0 --- -The Flux `regexp` package includes functions for working with regular expressions. -Import the `regexp` package. + + +The `regexp` package provides tools for working with regular expressions. +Import the `regexp` package: ```js import "regexp" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/regexp/compile.md b/content/flux/v0.x/stdlib/regexp/compile.md index d18ff8581..e4d92f4d5 100644 --- a/content/flux/v0.x/stdlib/regexp/compile.md +++ b/content/flux/v0.x/stdlib/regexp/compile.md @@ -1,48 +1,63 @@ --- title: regexp.compile() function description: > - The `regexp.compile()` function parses a regular expression and, if successful, - returns a Regexp object that can be used to match against text. -aliases: - - /influxdb/v2.0/reference/flux/functions/regexp/compile/ - - /influxdb/v2.0/reference/flux/stdlib/regexp/compile/ - - /influxdb/cloud/reference/flux/stdlib/regexp/compile/ + `regexp.compile()` parses a string into a regular expression and returns a regexp type + that can be used to match against strings. menu: flux_0_x_ref: name: regexp.compile parent: regexp -weight: 301 -introduced: 0.33.0 + identifier: regexp/compile +weight: 101 +flux/v0.x/tags: [type-conversions] --- -The `regexp.compile()` function parses a regular expression and, if successful, -returns a Regexp object that can be used to match against text. + + +`regexp.compile()` parses a string into a regular expression and returns a regexp type +that can be used to match against strings. + + + +##### Function type signature ```js -import "regexp" - -regexp.compile(v: "abcd") - -// Returns the regexp object `abcd` +(v: string) => regexp ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to parse into a regular expression. +### v +({{< req >}}) +String value to parse into a regular expression. + + + ## Examples -###### Use a string value as a regular expression +### Convert a string into a regular expression + ```js import "regexp" -data - |> map(fn: (r) => ({r with - regexStr: r.regexStr, - _value: r._value, - firstRegexMatch: findString(r: regexp.compile(v: regexStr), v: r._value) - })) +regexp.compile(v: "abcd")// Returns the regexp object /abcd/ + ``` + diff --git a/content/flux/v0.x/stdlib/regexp/findstring.md b/content/flux/v0.x/stdlib/regexp/findstring.md index 37679f0eb..62414413f 100644 --- a/content/flux/v0.x/stdlib/regexp/findstring.md +++ b/content/flux/v0.x/stdlib/regexp/findstring.md @@ -1,52 +1,128 @@ --- title: regexp.findString() function -description: The `regexp.findString()` function returns the left-most regular expression match in a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/regexp/findstring/ - - /influxdb/v2.0/reference/flux/stdlib/regexp/findstring/ - - /influxdb/cloud/reference/flux/stdlib/regexp/findstring/ +description: > + `regexp.findString()` returns the left-most regular expression match in a string. menu: flux_0_x_ref: name: regexp.findString parent: regexp -weight: 301 -related: - - /flux/v0.x/stdlib/regexp/splitregexp - - /flux/v0.x/data-types/basic/regexp/ -introduced: 0.33.1 + identifier: regexp/findString +weight: 101 --- -The `regexp.findString()` function returns the left-most regular expression match in a string. + + +`regexp.findString()` returns the left-most regular expression match in a string. + + + +##### Function type signature ```js -import "regexp" - -regexp.findString(r: /foo.?/, v: "seafood fool") - -// Returns "food" +(r: regexp, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### r {data-type="regexp"} -The regular expression used to search `v`. +### r +({{< req >}}) +Regular expression used to search `v`. + + + +### v +({{< req >}}) +String value to search. + + -### v {data-type="string"} -The string value to search. ## Examples -###### Find the first regular expression match in each row +- [Return the first regular expression match in a string](#return-the-first-regular-expression-match-in-a-string) +- [Find the first regular expression match in each row](#find-the-first-regular-expression-match-in-each-row) + +### Return the first regular expression match in a string + ```js import "regexp" -data - |> map(fn: (r) => ({r with - message: r.message, - regexp: r.regexp, - match: regexp.findString(r: r.regexp, v: r.message) - }) - ) +regexp.findString(r: /foo.?/, v: "seafood fool")// Returns "food" + ``` + + +### Find the first regular expression match in each row + +```js +import "regexp" +import "sampledata" + +regex = /.{6}$/ + +sampledata.string() + |> map(fn: (r) => ({r with _value: regexp.findString(v: r._value, r: regex)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | g9qczs | t1 | +| 2021-01-01T00:00:10Z | 0mgv9n | t1 | +| 2021-01-01T00:00:20Z | phw664 | t1 | +| 2021-01-01T00:00:30Z | guvzy4 | t1 | +| 2021-01-01T00:00:40Z | 5v3cce | t1 | +| 2021-01-01T00:00:50Z | s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | b5eida | t2 | +| 2021-01-01T00:00:10Z | eu4oxp | t2 | +| 2021-01-01T00:00:20Z | 5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | sox1ut | t2 | +| 2021-01-01T00:00:40Z | wfm757 | t2 | +| 2021-01-01T00:00:50Z | dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/regexp/findstringindex.md b/content/flux/v0.x/stdlib/regexp/findstringindex.md index a9be320ac..ae4546f58 100644 --- a/content/flux/v0.x/stdlib/regexp/findstringindex.md +++ b/content/flux/v0.x/stdlib/regexp/findstringindex.md @@ -1,58 +1,68 @@ --- title: regexp.findStringIndex() function description: > - The `regexp.findStringIndex()` function returns a two-element array of integers defining - the beginning and ending indexes of the left-most regular expression match in a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/regexp/findstringindex/ - - /influxdb/v2.0/reference/flux/stdlib/regexp/findstringindex/ - - /influxdb/cloud/reference/flux/stdlib/regexp/findstringindex/ + `regexp.findStringIndex()` returns a two-element array of integers that represent the + beginning and ending indexes of the first regular expression match in a string. menu: flux_0_x_ref: name: regexp.findStringIndex parent: regexp -weight: 301 -related: - - /flux/v0.x/stdlib/regexp/compile - - /flux/v0.x/data-types/basic/regexp/ -introduced: 0.33.2 + identifier: regexp/findStringIndex +weight: 101 --- -The `regexp.findStringIndex()` function returns a two-element array of integers defining -the beginning and ending indexes of the left-most regular expression match in a string. + + +`regexp.findStringIndex()` returns a two-element array of integers that represent the +beginning and ending indexes of the first regular expression match in a string. + + + +##### Function type signature ```js -import "regexp" - -regexp.findStringIndex(r: /ab?/, v: "tablet") - -// Returns [1, 3] +(r: regexp, v: string) => [int] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### r {data-type="regexp"} -The regular expression used to search `v`. +### r +({{< req >}}) +Regular expression used to search `v`. + + + +### v +({{< req >}}) +String value to search. + + -### v {data-type="string"} -The string value to search. ## Examples -###### Index the bounds of first regular expression match in each row +### Index the bounds of first regular expression match in each row + ```js import "regexp" -data - |> map(fn: (r) => ({r with - regexStr: r.regexStr, - _value: r._value, - matchIndex: regexp.findStringIndex( - r: regexp.compile(r.regexStr), - v: r._value - ) - }) - ) +regexp.findStringIndex(r: /ab?/, v: "tablet")// Returns [1, 3] + ``` + diff --git a/content/flux/v0.x/stdlib/regexp/getstring.md b/content/flux/v0.x/stdlib/regexp/getstring.md index ec671acb6..b533ed2fd 100644 --- a/content/flux/v0.x/stdlib/regexp/getstring.md +++ b/content/flux/v0.x/stdlib/regexp/getstring.md @@ -1,42 +1,48 @@ --- title: regexp.getString() function -description: The `regexp.getString()` function returns the source string used to compile a regular expression. -aliases: - - /influxdb/v2.0/reference/flux/functions/regexp/getstring/ - - /influxdb/v2.0/reference/flux/stdlib/regexp/getstring/ - - /influxdb/cloud/reference/flux/stdlib/regexp/getstring/ +description: > + `regexp.getString()` returns the source string used to compile a regular expression. menu: flux_0_x_ref: name: regexp.getString parent: regexp -weight: 301 -related: - - /flux/v0.x/stdlib/regexp/compile - - /flux/v0.x/data-types/basic/regexp/ -introduced: 0.33.3 + identifier: regexp/getString +weight: 101 --- -The `regexp.getString()` function returns the source string used to compile a regular expression. + + +`regexp.getString()` returns the source string used to compile a regular expression. + + + +##### Function type signature ```js -import "regexp" - -regexp.getString(r: /[a-zA-Z]/) - -// Returns "[a-zA-Z]" +(r: regexp) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### r {data-type="regexp"} -The regular expression object to convert to a string. +### r +({{< req >}}) +Regular expression object to convert to a string. + -## Examples -###### Convert regular expressions into strings in each row -```js -data - |> map(fn: (r) => ({r with regex: r.regex, regexStr: regexp.getString(r: r.regex)})) -``` diff --git a/content/flux/v0.x/stdlib/regexp/matchregexpstring.md b/content/flux/v0.x/stdlib/regexp/matchregexpstring.md index cb359a6df..7e0715889 100644 --- a/content/flux/v0.x/stdlib/regexp/matchregexpstring.md +++ b/content/flux/v0.x/stdlib/regexp/matchregexpstring.md @@ -1,47 +1,80 @@ --- title: regexp.matchRegexpString() function description: > - The `regexp.matchRegexpString()` function tests if a string contains any match - to a regular expression. -aliases: - - /influxdb/v2.0/reference/flux/functions/regexp/matchregexpstring/ - - /influxdb/v2.0/reference/flux/stdlib/regexp/matchregexpstring/ - - /influxdb/cloud/reference/flux/stdlib/regexp/matchregexpstring/ + `regexp.matchRegexpString()` tests if a string contains any match to a regular expression. menu: flux_0_x_ref: name: regexp.matchRegexpString parent: regexp -weight: 301 -introduced: 0.33.4 + identifier: regexp/matchRegexpString +weight: 101 --- -The `regexp.matchRegexpString()` function tests if a string contains any match -to a regular expression. + + +`regexp.matchRegexpString()` tests if a string contains any match to a regular expression. + + + +##### Function type signature ```js -import "regexp" - -regexp.matchRegexpString(r: /(gopher){2}/, v: "gophergophergopher") - -// Returns true +(r: regexp, v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### r {data-type="regexp"} -The regular expression used to search `v`. +### r +({{< req >}}) +Regular expression used to search `v`. + + + +### v +({{< req >}}) +String value to search. + + -### v {data-type="string"} -The string value to search. ## Examples -###### Filter by columns that contain matches to a regular expression +- [Test if a string contains a regular expression match](#test-if-a-string-contains-a-regular-expression-match) +- [Filter by rows that contain matches to a regular expression](#filter-by-rows-that-contain-matches-to-a-regular-expression) + +### Test if a string contains a regular expression match + ```js import "regexp" -data - |> filter(fn: (r) => regexp.matchRegexpString(r: /Alert:/, v: r.message)) +regexp.matchRegexpString(r: /(gopher){2}/, v: "gophergophergopher")// Returns true + ``` + + +### Filter by rows that contain matches to a regular expression + +```js +import "regexp" +import "sampledata" + +sampledata.string() + |> filter(fn: (r) => regexp.matchRegexpString(r: /_\d/, v: r._value)) +``` + diff --git a/content/flux/v0.x/stdlib/regexp/quotemeta.md b/content/flux/v0.x/stdlib/regexp/quotemeta.md index bde846d1a..02b8b5951 100644 --- a/content/flux/v0.x/stdlib/regexp/quotemeta.md +++ b/content/flux/v0.x/stdlib/regexp/quotemeta.md @@ -1,42 +1,60 @@ --- title: regexp.quoteMeta() function description: > - The `regexp.quoteMeta()` function escapes all regular expression metacharacters inside of a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/regexp/quotemeta/ - - /influxdb/v2.0/reference/flux/stdlib/regexp/quotemeta/ - - /influxdb/cloud/reference/flux/stdlib/regexp/quotemeta/ + `regexp.quoteMeta()` escapes all regular expression metacharacters in a string. menu: flux_0_x_ref: name: regexp.quoteMeta parent: regexp -weight: 301 -introduced: 0.33.5 + identifier: regexp/quoteMeta +weight: 101 --- -The `regexp.quoteMeta()` function escapes all regular expression metacharacters inside of a string. + + +`regexp.quoteMeta()` escapes all regular expression metacharacters in a string. + + + +##### Function type signature ```js -import "regexp" - -regexp.quoteMeta(v: ".+*?()|[]{}^$") - -// Returns "\.\+\*\?\(\)\|\[\]\{\}\^\$" +(v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string that contains regular expression metacharacters to escape. +### v +({{< req >}}) +String that contains regular expression metacharacters to escape. + + + ## Examples -###### Escape regular expression meta characters in column values +### Escape regular expression metacharacters in a string + ```js import "regexp" -data - |> map(fn: (r) => ({r with notes: r.notes, notes_escaped: regexp.quoteMeta(v: r.notes)})) +regexp.quoteMeta(v: ".+*?()|[]{}^$")// Returns "\.\+\*\?\(\)\|\[\]\{\}\^\$" + ``` + diff --git a/content/flux/v0.x/stdlib/regexp/replaceallstring.md b/content/flux/v0.x/stdlib/regexp/replaceallstring.md index 8cea33325..e93f2adad 100644 --- a/content/flux/v0.x/stdlib/regexp/replaceallstring.md +++ b/content/flux/v0.x/stdlib/regexp/replaceallstring.md @@ -1,57 +1,134 @@ --- title: regexp.replaceAllString() function description: > - The `regexp.replaceAllString()` function replaces all regular expression matches - in a string with a specified replacement. -aliases: - - /influxdb/v2.0/reference/flux/functions/regexp/replaceallstring/ - - /influxdb/v2.0/reference/flux/stdlib/regexp/replaceallstring/ - - /influxdb/cloud/reference/flux/stdlib/regexp/replaceallstring/ + `regexp.replaceAllString()` replaces all reguar expression matches in a string with a + specified replacement. menu: flux_0_x_ref: name: regexp.replaceAllString parent: regexp -weight: 301 -introduced: 0.33.6 + identifier: regexp/replaceAllString +weight: 101 --- -The `regexp.replaceAllString()` function replaces all regular expression matches -in a string with a specified replacement. + + +`regexp.replaceAllString()` replaces all reguar expression matches in a string with a +specified replacement. + + + +##### Function type signature ```js -import "regexp" - -regexp.replaceAllString(r: /a(x*)b/, v: "-ab-axxb-", t: "T") - -// Returns "-T-T-" +(r: regexp, t: string, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### r {data-type="regexp"} -The regular expression used to search `v`. +### r +({{< req >}}) +Regular expression used to search `v`. + + + +### v +({{< req >}}) +String value to search. + + + +### t +({{< req >}}) +Replacement for matches to `r`. + -### v {data-type="string"} -The string value to search. -### t {data-type="string"} -The replacement for matches to `r`. ## Examples -###### Replace regular expression matches in string column values +- [Replace regular expression matches in a string](#replace-regular-expression-matches-in-a-string) +- [Replace regular expression matches in string column values](#replace-regular-expression-matches-in-string-column-values) + +### Replace regular expression matches in a string + ```js import "regexp" -data - |> map(fn: (r) => ({r with - message: r.message, - updated_message: regexp.replaceAllString( - r: /cat|bird|ferret/, - v: r.message, - t: "dog", - ) - })) +regexp.replaceAllString(r: /a(x*)b/, v: "-ab-axxb-", t: "T")// Returns "-T-T-" + ``` + + +### Replace regular expression matches in string column values + +```js +import "regexp" +import "sampledata" + +sampledata.string() + |> map(fn: (r) => ({r with _value: regexp.replaceAllString(r: /smpl_/, v: r._value, t: "")})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | g9qczs | t1 | +| 2021-01-01T00:00:10Z | 0mgv9n | t1 | +| 2021-01-01T00:00:20Z | phw664 | t1 | +| 2021-01-01T00:00:30Z | guvzy4 | t1 | +| 2021-01-01T00:00:40Z | 5v3cce | t1 | +| 2021-01-01T00:00:50Z | s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | b5eida | t2 | +| 2021-01-01T00:00:10Z | eu4oxp | t2 | +| 2021-01-01T00:00:20Z | 5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | sox1ut | t2 | +| 2021-01-01T00:00:40Z | wfm757 | t2 | +| 2021-01-01T00:00:50Z | dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/regexp/splitregexp.md b/content/flux/v0.x/stdlib/regexp/splitregexp.md index f7e37673c..9917ec282 100644 --- a/content/flux/v0.x/stdlib/regexp/splitregexp.md +++ b/content/flux/v0.x/stdlib/regexp/splitregexp.md @@ -1,41 +1,74 @@ --- title: regexp.splitRegexp() function description: > - The `regexp.splitRegexp()` function splits a string into substrings separated by - regular expression matches and returns an array of `i` substrings between matches. -aliases: - - /influxdb/v2.0/reference/flux/functions/regexp/splitregexp/ - - /influxdb/v2.0/reference/flux/stdlib/regexp/splitregexp/ - - /influxdb/cloud/reference/flux/stdlib/regexp/splitregexp/ + `regexp.splitRegexp()` splits a string into substrings separated by regular expression + matches and returns an array of `i` substrings between matches. menu: flux_0_x_ref: name: regexp.splitRegexp parent: regexp -weight: 301 -introduced: 0.33.7 + identifier: regexp/splitRegexp +weight: 101 --- -The `regexp.splitRegexp()` function splits a string into substrings separated by -regular expression matches and returns an array of `i` substrings between matches. + + +`regexp.splitRegexp()` splits a string into substrings separated by regular expression +matches and returns an array of `i` substrings between matches. + + + +##### Function type signature + +```js +(i: int, r: regexp, v: string) => [string] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### r +({{< req >}}) +Regular expression used to search `v`. + + + +### v +({{< req >}}) +String value to be searched. + + + +### i +({{< req >}}) +Maximum number of substrings to return. + +-1 returns all matching substrings. + + +## Examples + +### Return an array of regular expression matches ```js import "regexp" -regexp.splitRegexp(r: /a*/, v: "abaabaccadaaae", i: 5) +regexp.splitRegexp(r: /a*/, v: "abaabaccadaaae", i: -1)// Returns ["", "b", "b", "c", "c", "d", "e"] -// Returns ["", "b", "b", "c", "cadaaae"] ``` -## Parameters - -### r {data-type="regexp"} -The regular expression used to search `v`. - -### v {data-type="string"} -The string value to search. - -### i {data-type="int"} -The maximum number of substrings to return. -`-1` returns all matching substrings. diff --git a/content/flux/v0.x/stdlib/runtime/_index.md b/content/flux/v0.x/stdlib/runtime/_index.md index 480461600..912b2d4bd 100644 --- a/content/flux/v0.x/stdlib/runtime/_index.md +++ b/content/flux/v0.x/stdlib/runtime/_index.md @@ -1,28 +1,41 @@ --- -title: Flux runtime package -list_title: runtime package +title: runtime package description: > - The Flux `runtime` package includes functions that provide information about the - current Flux runtime. Import the `runtime` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/runtime/ - - /influxdb/v2.0/reference/flux/stdlib/runtime/ - - /influxdb/cloud/reference/flux/stdlib/runtime/ + The `runtime` package provides information about the current Flux runtime. menu: flux_0_x_ref: - name: runtime - parent: Standard library + name: runtime + parent: stdlib + identifier: runtime weight: 11 -flux/v0.x/tags: [runtime, functions, package] -introduced: 0.38.0 --- -The Flux `runtime` package includes functions that provide information about the -current Flux runtime. Import the `runtime` package: + + +The `runtime` package provides information about the current Flux runtime. +Import the `runtime` package: ```js import "runtime" ``` +introduce: 0.38.0 + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/runtime/version.md b/content/flux/v0.x/stdlib/runtime/version.md index fff453dc1..bb8021c9a 100644 --- a/content/flux/v0.x/stdlib/runtime/version.md +++ b/content/flux/v0.x/stdlib/runtime/version.md @@ -1,22 +1,63 @@ --- title: runtime.version() function -description: The `runtime.version()` function returns the current Flux version. -aliases: - - /influxdb/v2.0/reference/flux/functions/runtime/version/ - - /influxdb/v2.0/reference/flux/stdlib/runtime/version/ - - /influxdb/cloud/reference/flux/stdlib/runtime/version/ +description: > + `runtime.version()` returns the current Flux version. menu: flux_0_x_ref: name: runtime.version parent: runtime -weight: 401 -introduced: 0.38.0 + identifier: runtime/version +weight: 101 --- -The `runtime.version()` function returns the current Flux version. + + +`runtime.version()` returns the current Flux version. + + + +##### Function type signature ```js +() => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + + +## Examples + +### Return the Flux version in a stream of tables + +```js +import "array" import "runtime" -runtime.version() +array.from(rows: [{version: runtime.version()}]) ``` + +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| version | +| -------- | +| (devel) | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/sampledata/_index.md b/content/flux/v0.x/stdlib/sampledata/_index.md index 40d6bcc14..f2d692666 100644 --- a/content/flux/v0.x/stdlib/sampledata/_index.md +++ b/content/flux/v0.x/stdlib/sampledata/_index.md @@ -1,22 +1,35 @@ --- -title: Flux sampledata package -list_title: sampledata package +title: sampledata package description: > - The Flux `sampledata` package provides functions that return basic sample datasets. - Import the `sampledata` package. + The `sampledata` package provides functions that return basic sample datasets. menu: flux_0_x_ref: - name: sampledata - parent: Standard library + name: sampledata + parent: stdlib + identifier: sampledata weight: 11 -flux/v0.x/tags: [sample data, functions, package] cascade: + flux/v0.x/tags: [sample data] introduced: 0.128.0 - related: - - /flux/v0.x/stdlib/influxdata/influxdb/sample/ --- -The Flux `sampledata` package provides functions that return basic sample datasets. + + +The `sampledata` package provides functions that return basic sample datasets. Import the `sampledata` package: ```js @@ -24,15 +37,16 @@ import "sampledata" ``` ## Constants -The `sampledata` package includes the following constants: ```js sampledata.start = 2021-01-01T00:00:00Z sampledata.stop = 2021-01-01T00:01:00Z ``` -`sampledata.start` and `sampledata.stop` constants represent the time range that -all data points output by `sampledata` functions are in. +- **sampledata.start** represents the earliest time included in sample datasets. +- **sampledata.stop** represents the latest time included in sample datasets. + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/sampledata/bool.md b/content/flux/v0.x/stdlib/sampledata/bool.md index c759e4a6b..c352c456c 100644 --- a/content/flux/v0.x/stdlib/sampledata/bool.md +++ b/content/flux/v0.x/stdlib/sampledata/bool.md @@ -1,54 +1,85 @@ --- title: sampledata.bool() function description: > - `sampledata.bool` returns a sample data set with boolean values. + `sampledata.bool()` returns a sample data set with boolean values. menu: flux_0_x_ref: name: sampledata.bool parent: sampledata + identifier: sampledata/bool weight: 101 -flux/v0.x/tags: [inputs, sample data] --- -`sampledata.bool` returns a sample data set with boolean values. + + +`sampledata.bool()` returns a sample data set with boolean values. + + + +##### Function type signature ```js -import "sampledata" - -sampledata.bool(includeNull: false) +(?includeNull: bool) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### includeNull {data-type="bool"} -Include _null_ values in the returned dataset. +### includeNull + +Include null values in the returned dataset. Default is `false`. + + + ## Examples -- [Return sample data with boolean values](#return-sample-data-with-boolean-values) -- [Return boolean sample data with null values](#return-boolean-sample-data-with-null-values) +### Output basic sample data with boolean values -### Return sample data with boolean values - -##### Function ```js import "sampledata" sampledata.bool() ``` -##### Output tables -{{% flux/sample "bool" %}} +{{< expand-wrapper >}} +{{% expand "View example output" %}} -### Return boolean sample data with null values +#### Output data -##### Function -```js -import "sampledata" +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | true | +| 2021-01-01T00:00:10Z | t1 | true | +| 2021-01-01T00:00:20Z | t1 | false | +| 2021-01-01T00:00:30Z | t1 | true | +| 2021-01-01T00:00:40Z | t1 | false | +| 2021-01-01T00:00:50Z | t1 | false | -sampledata.bool(includeNull: true) -``` +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | false | +| 2021-01-01T00:00:10Z | t2 | true | +| 2021-01-01T00:00:20Z | t2 | false | +| 2021-01-01T00:00:30Z | t2 | true | +| 2021-01-01T00:00:40Z | t2 | true | +| 2021-01-01T00:00:50Z | t2 | false | -##### Output tables -{{% flux/sample "bool" true %}} \ No newline at end of file +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/sampledata/float.md b/content/flux/v0.x/stdlib/sampledata/float.md index cfaa2a4ad..709de97e4 100644 --- a/content/flux/v0.x/stdlib/sampledata/float.md +++ b/content/flux/v0.x/stdlib/sampledata/float.md @@ -1,54 +1,85 @@ --- title: sampledata.float() function description: > - `sampledata.float` returns a sample data set with float values. + `sampledata.float()` returns a sample data set with float values. menu: flux_0_x_ref: name: sampledata.float parent: sampledata + identifier: sampledata/float weight: 101 -flux/v0.x/tags: [inputs, sample data] --- -`sampledata.float` returns a sample data set with float values. + + +`sampledata.float()` returns a sample data set with float values. + + + +##### Function type signature ```js -import "sampledata" - -sampledata.float(includeNull: false) +(?includeNull: bool) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### includeNull {data-type="bool"} -Include _null_ values in the returned dataset. +### includeNull + +Include null values in the returned dataset. Default is `false`. + + + ## Examples -- [Return sample data with float values](#return-sample-data-with-float-values) -- [Return float sample data with null values](#return-float-sample-data-with-null-values) +### Output basic sample data with float values -### Return sample data with float values - -##### Function ```js import "sampledata" sampledata.float() ``` -##### Output tables -{{% flux/sample "float" %}} +{{< expand-wrapper >}} +{{% expand "View example output" %}} -### Return float sample data with null values +#### Output data -##### Function -```js -import "sampledata" +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -sampledata.float(includeNull: true) -``` +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | -##### Output tables -{{% flux/sample "float" true %}} \ No newline at end of file +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/sampledata/int.md b/content/flux/v0.x/stdlib/sampledata/int.md index bf27bd578..f41e85592 100644 --- a/content/flux/v0.x/stdlib/sampledata/int.md +++ b/content/flux/v0.x/stdlib/sampledata/int.md @@ -1,54 +1,85 @@ --- title: sampledata.int() function description: > - `sampledata.int` returns a sample data set with integer values. + `sampledata.int()` returns a sample data set with integer values. menu: flux_0_x_ref: name: sampledata.int parent: sampledata + identifier: sampledata/int weight: 101 -flux/v0.x/tags: [inputs, sample data] --- -`sampledata.int` returns a sample data set with integer values. + + +`sampledata.int()` returns a sample data set with integer values. + + + +##### Function type signature ```js -import "sampledata" - -sampledata.int(includeNull: false) +(?includeNull: bool) => stream[{A with _value: B, _value: int}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### includeNull {data-type="bool"} -Include _null_ values in the returned dataset. +### includeNull + +Include null values in the returned dataset. Default is `false`. + + + ## Examples -- [Return sample data with integer values](#return-sample-data-with-integer-values) -- [Return integer sample data with null values](#return-integer-sample-data-with-null-values) +### Output basic sample data with integer values -### Return sample data with integer values - -##### Function ```js import "sampledata" sampledata.int() ``` -##### Output tables -{{% flux/sample "int" %}} +{{< expand-wrapper >}} +{{% expand "View example output" %}} -### Return integer sample data with null values +#### Output data -##### Function -```js -import "sampledata" +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -sampledata.int(includeNull: true) -``` +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -##### Output tables -{{% flux/sample "int" true %}} \ No newline at end of file +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/sampledata/numericbool.md b/content/flux/v0.x/stdlib/sampledata/numericbool.md index 96fcbf76a..fac0241a0 100644 --- a/content/flux/v0.x/stdlib/sampledata/numericbool.md +++ b/content/flux/v0.x/stdlib/sampledata/numericbool.md @@ -1,54 +1,85 @@ --- title: sampledata.numericBool() function description: > - `sampledata.numericBool` returns a sample data set with numeric boolean values (`[0,1]`). + `sampledata.numericBool()` returns a sample data set with numeric (integer) boolean values. menu: flux_0_x_ref: name: sampledata.numericBool parent: sampledata + identifier: sampledata/numericBool weight: 101 -flux/v0.x/tags: [inputs, sample data] --- -`sampledata.numericBool` returns a sample data set with numeric boolean values (`[0,1]`). + + +`sampledata.numericBool()` returns a sample data set with numeric (integer) boolean values. + + + +##### Function type signature ```js -import "sampledata" - -sampledata.numericBool(includeNull: false) +(?includeNull: bool) => stream[{A with _value: B, _value: int}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### includeNull {data-type="bool"} -Include _null_ values in the returned dataset. +### includeNull + +Include null values in the returned dataset. Default is `false`. + + + ## Examples -- [Return sample data with numeric boolean values](#return-sample-data-with-numeric-boolean-values) -- [Return numeric boolean sample data with null values](#return-numeric-boolean-sample-data-with-null-values) +### Output basic sample data with numeric boolean values -### Return sample data with numeric boolean values - -##### Function ```js import "sampledata" sampledata.numericBool() ``` -##### Output tables -{{% flux/sample "numericBool" %}} +{{< expand-wrapper >}} +{{% expand "View example output" %}} -### Return numeric boolean sample data with null values +#### Output data -##### Function -```js -import "sampledata" +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 0 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 0 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | -sampledata.numericBool(includeNull: true) -``` +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 1 | t2 | +| 2021-01-01T00:00:20Z | 0 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | -##### Output tables -{{% flux/sample "numericBool" true %}} \ No newline at end of file +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/sampledata/string.md b/content/flux/v0.x/stdlib/sampledata/string.md index 3f96ad87b..656a8e1b1 100644 --- a/content/flux/v0.x/stdlib/sampledata/string.md +++ b/content/flux/v0.x/stdlib/sampledata/string.md @@ -1,54 +1,85 @@ --- title: sampledata.string() function description: > - `sampledata.string` returns a sample data set with string values. + `sampledata.string()` returns a sample data set with string values. menu: flux_0_x_ref: name: sampledata.string parent: sampledata + identifier: sampledata/string weight: 101 -flux/v0.x/tags: [inputs, sample data] --- -`sampledata.string` returns a sample data set with string values. + + +`sampledata.string()` returns a sample data set with string values. + + + +##### Function type signature ```js -import "sampledata" - -sampledata.string(includeNull: false) +(?includeNull: bool) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### includeNull {data-type="bool"} -Include _null_ values in the returned dataset. +### includeNull + +Include null values in the returned dataset. Default is `false`. + + + ## Examples -- [Return sample data with string values](#return-sample-data-with-string-values) -- [Return string sample data with null values](#return-string-sample-data-with-null-values) +### Output basic sample data with string values -### Return sample data with string values - -##### Function ```js import "sampledata" sampledata.string() ``` -##### Output tables -{{% flux/sample "string" %}} +{{< expand-wrapper >}} +{{% expand "View example output" %}} -### Return string sample data with null values +#### Output data -##### Function -```js -import "sampledata" +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | -sampledata.string(includeNull: true) -``` +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | -##### Output tables -{{% flux/sample "string" true %}} \ No newline at end of file +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/sampledata/uint.md b/content/flux/v0.x/stdlib/sampledata/uint.md index ff0c92128..6d067c7a4 100644 --- a/content/flux/v0.x/stdlib/sampledata/uint.md +++ b/content/flux/v0.x/stdlib/sampledata/uint.md @@ -1,53 +1,85 @@ --- title: sampledata.uint() function description: > - `sampledata.uint` returns a sample data set with unsigned integer values. + `sampledata.uint()` returns a sample data set with unsigned integer values. menu: flux_0_x_ref: name: sampledata.uint parent: sampledata + identifier: sampledata/uint weight: 101 -flux/v0.x/tags: [inputs, sample data] --- -`sampledata.uint` returns a sample data set with unsigned integer values. + + +`sampledata.uint()` returns a sample data set with unsigned integer values. + + + +##### Function type signature ```js -import "sampledata" - -sampledata.uint(includeNull: false) +(?includeNull: bool) => stream[{A with _value: B, _value: uint}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### includeNull {data-type="bool"} -Include _null_ values in the returned dataset. +### includeNull + +Include null values in the returned dataset. Default is `false`. + + + ## Examples -- [Return sample data with unsigned integer values](#return-sample-data-with-unsigned-integer-values) -- [Return unsigned integer sample data with null values](#return-unsigned-integer-sample-data-with-null-values) +### Output basic sample data with unsigned integer values -### Return sample data with unsigned integer values - -##### Function ```js import "sampledata" sampledata.uint() ``` -##### Output tables -{{% flux/sample "uint" %}} -### Return unsigned integer sample data with null values +{{< expand-wrapper >}} +{{% expand "View example output" %}} -##### Function -```js -import "sampledata" +#### Output data -sampledata.uint(includeNull: true) -``` +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output tables -{{% flux/sample "uint" true %}} \ No newline at end of file +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/slack/_index.md b/content/flux/v0.x/stdlib/slack/_index.md index ed86446f5..95a7e0168 100644 --- a/content/flux/v0.x/stdlib/slack/_index.md +++ b/content/flux/v0.x/stdlib/slack/_index.md @@ -1,41 +1,56 @@ --- -title: Flux slack package -list_title: slack package +title: slack package description: > - The Flux `slack` package provides functions for sending data to [Slack](https://slack.com/). - Import the `slack` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/slack/ - - /influxdb/v2.0/reference/flux/stdlib/slack/ - - /influxdb/cloud/reference/flux/stdlib/slack/ + The `slack` package provides functions for sending messages to [Slack](https://slack.com/). menu: flux_0_x_ref: - name: slack - parent: Standard library + name: slack + parent: stdlib + identifier: slack weight: 11 -flux/v0.x/tags: [functions, slack, package] -introduced: 0.41.0 +cascade: + + introduced: 0.41.0 --- -The Flux `slack` package provides functions for sending data to [Slack](https://slack.com/). + + +The `slack` package provides functions for sending messages to [Slack](https://slack.com/). Import the `slack` package: ```js import "slack" ``` + + ## Options -The `slack` package provides the following options: ```js -import "slack" - option slack.defaultURL = "https://slack.com/api/chat.postMessage" ``` + +### defaultURL + +`defaultURL` defines the default Slack API URL used by functions in the `slack` package. + + -### defaultURL {data-type="string"} -Default Slack API URL. -Default is `https://slack.com/api/chat.postMessage`. ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/slack/endpoint.md b/content/flux/v0.x/stdlib/slack/endpoint.md index 0063d8836..97ae8253c 100644 --- a/content/flux/v0.x/stdlib/slack/endpoint.md +++ b/content/flux/v0.x/stdlib/slack/endpoint.md @@ -1,81 +1,60 @@ --- title: slack.endpoint() function description: > - The `slack.endpoint()` function sends a message to Slack that includes output data. -aliases: - - /influxdb/v2.0/reference/flux/functions/slack/endpoint/ - - /influxdb/v2.0/reference/flux/stdlib/slack/endpoint/ - - /influxdb/cloud/reference/flux/stdlib/slack/endpoint/ + `slack.endpoint()` returns a function that can be used to send a message to Slack per input row. menu: flux_0_x_ref: name: slack.endpoint parent: slack -weight: 202 -flux/v0.x/tags: [notification endpoints] -introduced: 0.41.0 + identifier: slack/endpoint +weight: 101 --- -The `slack.endpoint()` function sends a message to Slack that includes output data. + + +`slack.endpoint()` returns a function that can be used to send a message to Slack per input row. + +Each output row includes a `_sent` column that indicates if the message for +that row was sent successfully. + +##### Function type signature ```js -import "slack" - -slack.endpoint( - url: "https://slack.com/api/chat.postMessage", - token: "mySuPerSecRetTokEn", -) +( + ?token: string, + ?url: string, +) => ( + mapFn: (r: A) => {B with text: D, color: string, channel: C}, +) => (<-tables: stream[A]) => stream[{A with _sent: string}] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -The Slack API URL. -Default is `https://slack.com/api/chat.postMessage`. +### url -{{% note %}} -If using a Slack webhook, you'll receive a Slack webhook URL when you -[create an incoming webhook](https://api.slack.com/incoming-webhooks#create_a_webhook). -{{% /note %}} +Slack API URL. Default is `https://slack.com/api/chat.postMessage`. -### token {data-type="string"} -The [Slack API token](https://get.slack.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens) -used to interact with Slack. -Default is `""`. +If using the Slack webhook API, this URL is provided ine Slack webhook setup process. -{{% note %}} -A token is only required if using the Slack chat.postMessage API. -{{% /note %}} +### token -## Usage -`slack.endpoint` is a factory function that outputs another function. -The output function requires a `mapFn` parameter. +Slack API token. Default is `""`. -### mapFn {data-type="function"} -({{< req >}}) A function that builds the record used to generate the POST request. -Requires an `r` parameter. +If using the Slack Webhook API, a token is not required. -`mapFn` accepts a table row (`r`) and returns a record that must include the following fields: - -- `channel` -- `text` -- `color` - -_For more information, see [`slack.message()`](/flux/v0.x/stdlib/slack/message/)_ - -## Examples - -##### Send critical statuses to a Slack endpoint -```js -import "slack" -import "influxdata/influxdb/secrets" - -token = secrets.get(key: "SLACK_TOKEN") -toSlack = slack.endpoint(token: token) - -crit_statuses = from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses" and r.status == "crit") - -crit_statuses - |> toSlack(mapFn: (r) => ({channel: "Alerts", text: r._message, color: "danger"}))() -``` diff --git a/content/flux/v0.x/stdlib/slack/message.md b/content/flux/v0.x/stdlib/slack/message.md index 0cc101e3d..14dd51828 100644 --- a/content/flux/v0.x/stdlib/slack/message.md +++ b/content/flux/v0.x/stdlib/slack/message.md @@ -1,90 +1,120 @@ --- title: slack.message() function description: > - The `slack.message()` function sends a single message to a Slack channel. - The function works with either with the chat.postMessage API or with a Slack webhook. -aliases: - - /influxdb/v2.0/reference/flux/functions/slack/message/ - - /influxdb/v2.0/reference/flux/stdlib/slack/message/ - - /influxdb/cloud/reference/flux/stdlib/slack/message/ + `slack.message()` sends a single message to a Slack channel and returns the HTTP + response code of the request. menu: flux_0_x_ref: name: slack.message parent: slack -weight: 202 -introduced: 0.41.0 + identifier: slack/message +weight: 101 +flux/v0.x/tags: [single notification] --- -The `slack.message()` function sends a single message to a Slack channel. -The function works with either with the [chat.postMessage API](https://api.slack.com/methods/chat.postMessage) -or with a [Slack webhook](https://api.slack.com/incoming-webhooks). + + +`slack.message()` sends a single message to a Slack channel and returns the HTTP +response code of the request. + +The function works with either with the `chat.postMessage` API or with a Slack webhook. + +##### Function type signature ```js -import "slack" - -slack.message( - url: "https://slack.com/api/chat.postMessage", - token: "mySuPerSecRetTokEn", - channel: "#flux", - text: "This is a message from the Flux slack.message() function.", - color: "good", -) +( + channel: A, + color: string, + text: B, + ?token: string, + ?url: string, +) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### url {data-type="string"} -The Slack API URL. +### url + +Slack API URL. Default is `https://slack.com/api/chat.postMessage`. -{{% note %}} -If using a Slack webhook, you'll receive a Slack webhook URL when you -[create an incoming webhook](https://api.slack.com/incoming-webhooks#create_a_webhook). -{{% /note %}} +If using the Slack webhook API, this URL is provided ine Slack webhook setup process. -### token {data-type="string"} -The [Slack API token](https://get.slack.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens) -used to interact with Slack. -Default is `""`. +### token -{{% note %}} -A token is only required if using the Slack chat.postMessage API. -{{% /note %}} +Slack API token. Default is `""`. -### channel {data-type="string"} -({{< req >}}) The name of channel to post the message to. +If using the Slack Webhook API, a token is not required. -### text {data-type="string"} -({{< req >}}) The text to display in the Slack message. +### channel +({{< req >}}) +Slack channel or user to send the message to. -### color {data-type="string"} -({{< req >}}) The color to include with the message. -**Valid values include:** -- `good` -- `warning` -- `danger` -- Any valid RGB hex color code. For example, `#439FE0`. +### text +({{< req >}}) +Message text. + + + +### color +({{< req >}}) +Slack message color. + +Valid values: +- good +- warning +- danger +- Any hex RGB color code + ## Examples -##### Send the last reported status to Slack +- [Send a message to Slack using a Slack webhook](#send-a-message-to-slack-using-a-slack-webhook) +- [Send a message to Slack using chat.postMessage API](#send-a-message-to-slack-using-chatpostmessage-api) + +### Send a message to Slack using a Slack webhook + ```js import "slack" -lastReported = from(bucket: "example-bucket") - |> range(start: -1m) - |> filter(fn: (r) => r._measurement == "statuses") - |> last() - |> tableFind(fn: (key) => true) - |> getRecord(idx: 0) +slack.message( + url: "https://hooks.slack.com/services/EXAMPLE-WEBHOOK-URL", + channel: "#example-channel", + text: "Example slack message", + color: "warning", +) +``` + + +### Send a message to Slack using chat.postMessage API + +```js +import "slack" slack.message( url: "https://slack.com/api/chat.postMessage", token: "mySuPerSecRetTokEn", - channel: "#system-status", - text: "The last reported status was \"${lastReported.status}\".", + channel: "#example-channel", + text: "Example slack message", color: "warning", ) ``` + diff --git a/content/flux/v0.x/stdlib/slack/validatecolorstring.md b/content/flux/v0.x/stdlib/slack/validatecolorstring.md new file mode 100644 index 000000000..845e65817 --- /dev/null +++ b/content/flux/v0.x/stdlib/slack/validatecolorstring.md @@ -0,0 +1,59 @@ +--- +title: slack.validateColorString() function +description: > + `slack.validateColorString()` ensures a string contains a valid hex color code. +menu: + flux_0_x_ref: + name: slack.validateColorString + parent: slack + identifier: slack/validateColorString +weight: 101 +--- + + + +`slack.validateColorString()` ensures a string contains a valid hex color code. + + + +##### Function type signature + +```js +(color: string) => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### color +({{< req >}}) +Hex color code. + + + + +## Examples + +### Validate a hex color code string + +```js +import "slack" + +slack.validateColorString(color: "#fff") +``` + diff --git a/content/flux/v0.x/stdlib/socket/_index.md b/content/flux/v0.x/stdlib/socket/_index.md new file mode 100644 index 000000000..c3033291f --- /dev/null +++ b/content/flux/v0.x/stdlib/socket/_index.md @@ -0,0 +1,44 @@ +--- +title: socket package +description: > + The `socket` package provides tools for returning data from socket connections. +menu: + flux_0_x_ref: + name: socket + parent: stdlib + identifier: socket +weight: 11 +cascade: + + introduced: 0.21.0 +--- + + + +The `socket` package provides tools for returning data from socket connections. +Import the `socket` package: + +```js +import "socket" +``` + + + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/socket/from.md b/content/flux/v0.x/stdlib/socket/from.md new file mode 100644 index 000000000..83e4f2dfb --- /dev/null +++ b/content/flux/v0.x/stdlib/socket/from.md @@ -0,0 +1,85 @@ +--- +title: socket.from() function +description: > + `socket.from()` returns data from a socket connection and outputs a stream of tables + given a specified decoder. +menu: + flux_0_x_ref: + name: socket.from + parent: socket + identifier: socket/from +weight: 101 +flux/v0.x/tags: [inputs] +--- + + + +`socket.from()` returns data from a socket connection and outputs a stream of tables +given a specified decoder. + +The function produces a single table for everything that it receives from the +start to the end of the connection. + +##### Function type signature + +```js +(url: string, ?decoder: string) => stream[A] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### url +({{< req >}}) +URL to return data from. + +**Supported URL schemes**: +- tcp +- unix + +### decoder + +Decoder to use to parse returned data into a stream of tables. + +**Supported decoders**: +- csv +- line + + +## Examples + +- [Query annotated CSV from a socket connection](#query-annotated-csv-from-a-socket-connection) +- [Query line protocol from a socket connection](#query-line-protocol-from-a-socket-connection) + +### Query annotated CSV from a socket connection + +```js +import "socket" + +socket.from(url: "tcp://127.0.0.1:1234", decoder: "csv") +``` + + +### Query line protocol from a socket connection + +```js +import "socket" + +socket.from(url: "tcp://127.0.0.1:1234", decoder: "line") +``` + diff --git a/content/flux/v0.x/stdlib/sql/_index.md b/content/flux/v0.x/stdlib/sql/_index.md index 388a09ce8..d45cb1433 100644 --- a/content/flux/v0.x/stdlib/sql/_index.md +++ b/content/flux/v0.x/stdlib/sql/_index.md @@ -1,47 +1,148 @@ --- -title: Flux sql package -list_title: sql package +title: sql package description: > - The Flux `sql` package provides tools for working with data in SQL databases such - as MySQL, PostgreSQL, Snowflake, SQLite, Microsoft SQL Server, Amazon Athena, - Google BigQuery, and more. - Import the `sql` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/sql/ - - /influxdb/v2.0/reference/flux/stdlib/sql/ - - /influxdb/cloud/reference/flux/stdlib/sql/ + The `sql` package provides tools for working with data in SQL databases. menu: flux_0_x_ref: - name: sql - parent: Standard library + name: sql + parent: stdlib + identifier: sql weight: 11 -flux/v0.x/tags: [functions, sql, package, mysql, postgres] -related: - - /{{< latest "influxdb" >}}/query-data/flux/sql/ -introduced: 0.34.0 +cascade: + + introduced: 0.34.0 --- -The Flux `sql` package provides functions for working with SQL databases such as: + + +The `sql` package provides tools for working with data in SQL databases. Import the `sql` package: ```js import "sql" ``` +## SQL data source names +The `sql` packages uses Go drivers to connect to SQL database. +The data source name (DSN) (also known as connection string) is determined by +the driver used. + +```sh +# Amazon Athena Driver DSN +s3://myorgqueryresults/?accessID=AKIAJLO3F...®ion=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F... +s3://myorgqueryresults/?accessID=AKIAJLO3F...&db=dbname&missingAsDefault=false&missingAsEmptyString=false®ion=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F...&WGRemoteCreation=false + +# MySQL Driver DSN +username:password@tcp(localhost:3306)/dbname?param=value + +# Postgres Driver DSN +postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full + +# Snowflake Driver DSNs +username[:password]@accountname/dbname/schemaname?param1=value1¶mN=valueN +username[:password]@accountname/dbname?param1=value1¶mN=valueN +username[:password]@hostname:port/dbname/schemaname?account=¶m1=value1¶mN=valueN + +# SQLite Driver DSN +file:/path/to/test.db?cache=shared&mode=ro + +# Microsoft SQL Server Driver DSNs +sqlserver://username:password@localhost:1234?database=examplebdb +server=localhost;user id=username;database=examplebdb; +server=localhost;user id=username;database=examplebdb;azure auth=ENV +server=localhost;user id=username;database=examplebdbr;azure tenant id=77e7d537;azure client id=58879ce8;azure client secret=0123456789 + +# Google BigQuery DSNs +bigquery://projectid/?param1=value¶m2=value +bigquery://projectid/location?param1=value¶m2=value + +# SAP HANA driver DSN +hdb://:@:?=&=&... +hdb://:@:?DATABASENAME= +hdb://?KEY= + +# Vertica driver DSN +vertica://:@:/? +``` + +### AWS Athena connection strings +To query an Amazon Athena database, use the following query parameters in +your Athena S3 connection string (DNS): + +- **region**: _(Required)_ AWS region. +- **accessID**: _(Required)_ AWS IAM access ID. +- **SecretAccessKey**: _(Required)_ AWS IAM secret key. +- **db**: Database name. +- **WGRemoteCreation**: Controls workgroup and tag creation. +- **missingAsDefault**: Replace missing data with default values. +- **missingAsEmptyString**: Replace missing data with empty strings. + +### Common BigQuery URL parameters +The Flux BigQuery implementation uses the Google Cloud Go SDK. Provide your +authentication credentials using one of the following methods: + +- The `GOOGLE_APPLICATION_CREDENTIALS` environment variable that identifies the + location of yur credential JSON file. +- Provide your BigQuery credentials using the `credentials` URL parameters in your BigQuery DSN. + +#### BigQuery credential URL parameter +Provide your base-64 encoded service account, refresh token, or JSON credentials +using the credentials URL parameter in your BigQuery DSN. + +##### BigQuery credential URL parameter +```txt +bigquery://projectid/?credentials=eyJ0eXBlIjoiYXV0... +``` + +### SQL Server ADO authentication +Use one of the following methods to provide SQL Server authentication +credentials as ActiveX Data Objects (ADO) connection string parameters: + +#### Retrieve authentication credentials from environment variables +```txt +azure auth=ENV +``` + +#### Retrieve authentication credentials from a file +```txt +azure auth=C:\secure\azure.auth +``` + +**Note**: InfluxDB OSS and InfluxDB Cloud user interfaces do not provide access +to the underlying filesystem and do not support reading credentials from a file. +To retrieve SQL Server credentials from a file, execute the query in the Flux +REPL on your local machine. + +#### Specify authentication credentials in the connection string +```sh +# Example of providing tenant ID, client ID, and client secret token +azure tenant id=77...;azure client id=58...;azure client secret=0cf123.. +# Example of providing tenant ID, client ID, certificate path and certificate password +azure tenant id=77...;azure client id=58...;azure certificate path=C:\secure\...;azure certificate password=xY... +# Example of providing tenant ID, client ID, and Azure username and password +azure tenant id=77...;azure client id=58...;azure username=some@myorg;azure password=a1... +``` + +#### Use a managed identity in an Azure VM +```txt +azure auth=MSI +``` + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/sql/from.md b/content/flux/v0.x/stdlib/sql/from.md index 627db869f..64a341504 100644 --- a/content/flux/v0.x/stdlib/sql/from.md +++ b/content/flux/v0.x/stdlib/sql/from.md @@ -1,97 +1,70 @@ --- title: sql.from() function -description: The `sql.from()` function retrieves data from a SQL data source. -aliases: - - /influxdb/v2.0/reference/flux/functions/sql/from/ - - /influxdb/v2.0/reference/flux/stdlib/sql/from/ - - /influxdb/cloud/reference/flux/stdlib/sql/from/ +description: > + `sql.from()` retrieves data from a SQL data source. menu: flux_0_x_ref: name: sql.from parent: sql -weight: 202 -flux/v0.x/tags: [inputs] -related: - - /flux/v0.x/query-data/sql/ -introduced: 0.34.0 + identifier: sql/from +weight: 101 --- -The `sql.from()` function retrieves data from a SQL data source. + + +`sql.from()` retrieves data from a SQL data source. + + + +##### Function type signature ```js -import "sql" - -sql.from( - driverName: "postgres", - dataSourceName: "postgresql://user:password@localhost", - query:"SELECT * FROM TestTable", -) +(dataSourceName: string, driverName: string, query: string) => stream[A] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### driverName {data-type="string"} +### driverName +({{< req >}}) Driver to use to connect to the SQL database. -The following drivers are available: - +**Supported drivers**: - awsathena - bigquery - hdb - mysql - postgres - snowflake -- sqlite3 – _Does not work with InfluxDB OSS or InfluxDB Cloud. For more information, see [Query SQLite](/flux/v0.x/query-data/sql/sqlite/)._ +- sqlite3 _(Does not work with InfluxDB OSS or InfluxDB Cloud)_ - sqlserver - vertica, vertigo -### dataSourceName {data-type="string"} -Data source name (DSN) or connection string to use to connect to the SQL database. -The string's form and structure depend on the [driver](#drivername) used. +### dataSourceName +({{< req >}}) +Data source name (DNS) or connection string used to connect +to the SQL database. -##### Driver dataSourceName examples -```sh -# Amazon Athena Driver DSN -s3://myorgqueryresults/?accessID=AKIAJLO3F...®ion=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F... -s3://myorgqueryresults/?accessID=AKIAJLO3F...&db=dbname&missingAsDefault=false&missingAsEmptyString=false®ion=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F...&WGRemoteCreation=false -# MySQL Driver DSN -username:password@tcp(localhost:3306)/dbname?param=value -# Postgres Driver DSN -postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full - -# Snowflake Driver DSNs -username[:password]@accountname/dbname/schemaname?param1=value1¶mN=valueN -username[:password]@accountname/dbname?param1=value1¶mN=valueN -username[:password]@hostname:port/dbname/schemaname?account=¶m1=value1¶mN=valueN - -# SQLite Driver DSN -file:/path/to/test.db?cache=shared&mode=ro - -# Microsoft SQL Server Driver DSNs -sqlserver://username:password@localhost:1234?database=examplebdb -server=localhost;user id=username;database=examplebdb; -server=localhost;user id=username;database=examplebdb;azure auth=ENV -server=localhost;user id=username;database=examplebdbr;azure tenant id=77e7d537;azure client id=58879ce8;azure client secret=0123456789 - -# Google BigQuery DSNs -bigquery://projectid/?param1=value¶m2=value -bigquery://projectid/location?param1=value¶m2=value - -# SAP HANA driver DSN -hdb://:@:?=&=&... -hdb://:@:?DATABASENAME= -hdb://?KEY= - -# Vertica driver DSN -vertica://:@:/? -``` - -### query {data-type="string"} +### query +({{< req >}}) Query to run against the SQL database. -## Examples -For examples and more information about each supported SQL database, see -[Query SQL databases](/flux/v0.x/query-data/sql/). \ No newline at end of file + diff --git a/content/flux/v0.x/stdlib/sql/to.md b/content/flux/v0.x/stdlib/sql/to.md index a6e0a09ed..554464feb 100644 --- a/content/flux/v0.x/stdlib/sql/to.md +++ b/content/flux/v0.x/stdlib/sql/to.md @@ -1,104 +1,88 @@ --- title: sql.to() function -description: The `sql.to()` function writes data to a SQL database. -aliases: - - /influxdb/v2.0/reference/flux/functions/sql/to/ - - /influxdb/v2.0/reference/flux/stdlib/sql/to/ - - /influxdb/cloud/reference/flux/stdlib/sql/to/ +description: > + `sql.to()` writes data to an SQL database. menu: flux_0_x_ref: name: sql.to parent: sql -weight: 202 -flux/v0.x/tags: [outputs] -introduced: 0.35.0 + identifier: sql/to +weight: 101 --- -The `sql.to()` function writes data to a SQL database. + + +`sql.to()` writes data to an SQL database. + + + +##### Function type signature ```js -import "sql" - -sql.to( - driverName: "mysql", - dataSourceName: "username:password@tcp(localhost:3306)/dbname?param=value", - table: "example_table", - batchSize: 10000, -) +( + <-tables: stream[A], + dataSourceName: string, + driverName: string, + table: string, + ?batchSize: int, +) => stream[A] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### driverName {data-type="string"} -The driver used to connect to the SQL database. - -The following drivers are available: +### driverName +({{< req >}}) +Driver used to connect to the SQL database. +**Supported drivers**: - bigquery - hdb - mysql - postgres - snowflake -- sqlite3 – _Does not work with InfluxDB OSS or InfluxDB Cloud. For more information, see [Write to SQLite](/flux/v0.x/write-data/sql/sqlite/)._ +- sqlite3 _(Does not work with InfluxDB OSS or InfluxDB Cloud)_ - sqlserver - vertica, vertigo -{{% warn %}} -#### sql.to does not support Amazon Athena -The `sql.to` function does not support writing data to [Amazon Athena](https://aws.amazon.com/athena/). -{{% /warn %}} +### dataSourceName +({{< req >}}) +Data source name (DNS) or connection string used +to connect to the SQL database. -### dataSourceName {data-type="string"} -The data source name (DSN) or connection string used to connect to the SQL database. -The string's form and structure depend on the [driver](#drivername) used. -##### Driver dataSourceName examples -```sh -# Postgres Driver DSN -postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full -# MySQL Driver DSN -username:password@tcp(localhost:3306)/dbname?param=value +### table +({{< req >}}) +Destination table. -# Snowflake Driver DSNs -username[:password]@accountname/dbname/schemaname?param1=value1¶mN=valueN -username[:password]@accountname/dbname?param1=value1¶mN=valueN -username[:password]@hostname:port/dbname/schemaname?account=¶m1=value1¶mN=valueN -# SQLite Driver DSN -file:/path/to/test.db?cache=shared&mode=rw -# Microsoft SQL Server Driver DSNs -sqlserver://username:password@localhost:1234?database=examplebdb -server=localhost;user id=username;database=examplebdb; -server=localhost;user id=username;database=examplebdb;azure auth=ENV -server=localhost;user id=username;database=examplebdbr;azure tenant id=77e7d537;azure client id=58879ce8;azure client secret=0123456789 +### batchSize -# Google BigQuery DSNs -bigquery://projectid/?param1=value¶m2=value -bigquery://projectid/location?param1=value¶m2=value +Number of parameters or columns that can be queued within each +call to `Exec`. Default is `10000`. -# SAP HANA driver DSN -hdb://:@:?=&=&... -hdb://:@:?DATABASENAME= -hdb://?KEY= +If writing to SQLite database, set the batchSize to `999` or less. -# Vertica driver DSN -vertica://:@:/? -``` +### tables -### table {data-type="string"} -The destination table. +Input data. Default is piped-forward data (`<-`). -### batchSize {data-type="int"} -The number of parameters or columns that can be queued within each call to `Exec`. -Defaults to `10000`. -{{% note %}} -If writing to a **SQLite** database, set `batchSize` to `999` or less. -{{% /note %}} -## Examples - -For examples and more information about each supported SQL database, see -[Write to SQL databases](/flux/v0.x/write-data/sql/). diff --git a/content/flux/v0.x/stdlib/strings/_index.md b/content/flux/v0.x/stdlib/strings/_index.md index 93bf38d8a..d2301ccae 100644 --- a/content/flux/v0.x/stdlib/strings/_index.md +++ b/content/flux/v0.x/stdlib/strings/_index.md @@ -1,28 +1,44 @@ --- -title: Flux strings package -list_title: strings package +title: strings package description: > - The Flux `strings` package provides functions to manipulate UTF-8 encoded strings. - Import the `strings` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/ - - /influxdb/v2.0/reference/flux/stdlib/strings/ - - /influxdb/cloud/reference/flux/stdlib/strings/ + The `strings` package provides functions to operate on UTF-8 encoded strings. menu: flux_0_x_ref: - name: strings - parent: Standard library + name: strings + parent: stdlib + identifier: strings weight: 11 -flux/v0.x/tags: [strings, functions, package] -introduced: 0.18.0 +cascade: + + introduced: 0.18.0 --- -The Flux `strings` package provides functions for working with UTF-8 encoded strings. + + +The `strings` package provides functions to operate on UTF-8 encoded strings. Import the `strings` package: ```js import "strings" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/strings/compare.md b/content/flux/v0.x/stdlib/strings/compare.md index ae6732cc6..eea9f5da7 100644 --- a/content/flux/v0.x/stdlib/strings/compare.md +++ b/content/flux/v0.x/stdlib/strings/compare.md @@ -1,51 +1,97 @@ --- title: strings.compare() function -description: The strings.compare() function compares the lexicographical order of two strings. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/compare/ - - /influxdb/v2.0/reference/flux/stdlib/strings/compare/ - - /influxdb/cloud/reference/flux/stdlib/strings/compare/ +description: > + `strings.compare()` compares the lexicographical order of two strings. menu: flux_0_x_ref: name: strings.compare parent: strings -weight: 301 -introduced: 0.18.0 + identifier: strings/compare +weight: 101 --- -The `strings.compare()` function compares the lexicographical order of two strings. + + +`strings.compare()` compares the lexicographical order of two strings. #### Return values | Comparison | Return value | -|:----------:|:------------:| -| `v < t` | `-1` | -| `v == t` | `0` | -| `v > t` | `1` | +| :--------- | -----------: | +| v < t | -1 | +| v == t | 0 | +| v > t | 1 | + +##### Function type signature + +```js +(t: string, v: string) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### v {data-type="string"} -The string value to compare. +### v +({{< req >}}) +String value to compare. + + + +### t +({{< req >}}) +String value to compare against. + + -### t {data-type="string"} -The string value to compare against. ## Examples -###### Compare the lexicographical order of column values +### Compare the lexicographical order of column values + ```js import "strings" data - |> map(fn: (r) => ({r with _value: strings.compare(v: r.tag1, t: r.tag2)})) + |> map(fn: (r) => ({r with same: strings.compare(v: r.string1, t: r.string2)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| time | string1 | string2 | +| -------------------- | ---------- | ---------- | +| 2022-01-01T00:00:00Z | RJqcVGNlcJ | rjQCvGNLCj | +| 2022-01-01T00:01:00Z | unfbcNAXUA | hBumdSljCQ | +| 2022-01-01T00:02:00Z | ITcHyLZuqu | ITcHyLZuqu | +| 2022-01-01T00:03:00Z | HyXdjvrjgp | hyxDJvrJGP | +| 2022-01-01T00:04:00Z | SVepvUBAVx | GuKKjuGsyI | + + +#### Output data + +| same | string1 | string2 | time | +| ----- | ---------- | ---------- | -------------------- | +| -1 | RJqcVGNlcJ | rjQCvGNLCj | 2022-01-01T00:00:00Z | +| 1 | unfbcNAXUA | hBumdSljCQ | 2022-01-01T00:01:00Z | +| 0 | ITcHyLZuqu | ITcHyLZuqu | 2022-01-01T00:02:00Z | +| -1 | HyXdjvrjgp | hyxDJvrJGP | 2022-01-01T00:03:00Z | +| 1 | SVepvUBAVx | GuKKjuGsyI | 2022-01-01T00:04:00Z | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/containsany.md b/content/flux/v0.x/stdlib/strings/containsany.md index 4ec418fe7..a149a574e 100644 --- a/content/flux/v0.x/stdlib/strings/containsany.md +++ b/content/flux/v0.x/stdlib/strings/containsany.md @@ -1,49 +1,107 @@ --- title: strings.containsAny() function description: > - The strings.containsAny() function reports whether a specified string contains - any characters from from another string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/containsany/ - - /influxdb/v2.0/reference/flux/stdlib/strings/containsany/ - - /influxdb/cloud/reference/flux/stdlib/strings/containsany/ + `strings.containsAny()` reports whether a specified string contains characters from another string. menu: flux_0_x_ref: name: strings.containsAny parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/containsstr -introduced: 0.18.0 + identifier: strings/containsAny +weight: 101 --- -The `strings.containsAny()` function reports whether a specified string contains -characters from another string. + + +`strings.containsAny()` reports whether a specified string contains characters from another string. + + + +##### Function type signature ```js -import "strings" - -strings.containsAny(v: "abc", chars: "and") - -// returns true +(chars: string, v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search. -### chars {data-type="string"} + + +### chars +({{< req >}}) Characters to search for. + + + ## Examples -###### Report if a string contains specific characters +### Filter based on the presence of a specific characters in a column value + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with _value: strings.containsAny(v: r.price, chars: "£$¢")})) +sampledata.string() + |> filter(fn: (r) => strings.containsAny(v: r._value, chars: "a79")) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/containsstr.md b/content/flux/v0.x/stdlib/strings/containsstr.md index 172eb29dc..d96fd3d0e 100644 --- a/content/flux/v0.x/stdlib/strings/containsstr.md +++ b/content/flux/v0.x/stdlib/strings/containsstr.md @@ -1,46 +1,105 @@ --- title: strings.containsStr() function -description: The strings.containsStr() function reports whether a string contains a specified substring. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/containsstr/ - - /influxdb/v2.0/reference/flux/stdlib/strings/containsstr/ - - /influxdb/cloud/reference/flux/stdlib/strings/containsstr/ +description: > + `strings.containsStr()` reports whether a string contains a specified substring. menu: flux_0_x_ref: name: strings.containsStr parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/containsany -introduced: 0.18.0 + identifier: strings/containsStr +weight: 101 --- -The `strings.containsStr()` function reports whether a string contains a specified substring. + + +`strings.containsStr()` reports whether a string contains a specified substring. + + + +##### Function type signature ```js -import "strings" - -strings.containsStr(v: "This and that", substr: "and") - -// returns true +(substr: string, v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search. + + + +### substr +({{< req >}}) +Substring value to search for. + + -### substr {data-type="string"} -The substring value to search for. ## Examples -###### Report if a string contains a specific substring +### Filter based on the presence of a substring in a column value + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with _value: strings.containsStr(v: r.author, substr: "John")})) +sampledata.string() + |> filter(fn: (r) => strings.containsStr(v: r._value, substr: "5")) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/countstr.md b/content/flux/v0.x/stdlib/strings/countstr.md index 2d811b119..d0d3df88b 100644 --- a/content/flux/v0.x/stdlib/strings/countstr.md +++ b/content/flux/v0.x/stdlib/strings/countstr.md @@ -1,58 +1,113 @@ --- title: strings.countStr() function description: > - The strings.countStr() function counts the number of non-overlapping instances - of a substring appears in a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/countstr/ - - /influxdb/v2.0/reference/flux/stdlib/strings/countstr/ - - /influxdb/cloud/reference/flux/stdlib/strings/countstr/ + `strings.countStr()` counts the number of non-overlapping instances of a substring appears in a string. menu: flux_0_x_ref: name: strings.countStr parent: strings -weight: 301 -introduced: 0.18.0 + identifier: strings/countStr +weight: 101 --- -The `strings.countStr()` function counts the number of non-overlapping instances -of a substring appears in a string. + + +`strings.countStr()` counts the number of non-overlapping instances of a substring appears in a string. + + + +##### Function type signature ```js -import "strings" - -strings.countStr(v: "Hello mellow fellow", substr: "ello") - -// returns 3 +(substr: string, v: string) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search. -### substr {data-type="string"} -The substring to count. -{{% note %}} + +### substr +({{< req >}}) +Substring to count occurences of. + The function counts only non-overlapping instances of `substr`. -For example: -```js -strings.coutnStr(v: "ooooo", substr: "oo") - -// Returns 2 -- (oo)(oo)o -``` -{{% /note %}} ## Examples -###### Count instances of a substring within a string +### Count instances of a substring within a string + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with _value: strings.countStr(v: r.message, substr: "uh")})) +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.countStr(v: r._value, substr: "p")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 2 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 1 | t1 | +| 2021-01-01T00:00:50Z | 1 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t2 | +| 2021-01-01T00:00:10Z | 2 | t2 | +| 2021-01-01T00:00:20Z | 1 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/equalfold.md b/content/flux/v0.x/stdlib/strings/equalfold.md index fb2d1a172..0cdecb95e 100644 --- a/content/flux/v0.x/stdlib/strings/equalfold.md +++ b/content/flux/v0.x/stdlib/strings/equalfold.md @@ -1,52 +1,92 @@ --- title: strings.equalFold() function description: > - The strings.equalFold() function reports whether two UTF-8 strings are equal - under Unicode case-folding. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/equalfold/ - - /influxdb/v2.0/reference/flux/stdlib/strings/equalfold/ - - /influxdb/cloud/reference/flux/stdlib/strings/equalfold/ + `strings.equalFold()` reports whether two UTF-8 strings are equal under Unicode case-folding. menu: flux_0_x_ref: name: strings.equalFold parent: strings -weight: 301 -introduced: 0.18.0 + identifier: strings/equalFold +weight: 101 --- -The `strings.equalFold()` function reports whether two UTF-8 strings are equal -under Unicode case-folding. + + +`strings.equalFold()` reports whether two UTF-8 strings are equal under Unicode case-folding. + + + +##### Function type signature ```js -import "strings" - -strings.equalFold(v: "Go", t: "go") - -// returns true +(t: string, v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to compare. +### v +({{< req >}}) +String value to compare. + + + +### t +({{< req >}}) +String value to compare against. + + -### t {data-type="string"} -The string value to compare against. ## Examples -###### Ignore case when testing if two strings are the same +### Ignore case when comparing two strings + ```js import "strings" data - |> map(fn: (r) => ({r with - string1: r.string1, - string2: r.string2, - same: strings.equalFold(v: r.string1, t: r.string2) - }) - ) + |> map(fn: (r) => ({r with same: strings.equalFold(v: r.string1, t: r.string2)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| time | string1 | string2 | +| -------------------- | ---------- | ---------- | +| 2022-01-01T00:00:00Z | RJqcVGNlcJ | rjQCvGNLCj | +| 2022-01-01T00:01:00Z | hBumdSljCQ | unfbcNAXUA | +| 2022-01-01T00:02:00Z | ITcHyLZuqu | KKtCcRHsKj | +| 2022-01-01T00:03:00Z | HyXdjvrjgp | hyxDJvrJGP | +| 2022-01-01T00:04:00Z | SVepvUBAVx | GuKKjuGsyI | + + +#### Output data + +| same | string1 | string2 | time | +| ----- | ---------- | ---------- | -------------------- | +| true | RJqcVGNlcJ | rjQCvGNLCj | 2022-01-01T00:00:00Z | +| false | hBumdSljCQ | unfbcNAXUA | 2022-01-01T00:01:00Z | +| false | ITcHyLZuqu | KKtCcRHsKj | 2022-01-01T00:02:00Z | +| true | HyXdjvrjgp | hyxDJvrJGP | 2022-01-01T00:03:00Z | +| false | SVepvUBAVx | GuKKjuGsyI | 2022-01-01T00:04:00Z | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/hasprefix.md b/content/flux/v0.x/stdlib/strings/hasprefix.md index ffb6ce18e..833eb7da6 100644 --- a/content/flux/v0.x/stdlib/strings/hasprefix.md +++ b/content/flux/v0.x/stdlib/strings/hasprefix.md @@ -1,44 +1,103 @@ --- title: strings.hasPrefix() function -description: The strings.hasPrefix() function indicates if a string begins with a specific prefix. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/hasprefix/ - - /influxdb/v2.0/reference/flux/stdlib/strings/hasprefix/ - - /influxdb/cloud/reference/flux/stdlib/strings/hasprefix/ +description: > + `strings.hasPrefix()` indicates if a string begins with a specified prefix. menu: flux_0_x_ref: name: strings.hasPrefix parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/hassuffix -introduced: 0.18.0 + identifier: strings/hasPrefix +weight: 101 --- -The `strings.hasPrefix()` function indicates if a string begins with a specified prefix. + + +`strings.hasPrefix()` indicates if a string begins with a specified prefix. + + + +##### Function type signature ```js -import "strings" - -strings.hasPrefix(v: "go gopher", prefix: "go") - -// returns true +(prefix: string, v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search. -### prefix {data-type="string"} -The prefix to search for. -###### Filter based on the presence of a prefix in a column value + +### prefix +({{< req >}}) +Prefix to search for. + + + + +## Examples + +### Filter based on the presence of a prefix in a column value + ```js +import "sampledata" import "strings" -data - |> filter(fn:(r) => strings.hasPrefix(v: r.metric, prefix: "int_" )) +sampledata.string() + |> filter(fn: (r) => strings.hasPrefix(v: r._value, prefix: "smpl_5")) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/hassuffix.md b/content/flux/v0.x/stdlib/strings/hassuffix.md index 413df06f0..4f378f7d6 100644 --- a/content/flux/v0.x/stdlib/strings/hassuffix.md +++ b/content/flux/v0.x/stdlib/strings/hassuffix.md @@ -1,45 +1,104 @@ --- title: strings.hasSuffix() function -description: The strings.hasSuffix() function indicates if a string ends with a specified suffix. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/hassuffix/ - - /influxdb/v2.0/reference/flux/stdlib/strings/hassuffix/ - - /influxdb/cloud/reference/flux/stdlib/strings/hassuffix/ +description: > + `strings.hasSuffix()` indicates if a string ends with a specified suffix. menu: flux_0_x_ref: name: strings.hasSuffix parent: strings -weight: 301 -flux/v0.x/tags: [tests] -related: - - /flux/v0.x/stdlib/strings/hasprefix -introduced: 0.18.0 + identifier: strings/hasSuffix +weight: 101 --- -The `strings.hasSuffix()` function indicates if a string ends with a specified suffix. + + +`strings.hasSuffix()` indicates if a string ends with a specified suffix. + + + +##### Function type signature ```js -import "strings" - -strings.hasSuffix(v: "go gopher", suffix: "go") - -// returns false +(suffix: string, v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search. -### suffix {data-type="string"} -The suffix to search for. -###### Filter based on the presence of a suffix in a column value + +### suffix +({{< req >}}) +Suffix to search for. + + + + +## Examples + +### Filter based on the presence of a suffix in a column value + ```js +import "sampledata" import "strings" -data - |> filter(fn:(r) => strings.hasSuffix(v: r.metric, suffix: "_count" )) +sampledata.string() + |> filter(fn: (r) => strings.hasSuffix(v: r._value, suffix: "4")) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/index-fn.md b/content/flux/v0.x/stdlib/strings/index-fn.md new file mode 100644 index 000000000..54145e692 --- /dev/null +++ b/content/flux/v0.x/stdlib/strings/index-fn.md @@ -0,0 +1,115 @@ +--- +title: strings.index() function +description: > + `strings.index()` returns the index of the first instance of a substring in a string. + If the substring is not present, it returns `-1`. +menu: + flux_0_x_ref: + name: strings.index + parent: strings + identifier: strings/index +weight: 101 +--- + + + +`strings.index()` returns the index of the first instance of a substring in a string. +If the substring is not present, it returns `-1`. + + + +##### Function type signature + +```js +(substr: string, v: string) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### v +({{< req >}}) +String value to search. + + + +### substr +({{< req >}}) +Substring to search for. + + + + +## Examples + +### Find the index of the first occurrence of a substring + +```js +import "sampledata" +import "strings" + +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.index(v: r._value, substr: "g")})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 5 | t1 | +| 2021-01-01T00:00:10Z | 7 | t1 | +| 2021-01-01T00:00:20Z | -1 | t1 | +| 2021-01-01T00:00:30Z | 5 | t1 | +| 2021-01-01T00:00:40Z | -1 | t1 | +| 2021-01-01T00:00:50Z | 9 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -1 | t2 | +| 2021-01-01T00:00:10Z | -1 | t2 | +| 2021-01-01T00:00:20Z | 6 | t2 | +| 2021-01-01T00:00:30Z | -1 | t2 | +| 2021-01-01T00:00:40Z | -1 | t2 | +| 2021-01-01T00:00:50Z | -1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/index-func.md b/content/flux/v0.x/stdlib/strings/index-func.md deleted file mode 100644 index 6d9ab1271..000000000 --- a/content/flux/v0.x/stdlib/strings/index-func.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: strings.index() function -description: > - The strings.index() function returns the index of the first instance of a substring - in another string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/index-func/ - - /influxdb/v2.0/reference/flux/stdlib/strings/index-func/ - - /influxdb/cloud/reference/flux/stdlib/strings/index-func/ -menu: - flux_0_x_ref: - name: strings.index - parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/indexany/ - - /flux/v0.x/stdlib/strings/lastindex/ - - /flux/v0.x/stdlib/strings/lastindexany/ -introduced: 0.18.0 ---- - -The `strings.index()` function returns the index of the first instance of a substring -in a string. If the substring is not present, it returns `-1`. - -_**Output data type:** Integer_ - -```js -import "strings" - -strings.index(v: "go gopher", substr: "go") - -// returns 0 -``` - -## Parameters - -### v {data-type="string"} -The string value to search. - -### substr {data-type="string"} -The substring to search for. - -## Examples - -###### Find the first occurrence of a substring -```js -import "strings" - -data - |> map(fn: (r) => ({r with the_index: strings.index(v: r.pageTitle, substr: "the")})) -``` diff --git a/content/flux/v0.x/stdlib/strings/indexany.md b/content/flux/v0.x/stdlib/strings/indexany.md index 6ef4ee5d7..2550424fc 100644 --- a/content/flux/v0.x/stdlib/strings/indexany.md +++ b/content/flux/v0.x/stdlib/strings/indexany.md @@ -1,50 +1,115 @@ --- title: strings.indexAny() function description: > - The strings.indexAny() function returns the index of the first instance of specified characters in a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/indexany/ - - /influxdb/v2.0/reference/flux/stdlib/strings/indexany/ - - /influxdb/cloud/reference/flux/stdlib/strings/indexany/ + `strings.indexAny()` returns the index of the first instance of specified characters in a string. + If none of the specified characters are present, it returns `-1`. menu: flux_0_x_ref: name: strings.indexAny parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/index-func/ - - /flux/v0.x/stdlib/strings/lastindex/ - - /flux/v0.x/stdlib/strings/lastindexany/ -introduced: 0.18.0 + identifier: strings/indexAny +weight: 101 --- -The `strings.indexAny()` function returns the index of the first instance of specified characters in a string. + + +`strings.indexAny()` returns the index of the first instance of specified characters in a string. If none of the specified characters are present, it returns `-1`. -_**Output data type:** Integer_ + + +##### Function type signature ```js -import "strings" - -strings.indexAny(v: "chicken", chars: "aeiouy") - -// returns 2 +(chars: string, v: string) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search. -### chars {data-type="string"} + + +### chars +({{< req >}}) Characters to search for. + + + ## Examples -###### Find the first occurrence of characters from a string +### Find the index of the first occurrence of characters from a string + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with charIndex: strings.indexAny(v: r._field, chars: "_-")})) +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.indexAny(v: r._value, chars: "g7t")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 5 | t1 | +| 2021-01-01T00:00:10Z | 7 | t1 | +| 2021-01-01T00:00:20Z | -1 | t1 | +| 2021-01-01T00:00:30Z | 5 | t1 | +| 2021-01-01T00:00:40Z | -1 | t1 | +| 2021-01-01T00:00:50Z | 9 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -1 | t2 | +| 2021-01-01T00:00:10Z | -1 | t2 | +| 2021-01-01T00:00:20Z | 6 | t2 | +| 2021-01-01T00:00:30Z | 10 | t2 | +| 2021-01-01T00:00:40Z | 8 | t2 | +| 2021-01-01T00:00:50Z | 6 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/isdigit.md b/content/flux/v0.x/stdlib/strings/isdigit.md index 771cdfe9b..97202ff74 100644 --- a/content/flux/v0.x/stdlib/strings/isdigit.md +++ b/content/flux/v0.x/stdlib/strings/isdigit.md @@ -1,44 +1,98 @@ --- title: strings.isDigit() function -description: The strings.isDigit() function tests if a single character string is a digit (0-9). -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/isdigit/ - - /influxdb/v2.0/reference/flux/stdlib/strings/isdigit/ - - /influxdb/cloud/reference/flux/stdlib/strings/isdigit/ +description: > + `strings.isDigit()` tests if a single-character string is a digit (0-9). menu: flux_0_x_ref: name: strings.isDigit parent: strings -weight: 301 -flux/v0.x/tags: [tests] -related: - - /flux/v0.x/stdlib/strings/isletter/ -introduced: 0.18.0 + identifier: strings/isDigit +weight: 101 --- -The `strings.isDigit()` function tests if a single-character string is a digit (0-9). + + +`strings.isDigit()` tests if a single-character string is a digit (0-9). + + + +##### Function type signature ```js -import "strings" - -strings.isDigit(v: "A") - -// Returns false +(v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The single-character string to test. +### v +({{< req >}}) +Single-character string to test. + + + ## Examples -###### Filter by columns with digits as values +### Filter by columns with digits as values + ```js import "strings" data - |> filter(fn: (r) => strings.isDigit(v: r.serverRef)) + |> filter(fn: (r) => strings.isDigit(v: r._value)) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | s | t1 | +| 2021-01-01T00:00:10Z | n | t1 | +| 2021-01-01T00:00:20Z | 4 | t1 | +| 2021-01-01T00:00:30Z | 4 | t1 | +| 2021-01-01T00:00:40Z | e | t1 | +| 2021-01-01T00:00:50Z | y | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | a | t2 | +| 2021-01-01T00:00:10Z | p | t2 | +| 2021-01-01T00:00:20Z | 4 | t2 | +| 2021-01-01T00:00:30Z | t | t2 | +| 2021-01-01T00:00:40Z | 7 | t2 | +| 2021-01-01T00:00:50Z | v | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 4 | t1 | +| 2021-01-01T00:00:30Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 4 | t2 | +| 2021-01-01T00:00:40Z | 7 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/isletter.md b/content/flux/v0.x/stdlib/strings/isletter.md index 54b217ef5..e49a4e695 100644 --- a/content/flux/v0.x/stdlib/strings/isletter.md +++ b/content/flux/v0.x/stdlib/strings/isletter.md @@ -1,44 +1,102 @@ --- title: strings.isLetter() function -description: The strings.isLetter() function tests if a single character string is a letter (a-z, A-Z). -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/isletter/ - - /influxdb/v2.0/reference/flux/stdlib/strings/isletter/ - - /influxdb/cloud/reference/flux/stdlib/strings/isletter/ +description: > + `strings.isLetter()` tests if a single character string is a letter (a-z, A-Z). menu: flux_0_x_ref: name: strings.isLetter parent: strings -weight: 301 -flux/v0.x/tags: [tests] -related: - - /flux/v0.x/stdlib/strings/isdigit/ -introduced: 0.18.0 + identifier: strings/isLetter +weight: 101 --- -The `strings.isLetter()` function tests if a single character string is a letter (a-z, A-Z). + + +`strings.isLetter()` tests if a single character string is a letter (a-z, A-Z). + + + +##### Function type signature ```js -import "strings" - -strings.isLetter(v: "A") - -// returns true +(v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The single character string to test. +### v +({{< req >}}) +Single-character string to test. + + + ## Examples -###### Filter by columns with single-letter values +### Filter by columns with digits as values + ```js import "strings" data - |> filter(fn: (r) => strings.isLetter(v: r.serverRef)) + |> filter(fn: (r) => strings.isLetter(v: r._value)) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | s | t1 | +| 2021-01-01T00:00:10Z | n | t1 | +| 2021-01-01T00:00:20Z | 4 | t1 | +| 2021-01-01T00:00:30Z | 4 | t1 | +| 2021-01-01T00:00:40Z | e | t1 | +| 2021-01-01T00:00:50Z | y | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | a | t2 | +| 2021-01-01T00:00:10Z | p | t2 | +| 2021-01-01T00:00:20Z | 4 | t2 | +| 2021-01-01T00:00:30Z | t | t2 | +| 2021-01-01T00:00:40Z | 7 | t2 | +| 2021-01-01T00:00:50Z | v | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | s | t1 | +| 2021-01-01T00:00:10Z | n | t1 | +| 2021-01-01T00:00:40Z | e | t1 | +| 2021-01-01T00:00:50Z | y | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | a | t2 | +| 2021-01-01T00:00:10Z | p | t2 | +| 2021-01-01T00:00:30Z | t | t2 | +| 2021-01-01T00:00:50Z | v | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/islower.md b/content/flux/v0.x/stdlib/strings/islower.md index 138b72638..bb72a4fcf 100644 --- a/content/flux/v0.x/stdlib/strings/islower.md +++ b/content/flux/v0.x/stdlib/strings/islower.md @@ -1,44 +1,97 @@ --- title: strings.isLower() function -description: The strings.isLower() function tests if a single-character string is lowercase. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/islower/ - - /influxdb/v2.0/reference/flux/stdlib/strings/islower/ - - /influxdb/cloud/reference/flux/stdlib/strings/islower/ +description: > + `strings.isLower()` tests if a single-character string is lowercase. menu: flux_0_x_ref: name: strings.isLower parent: strings -weight: 301 -flux/v0.x/tags: [tests] -related: - - /flux/v0.x/stdlib/strings/isupper -introduced: 0.18.0 + identifier: strings/isLower +weight: 101 --- -The `strings.isLower()` function tests if a single-character string is lowercase. + + +`strings.isLower()` tests if a single-character string is lowercase. + + + +##### Function type signature ```js -import "strings" - -strings.isLower(v: "a") - -// returns true +(v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The single-character string value to test. +### v +({{< req >}}) +Single-character string value to test. + + + ## Examples -###### Filter by columns with single-letter lowercase values +### Filter by columns with single-letter lowercase values + ```js import "strings" data - |> filter(fn: (r) => strings.isLower(v: r.host)) + |> filter(fn: (r) => strings.isLower(v: r._value)) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T00:00:00Z | t1 | a | +| 2022-01-01T00:01:00Z | t1 | B | +| 2022-01-01T00:02:00Z | t1 | C | +| 2022-01-01T00:03:00Z | t1 | d | +| 2022-01-01T00:04:00Z | t1 | e | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T00:00:00Z | t2 | F | +| 2022-01-01T00:01:00Z | t2 | g | +| 2022-01-01T00:02:00Z | t2 | H | +| 2022-01-01T00:03:00Z | t2 | i | +| 2022-01-01T00:04:00Z | t2 | J | + + +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T00:00:00Z | t1 | a | +| 2022-01-01T00:03:00Z | t1 | d | +| 2022-01-01T00:04:00Z | t1 | e | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T00:01:00Z | t2 | g | +| 2022-01-01T00:03:00Z | t2 | i | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/isupper.md b/content/flux/v0.x/stdlib/strings/isupper.md index 315e3f632..3f7e9c4c9 100644 --- a/content/flux/v0.x/stdlib/strings/isupper.md +++ b/content/flux/v0.x/stdlib/strings/isupper.md @@ -1,44 +1,97 @@ --- title: strings.isUpper() function -description: The strings.isUpper() function tests if a single character string is uppercase. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/isupper/ - - /influxdb/v2.0/reference/flux/stdlib/strings/isupper/ - - /influxdb/cloud/reference/flux/stdlib/strings/isupper/ +description: > + `strings.isUpper()` tests if a single character string is uppercase. menu: flux_0_x_ref: name: strings.isUpper parent: strings -weight: 301 -flux/v0.x/tags: [tests] -related: - - /flux/v0.x/stdlib/strings/islower -introduced: 0.18.0 + identifier: strings/isUpper +weight: 101 --- -The `strings.isUpper()` function tests if a single character string is uppercase. + + +`strings.isUpper()` tests if a single character string is uppercase. + + + +##### Function type signature ```js -import "strings" - -strings.isUpper(v: "A") - -// returns true +(v: string) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The single-character string value to test. +### v +({{< req >}}) +Single-character string value to test. + + + ## Examples -###### Filter by columns with single-letter uppercase values +### Filter by columns with single-letter uppercase values + ```js import "strings" data - |> filter(fn: (r) => strings.isUpper(v: r.host)) + |> filter(fn: (r) => strings.isUpper(v: r._value)) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T00:00:00Z | t1 | a | +| 2022-01-01T00:01:00Z | t1 | B | +| 2022-01-01T00:02:00Z | t1 | C | +| 2022-01-01T00:03:00Z | t1 | d | +| 2022-01-01T00:04:00Z | t1 | e | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T00:00:00Z | t2 | F | +| 2022-01-01T00:01:00Z | t2 | g | +| 2022-01-01T00:02:00Z | t2 | H | +| 2022-01-01T00:03:00Z | t2 | i | +| 2022-01-01T00:04:00Z | t2 | J | + + +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T00:01:00Z | t1 | B | +| 2022-01-01T00:02:00Z | t1 | C | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T00:00:00Z | t2 | F | +| 2022-01-01T00:02:00Z | t2 | H | +| 2022-01-01T00:04:00Z | t2 | J | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/joinstr.md b/content/flux/v0.x/stdlib/strings/joinstr.md index 6f54ae220..7803978cf 100644 --- a/content/flux/v0.x/stdlib/strings/joinstr.md +++ b/content/flux/v0.x/stdlib/strings/joinstr.md @@ -1,48 +1,66 @@ --- title: strings.joinStr() function description: > - The strings.joinStr() function concatenates the elements of a string array into - a single string using a specified separator. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/joinstr/ - - /influxdb/v2.0/reference/flux/stdlib/strings/joinstr/ - - /influxdb/cloud/reference/flux/stdlib/strings/joinstr/ + `strings.joinStr()` concatenates elements of a string array into a single string using a specified separator. menu: flux_0_x_ref: name: strings.joinStr parent: strings -weight: 301 -introduced: 0.18.0 + identifier: strings/joinStr +weight: 101 --- -The `strings.joinStr()` function concatenates elements of a string array into -a single string using a specified separator. + + +`strings.joinStr()` concatenates elements of a string array into a single string using a specified separator. + + + +##### Function type signature ```js -import "strings" - -strings.joinStr(arr: ["a", "b", "c"], v: ",") - -// returns "a,b,c" +(arr: [string], v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### arr {data-type="array of strings"} -The array of strings to concatenate. +### arr +({{< req >}}) +Array of strings to concatenate. + + + +### v +({{< req >}}) +Separator to use in the concatenated value. + + -### v {data-type="string"} -The separator to use in the concatenated value. ## Examples -###### Join a list of strings into a single string +### Join a list of strings into a single string + ```js import "strings" -searchTags = ["tag1", "tag2", "tag3"] +strings.joinStr(arr: ["foo", "bar", "baz", "quz"], v: ", ")// Returns "foo, bar, baz, quz" -strings.joinStr(arr: searchTags, v: ",")) ``` + diff --git a/content/flux/v0.x/stdlib/strings/lastindex.md b/content/flux/v0.x/stdlib/strings/lastindex.md index afcc33cf4..af17007c3 100644 --- a/content/flux/v0.x/stdlib/strings/lastindex.md +++ b/content/flux/v0.x/stdlib/strings/lastindex.md @@ -1,51 +1,115 @@ --- title: strings.lastIndex() function description: > - The strings.lastIndex() function returns the index of the last instance of a substring - in a string or `-1` if substring is not present. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/lastindex/ - - /influxdb/v2.0/reference/flux/stdlib/strings/lastindex/ - - /influxdb/cloud/reference/flux/stdlib/strings/lastindex/ + `strings.lastIndex()` returns the index of the last instance of a substring in a string. + If the substring is not present, the function returns -1. menu: flux_0_x_ref: name: strings.lastIndex parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/index/ - - /flux/v0.x/stdlib/strings/indexany/ - - /flux/v0.x/stdlib/strings/lastindexany/ -introduced: 0.18.0 + identifier: strings/lastIndex +weight: 101 --- -The `strings.lastIndex()` function returns the index of the last instance of a substring -in a string. If the substring is not present, the function returns `-1`. + + +`strings.lastIndex()` returns the index of the last instance of a substring in a string. +If the substring is not present, the function returns -1. + + + +##### Function type signature ```js -import "strings" - -strings.lastIndex(v: "go gopher", substr: "go") - -// returns 3 +(substr: string, v: string) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search. + + + +### substr +({{< req >}}) +Substring to search for. + + -### substr {data-type="string"} -The substring to search for. ## Examples -###### Find the last occurrence of a substring +### Find the index of the last occurrence of a substring + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with the_index: strings.lastIndex(v: r.pageTitle, substr: "the")})) +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.lastIndex(v: r._value, substr: "g")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 5 | t1 | +| 2021-01-01T00:00:10Z | 7 | t1 | +| 2021-01-01T00:00:20Z | -1 | t1 | +| 2021-01-01T00:00:30Z | 5 | t1 | +| 2021-01-01T00:00:40Z | -1 | t1 | +| 2021-01-01T00:00:50Z | 9 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -1 | t2 | +| 2021-01-01T00:00:10Z | -1 | t2 | +| 2021-01-01T00:00:20Z | 6 | t2 | +| 2021-01-01T00:00:30Z | -1 | t2 | +| 2021-01-01T00:00:40Z | -1 | t2 | +| 2021-01-01T00:00:50Z | -1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/lastindexany.md b/content/flux/v0.x/stdlib/strings/lastindexany.md index 6f14fc381..c78ad51c4 100644 --- a/content/flux/v0.x/stdlib/strings/lastindexany.md +++ b/content/flux/v0.x/stdlib/strings/lastindexany.md @@ -1,49 +1,117 @@ --- title: strings.lastIndexAny() function -description: The `strings.lastIndexAny()` function returns the index of the last instance of any specified characters in a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/lastindexany/ - - /influxdb/v2.0/reference/flux/stdlib/strings/lastindexany/ - - /influxdb/cloud/reference/flux/stdlib/strings/lastindexany/ +description: > + `strings.lastIndexAny()` returns the index of the last instance of any specified + characters in a string. + If none of the specified characters are present, the function returns `-1`. menu: flux_0_x_ref: name: strings.lastIndexAny parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/index/ - - /flux/v0.x/stdlib/strings/indexany/ - - /flux/v0.x/stdlib/strings/lastindex/ -introduced: 0.18.0 + identifier: strings/lastIndexAny +weight: 101 --- -The `strings.lastIndexAny()` function returns the index of the last instance of any specified characters in a string. + + +`strings.lastIndexAny()` returns the index of the last instance of any specified +characters in a string. If none of the specified characters are present, the function returns `-1`. -_**Output data type:** Integer_ + + +##### Function type signature ```js -import "strings" - -strings.lastIndexAny(v: "chicken", chars: "aeiouy") - -// returns 5 +(chars: string, v: string) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search. -### chars {data-type="string"} + + +### chars +({{< req >}}) Characters to search for. + + + ## Examples -###### Find the last occurrence of characters from a string +### Find the index of the last occurrence of characters from a string + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with charLastIndex: strings.lastIndexAny(v: r._field, chars: "_-")})) +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.lastIndexAny(v: r._value, chars: "g7t")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 5 | t1 | +| 2021-01-01T00:00:10Z | 7 | t1 | +| 2021-01-01T00:00:20Z | -1 | t1 | +| 2021-01-01T00:00:30Z | 5 | t1 | +| 2021-01-01T00:00:40Z | -1 | t1 | +| 2021-01-01T00:00:50Z | 9 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -1 | t2 | +| 2021-01-01T00:00:10Z | -1 | t2 | +| 2021-01-01T00:00:20Z | 8 | t2 | +| 2021-01-01T00:00:30Z | 10 | t2 | +| 2021-01-01T00:00:40Z | 10 | t2 | +| 2021-01-01T00:00:50Z | 6 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/repeat.md b/content/flux/v0.x/stdlib/strings/repeat.md index 5b2a88498..607e24584 100644 --- a/content/flux/v0.x/stdlib/strings/repeat.md +++ b/content/flux/v0.x/stdlib/strings/repeat.md @@ -1,49 +1,112 @@ --- title: strings.repeat() function -description: The strings.repeat() function returns a string consisting of `i` copies of a specified string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/repeat/ - - /influxdb/v2.0/reference/flux/stdlib/strings/repeat/ - - /influxdb/cloud/reference/flux/stdlib/strings/repeat/ +description: > + `strings.repeat()` returns a string consisting of `i` copies of a specified string. menu: flux_0_x_ref: name: strings.repeat parent: strings -weight: 301 -introduced: 0.18.0 + identifier: strings/repeat +weight: 101 --- -The `strings.repeat()` function returns a string consisting of `i` copies of a specified string. + + +`strings.repeat()` returns a string consisting of `i` copies of a specified string. + + + +##### Function type signature ```js -import "strings" - -strings.repeat(v: "ha", i: 3) - -// returns "hahaha" +(i: int, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to repeat. +### v +({{< req >}}) +String value to repeat. + + + +### i +({{< req >}}) +Number of times to repeat `v`. + + -### i {data-type="int"} -The number of times to repeat `v`. ## Examples -###### Repeat a string based on existing columns +### Repeat a string based on existing columns + ```js import "strings" data - |> map(fn: (r) => ({ - laugh: r.laugh, - intensity: r.intensity, - laughter: strings.repeat(v: r.laugh, i: r.intensity), - }) - ) + |> map(fn: (r) => ({r with _value: strings.repeat(v: "ha", i: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 5 | t1 | +| 2021-01-01T00:00:20Z | 3 | t1 | +| 2021-01-01T00:00:30Z | 8 | t1 | +| 2021-01-01T00:00:40Z | 7 | t1 | +| 2021-01-01T00:00:50Z | 2 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 9 | t2 | +| 2021-01-01T00:00:10Z | 2 | t2 | +| 2021-01-01T00:00:20Z | 1 | t2 | +| 2021-01-01T00:00:30Z | 9 | t2 | +| 2021-01-01T00:00:40Z | 6 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ---------------- | ---- | +| 2021-01-01T00:00:00Z | ha | t1 | +| 2021-01-01T00:00:10Z | hahahahaha | t1 | +| 2021-01-01T00:00:20Z | hahaha | t1 | +| 2021-01-01T00:00:30Z | hahahahahahahaha | t1 | +| 2021-01-01T00:00:40Z | hahahahahahaha | t1 | +| 2021-01-01T00:00:50Z | haha | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | hahahahahahahahaha | t2 | +| 2021-01-01T00:00:10Z | haha | t2 | +| 2021-01-01T00:00:20Z | ha | t2 | +| 2021-01-01T00:00:30Z | hahahahahahahahaha | t2 | +| 2021-01-01T00:00:40Z | hahahahahaha | t2 | +| 2021-01-01T00:00:50Z | | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/replace.md b/content/flux/v0.x/stdlib/strings/replace.md index ab39c25ca..de92e1ded 100644 --- a/content/flux/v0.x/stdlib/strings/replace.md +++ b/content/flux/v0.x/stdlib/strings/replace.md @@ -1,55 +1,127 @@ --- title: strings.replace() function description: > - The strings.replace() function replaces the first `i` non-overlapping instances - of a substring with a specified replacement. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/replace/ - - /influxdb/v2.0/reference/flux/stdlib/strings/replace/ - - /influxdb/cloud/reference/flux/stdlib/strings/replace/ + `strings.replace()` replaces the first `i` non-overlapping instances of a substring with + a specified replacement. menu: flux_0_x_ref: name: strings.replace parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/replaceall -introduced: 0.18.0 + identifier: strings/replace +weight: 101 --- -The `strings.replace()` function replaces the first `i` non-overlapping instances -of a substring with a specified replacement. + + +`strings.replace()` replaces the first `i` non-overlapping instances of a substring with +a specified replacement. + + + +##### Function type signature ```js -import "strings" - -strings.replace(v: "oink oink oink", t: "oink", u: "moo", i: 2) - -// returns "moo moo oink" +(i: int, t: string, u: string, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters ### v -The string value to search. +({{< req >}}) +String value to search. + + + +### t +({{< req >}}) +Substring value to replace. + + + +### u +({{< req >}}) +Replacement for `i` instances of `t`. + + + +### i +({{< req >}}) +Number of non-overlapping `t` matches to replace. -### t {data-type="string"} -The substring value to replace. -### u {data-type="string"} -The replacement for `i` instances of `t`. -### i {data-type="int"} -The number of non-overlapping `t` matches to replace. ## Examples -###### Replace a specific number of string matches +### Replace a specific number of string matches + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with content: strings.replace(v: r.content, t: "he", u: "her", i: 3)})) +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.replace(v: r._value, t: "p", u: "XX", i: 2)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | smXXl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | smXXl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | smXXl_XXhw664 | t1 | +| 2021-01-01T00:00:30Z | smXXl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | smXXl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | smXXl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | smXXl_b5eida | t2 | +| 2021-01-01T00:00:10Z | smXXl_eu4oxXX | t2 | +| 2021-01-01T00:00:20Z | smXXl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | smXXl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | smXXl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | smXXl_dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/replaceall.md b/content/flux/v0.x/stdlib/strings/replaceall.md index e7f3a7d49..f62c71334 100644 --- a/content/flux/v0.x/stdlib/strings/replaceall.md +++ b/content/flux/v0.x/stdlib/strings/replaceall.md @@ -1,52 +1,119 @@ --- title: strings.replaceAll() function description: > - The strings.replaceAll() function replaces all non-overlapping instances of a - substring with a specified replacement. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/replaceall/ - - /influxdb/v2.0/reference/flux/stdlib/strings/replaceall/ - - /influxdb/cloud/reference/flux/stdlib/strings/replaceall/ + `strings.replaceAll()` replaces all non-overlapping instances of a substring with a specified replacement. menu: flux_0_x_ref: name: strings.replaceAll parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/replace -introduced: 0.18.0 + identifier: strings/replaceAll +weight: 101 --- -The `strings.replaceAll()` function replaces all non-overlapping instances of a -substring with a specified replacement. + + +`strings.replaceAll()` replaces all non-overlapping instances of a substring with a specified replacement. + + + +##### Function type signature ```js -import "strings" - -strings.replaceAll(v: "oink oink oink", t: "oink", u: "moo") - -// returns "moo moo moo" +(t: string, u: string, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search. + + + +### t +({{< req >}}) +Substring to replace. + + + +### u +({{< req >}}) +Replacement for all instances of `t`. + -### t {data-type="string"} -The substring to replace. -### u {data-type="string"} -The replacement for all instances of `t`. ## Examples -###### Replace string matches +### Replace string matches + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with content: strings.replaceAll(v: r.content, t: "he", u: "her")})) +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.replaceAll(v: r._value, t: "p", u: "XX")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | smXXl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | smXXl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | smXXl_XXhw664 | t1 | +| 2021-01-01T00:00:30Z | smXXl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | smXXl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | smXXl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | smXXl_b5eida | t2 | +| 2021-01-01T00:00:10Z | smXXl_eu4oxXX | t2 | +| 2021-01-01T00:00:20Z | smXXl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | smXXl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | smXXl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | smXXl_dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/split.md b/content/flux/v0.x/stdlib/strings/split.md index 1e5e5c9e6..47a1693fb 100644 --- a/content/flux/v0.x/stdlib/strings/split.md +++ b/content/flux/v0.x/stdlib/strings/split.md @@ -1,51 +1,66 @@ --- title: strings.split() function description: > - The strings.split() function splits a string on a specified separator and returns - an array of substrings. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/split/ - - /influxdb/v2.0/reference/flux/stdlib/strings/split/ - - /influxdb/cloud/reference/flux/stdlib/strings/split/ + `strings.split()` splits a string on a specified separator and returns an array of substrings. menu: flux_0_x_ref: name: strings.split parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/splitafter - - /flux/v0.x/stdlib/strings/splitaftern - - /flux/v0.x/stdlib/strings/splitn -introduced: 0.18.0 + identifier: strings/split +weight: 101 --- -The `strings.split()` function splits a string on a specified separator and returns -an array of substrings. + + +`strings.split()` splits a string on a specified separator and returns an array of substrings. + + + +##### Function type signature ```js -import "strings" - -strings.split(v: "a flux of foxes", t: " ") - -// returns ["a", "flux", "of", "foxes"] +(t: string, v: string) => [string] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to split. +### v +({{< req >}}) +String value to split. + + + +### t +({{< req >}}) +String value that acts as the separator. + + -### t {data-type="string"} -The string value that acts as the separator. ## Examples -###### Split a string into an array of substrings +### Split a string into an array of substrings + ```js import "strings" -data - |> map (fn:(r) => strings.split(v: r.searchTags, t: ",")) +strings.split(v: "foo, bar, baz, quz", t: ", ")// Returns ["foo", "bar", "baz", "quz"] + ``` + diff --git a/content/flux/v0.x/stdlib/strings/splitafter.md b/content/flux/v0.x/stdlib/strings/splitafter.md index 0a44a65a1..76e92c207 100644 --- a/content/flux/v0.x/stdlib/strings/splitafter.md +++ b/content/flux/v0.x/stdlib/strings/splitafter.md @@ -1,52 +1,68 @@ --- title: strings.splitAfter() function description: > - The strings.splitAfter() function splits a string after a specified separator and returns - an array of substrings. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/splitafter/ - - /influxdb/v2.0/reference/flux/stdlib/strings/splitafter/ - - /influxdb/cloud/reference/flux/stdlib/strings/splitafter/ + `strings.splitAfter()` splits a string after a specified separator and returns an array of substrings. + Split substrings include the separator, `t`. menu: flux_0_x_ref: name: strings.splitAfter parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/split - - /flux/v0.x/stdlib/strings/splitaftern - - /flux/v0.x/stdlib/strings/splitn -introduced: 0.18.0 + identifier: strings/splitAfter +weight: 101 --- -The `strings.splitAfter()` function splits a string after a specified separator and returns -an array of substrings. + + +`strings.splitAfter()` splits a string after a specified separator and returns an array of substrings. Split substrings include the separator, `t`. -_**Output data type:** Array of strings_ + + +##### Function type signature ```js -import "strings" - -strings.splitAfter(v: "a flux of foxes", t: " ") - -// returns ["a ", "flux ", "of ", "foxes"] +(t: string, v: string) => [string] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to split. +### v +({{< req >}}) +String value to split. + + + +### t +({{< req >}}) +String value that acts as the separator. + + -### t {data-type="string"} -The string value that acts as the separator. ## Examples -###### Split a string into an array of substrings +### Split a string into an array of substrings + ```js import "strings" -data - |> map (fn:(r) => strings.splitAfter(v: r.searchTags, t: ",")) +strings.splitAfter(v: "foo, bar, baz, quz", t: ", ")// Returns ["foo, ", "bar, ", "baz, ", "quz"] + ``` + diff --git a/content/flux/v0.x/stdlib/strings/splitaftern.md b/content/flux/v0.x/stdlib/strings/splitaftern.md index 2894ec4c5..a8087511a 100644 --- a/content/flux/v0.x/stdlib/strings/splitaftern.md +++ b/content/flux/v0.x/stdlib/strings/splitaftern.md @@ -1,57 +1,75 @@ --- title: strings.splitAfterN() function description: > - The strings.splitAfterN() function splits a string after a specified separator and returns - an array of `i` substrings. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/splitaftern/ - - /influxdb/v2.0/reference/flux/stdlib/strings/splitaftern/ - - /influxdb/cloud/reference/flux/stdlib/strings/splitaftern/ + `strings.splitAfterN()` splits a string after a specified separator and returns an array of `i` substrings. + Split substrings include the separator, `t`. menu: flux_0_x_ref: name: strings.splitAfterN parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/split - - /flux/v0.x/stdlib/strings/splitafter - - /flux/v0.x/stdlib/strings/splitn -introduced: 0.18.0 + identifier: strings/splitAfterN +weight: 101 --- -The `strings.splitAfterN()` function splits a string after a specified separator and returns -an array of `i` substrings. -Split substrings include the separator `t`. + + +`strings.splitAfterN()` splits a string after a specified separator and returns an array of `i` substrings. +Split substrings include the separator, `t`. + + + +##### Function type signature ```js -import "strings" - -strings.splitAfterN(v: "a flux of foxes", t: " ", i: 3) - -// returns ["a ", "flux ", "of foxes"] +(i: int, t: string, v: string) => [string] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to split. +### v +({{< req >}}) +String value to split. -### t {data-type="string"} -The string value that acts as the separator. -### i {data-type="int"} -The maximum number of split substrings to return. + +### t +({{< req >}}) +String value that acts as the separator. + + + +### i +({{< req >}}) +Maximum number of split substrings to return. + `-1` returns all matching substrings. The last substring is the unsplit remainder. + ## Examples -###### Split a string into an array of substrings +### Split a string into an array of substrings + ```js import "strings" -data - |> map (fn:(r) => strings.splitAfterN(v: r.searchTags, t: ",")) +strings.splitAfterN(v: "foo, bar, baz, quz", t: ", ", i: 3)// Returns ["foo, ", "bar, ", "baz, quz"] + ``` + diff --git a/content/flux/v0.x/stdlib/strings/splitn.md b/content/flux/v0.x/stdlib/strings/splitn.md index f9984c2b9..921d0e56e 100644 --- a/content/flux/v0.x/stdlib/strings/splitn.md +++ b/content/flux/v0.x/stdlib/strings/splitn.md @@ -1,56 +1,73 @@ --- title: strings.splitN() function description: > - The strings.splitN() function splits a string on a specified separator and returns - an array of `i` substrings. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/splitn/ - - /influxdb/v2.0/reference/flux/stdlib/strings/splitn/ - - /influxdb/cloud/reference/flux/stdlib/strings/splitn/ + `strings.splitN()` splits a string on a specified separator and returns an array of `i` substrings. menu: flux_0_x_ref: name: strings.splitN parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/split - - /flux/v0.x/stdlib/strings/splitafter - - /flux/v0.x/stdlib/strings/splitaftern -introduced: 0.18.0 + identifier: strings/splitN +weight: 101 --- -The `strings.splitN()` function splits a string on a specified separator and returns -an array of `i` substrings. + + +`strings.splitN()` splits a string on a specified separator and returns an array of `i` substrings. + + + +##### Function type signature ```js -import "strings" - -strings.splitN(v: "a flux of foxes", t: " ", i: 3) - -// returns ["a", "flux", "of foxes"] +(i: int, t: string, v: string) => [string] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to split. +### v +({{< req >}}) +String value to split. -### t {data-type="string"} -The string value that acts as the separator. -### i {data-type="int"} -The maximum number of split substrings to return. + +### t +({{< req >}}) +String value that acts as the separator. + + + +### i +({{< req >}}) +Maximum number of split substrings to return. + `-1` returns all matching substrings. The last substring is the unsplit remainder. + ## Examples -###### Split a string into an array of substrings +### Split a string into an array of substrings + ```js import "strings" -data - |> map (fn:(r) => strings.splitN(v: r.searchTags, t: ",")) +strings.splitN(v: "foo, bar, baz, quz", t: ", ", i: 3)// Returns ["foo", "bar", "baz, quz"] + ``` + diff --git a/content/flux/v0.x/stdlib/strings/strlen.md b/content/flux/v0.x/stdlib/strings/strlen.md index 1cbbe7684..341f142e7 100644 --- a/content/flux/v0.x/stdlib/strings/strlen.md +++ b/content/flux/v0.x/stdlib/strings/strlen.md @@ -1,52 +1,158 @@ --- title: strings.strlen() function description: > - The strings.strlen() function returns the length of a string. - String length is determined by the number of UTF code points a string contains. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/strlen/ - - /influxdb/v2.0/reference/flux/stdlib/strings/strlen/ - - /influxdb/cloud/reference/flux/stdlib/strings/strlen/ + `strings.strlen()` returns the length of a string. String length is determined by the number of UTF code points a string contains. menu: flux_0_x_ref: name: strings.strlen parent: strings -weight: 301 -introduced: 0.35.0 + identifier: strings/strlen +weight: 101 --- -The `strings.strlen()` function returns the length of a string. -String length is determined by the number of UTF code points a string contains. + + +`strings.strlen()` returns the length of a string. String length is determined by the number of UTF code points a string contains. + + + +##### Function type signature ```js -import "strings" - -strings.strlen(v: "apple") - -// returns 5 +(v: string) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to measure. +### v +({{< req >}}) +String value to measure. + + + ## Examples -###### Filter based on string value length +- [Filter based on string value length](#filter-based-on-string-value-length) +- [Store the length of string values](#store-the-length-of-string-values) + +### Filter based on string value length + ```js import "strings" data - |> filter(fn: (r) => strings.strlen(v: r._measurement) <= 4) + |> filter(fn: (r) => strings.strlen(v: r._value) <= 6) ``` -###### Store the length of string values +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------- | ---- | +| 2021-01-01T00:00:00Z | pl_gqcz | t1 | +| 2021-01-01T00:00:10Z | pl_gvn | t1 | +| 2021-01-01T00:00:20Z | pl_phw | t1 | +| 2021-01-01T00:00:30Z | pl_guvzy | t1 | +| 2021-01-01T00:00:40Z | pl_vcce | t1 | +| 2021-01-01T00:00:50Z | pl_fgy | t1 | + +| _time | _value | *tag | +| -------------------- | -------- | ---- | +| 2021-01-01T00:00:00Z | pl_beida | t2 | +| 2021-01-01T00:00:10Z | pl_euoxp | t2 | +| 2021-01-01T00:00:20Z | pl_gtz | t2 | +| 2021-01-01T00:00:30Z | pl_oxut | t2 | +| 2021-01-01T00:00:40Z | pl_wf | t2 | +| 2021-01-01T00:00:50Z | pl_dtnbv | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | pl_gvn | t1 | +| 2021-01-01T00:00:20Z | pl_phw | t1 | +| 2021-01-01T00:00:50Z | pl_fgy | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | pl_gtz | t2 | +| 2021-01-01T00:00:40Z | pl_wf | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Store the length of string values + ```js import "strings" data |> map(fn: (r) => ({r with length: strings.strlen(v: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------- | ---- | +| 2021-01-01T00:00:00Z | pl_gqcz | t1 | +| 2021-01-01T00:00:10Z | pl_gvn | t1 | +| 2021-01-01T00:00:20Z | pl_phw | t1 | +| 2021-01-01T00:00:30Z | pl_guvzy | t1 | +| 2021-01-01T00:00:40Z | pl_vcce | t1 | +| 2021-01-01T00:00:50Z | pl_fgy | t1 | + +| _time | _value | *tag | +| -------------------- | -------- | ---- | +| 2021-01-01T00:00:00Z | pl_beida | t2 | +| 2021-01-01T00:00:10Z | pl_euoxp | t2 | +| 2021-01-01T00:00:20Z | pl_gtz | t2 | +| 2021-01-01T00:00:30Z | pl_oxut | t2 | +| 2021-01-01T00:00:40Z | pl_wf | t2 | +| 2021-01-01T00:00:50Z | pl_dtnbv | t2 | + + +#### Output data + +| _time | _value | length | *tag | +| -------------------- | -------- | ------- | ---- | +| 2021-01-01T00:00:00Z | pl_gqcz | 7 | t1 | +| 2021-01-01T00:00:10Z | pl_gvn | 6 | t1 | +| 2021-01-01T00:00:20Z | pl_phw | 6 | t1 | +| 2021-01-01T00:00:30Z | pl_guvzy | 8 | t1 | +| 2021-01-01T00:00:40Z | pl_vcce | 7 | t1 | +| 2021-01-01T00:00:50Z | pl_fgy | 6 | t1 | + +| _time | _value | length | *tag | +| -------------------- | -------- | ------- | ---- | +| 2021-01-01T00:00:00Z | pl_beida | 8 | t2 | +| 2021-01-01T00:00:10Z | pl_euoxp | 8 | t2 | +| 2021-01-01T00:00:20Z | pl_gtz | 6 | t2 | +| 2021-01-01T00:00:30Z | pl_oxut | 7 | t2 | +| 2021-01-01T00:00:40Z | pl_wf | 5 | t2 | +| 2021-01-01T00:00:50Z | pl_dtnbv | 8 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/substring.md b/content/flux/v0.x/stdlib/strings/substring.md index 5aeefa5cc..e5f389921 100644 --- a/content/flux/v0.x/stdlib/strings/substring.md +++ b/content/flux/v0.x/stdlib/strings/substring.md @@ -1,48 +1,122 @@ --- title: strings.substring() function description: > - The strings.substring() function returns a substring based on `start` and `end` parameters. - Indices are based on UTF code points. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/substring/ - - /influxdb/v2.0/reference/flux/stdlib/strings/substring/ - - /influxdb/cloud/reference/flux/stdlib/strings/substring/ + `strings.substring()` returns a substring based on start and end parameters. These parameters are represent indices of UTF code points in the string. menu: flux_0_x_ref: name: strings.substring parent: strings -weight: 301 -introduced: 0.35.0 + identifier: strings/substring +weight: 101 --- -The `strings.substring()` function returns a substring based on `start` and `end` parameters. -These parameters are represent indices of UTF code points in the string. + + +`strings.substring()` returns a substring based on start and end parameters. These parameters are represent indices of UTF code points in the string. + + + +When start or end are past the bounds of the string, respecitvely the start or end of the string +is assumed. When end is less than or equal to start an empty string is returned. + +##### Function type signature ```js -import "strings" - -strings.substring(v: "influx", start: 0, end: 4) - -// returns "infl" +(end: int, start: int, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to search. +### v +({{< req >}}) +String value to search for. + + + +### start +({{< req >}}) +Starting inclusive index of the substring. + + + +### end +({{< req >}}) +Ending exclusive index of the substring. + -### start {data-type="int"} -The starting inclusive index of the substring. -### end {data-type="int"} -The ending exclusive index of the substring. ## Examples -###### Store the first four characters of a string +### Return part of a string based on character index + ```js -data - |> map(fn: (r) => ({r with abbr: strings.substring(v: r.name, start: 0, end: 4)})) +import "sampledata" +import "strings" + +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.substring(v: r._value, start: 5, end: 9)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | g9qc | t1 | +| 2021-01-01T00:00:10Z | 0mgv | t1 | +| 2021-01-01T00:00:20Z | phw6 | t1 | +| 2021-01-01T00:00:30Z | guvz | t1 | +| 2021-01-01T00:00:40Z | 5v3c | t1 | +| 2021-01-01T00:00:50Z | s9fm | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | b5ei | t2 | +| 2021-01-01T00:00:10Z | eu4o | t2 | +| 2021-01-01T00:00:20Z | 5g7t | t2 | +| 2021-01-01T00:00:30Z | sox1 | t2 | +| 2021-01-01T00:00:40Z | wfm7 | t2 | +| 2021-01-01T00:00:50Z | dtn2 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/title.md b/content/flux/v0.x/stdlib/strings/title.md index 22c13b3bf..a979a1d84 100644 --- a/content/flux/v0.x/stdlib/strings/title.md +++ b/content/flux/v0.x/stdlib/strings/title.md @@ -1,45 +1,107 @@ --- title: strings.title() function -description: The strings.title() function converts a string to title case. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/title/ - - /influxdb/v2.0/reference/flux/stdlib/strings/title/ - - /influxdb/cloud/reference/flux/stdlib/strings/title/ +description: > + `strings.title()` converts a string to title case. menu: flux_0_x_ref: name: strings.title parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/tolower - - /flux/v0.x/stdlib/strings/totitle - - /flux/v0.x/stdlib/strings/toupper -introduced: 0.18.0 + identifier: strings/title +weight: 101 --- -The `strings.title()` function converts a string to title case. + + +`strings.title()` converts a string to title case. + + + +##### Function type signature ```js -import "strings" - -strings.title(v: "a flux of foxes") - -// returns "A Flux Of Foxes" +(v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to convert. +### v +({{< req >}}) +String value to convert. + + + ## Examples -###### Convert all values of a column to title case +### Convert all values of a column to title case + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({ r with pageTitle: strings.title(v: r.pageTitle) })) +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.title(v: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | Smpl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | Smpl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | Smpl_phw664 | t1 | +| 2021-01-01T00:00:30Z | Smpl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | Smpl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | Smpl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | Smpl_b5eida | t2 | +| 2021-01-01T00:00:10Z | Smpl_eu4oxp | t2 | +| 2021-01-01T00:00:20Z | Smpl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | Smpl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | Smpl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | Smpl_dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/tolower.md b/content/flux/v0.x/stdlib/strings/tolower.md index a2f7df272..d3c124af4 100644 --- a/content/flux/v0.x/stdlib/strings/tolower.md +++ b/content/flux/v0.x/stdlib/strings/tolower.md @@ -1,45 +1,107 @@ --- title: strings.toLower() function -description: The strings.toLower() function converts a string to lowercase. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/tolower/ - - /influxdb/v2.0/reference/flux/stdlib/strings/tolower/ - - /influxdb/cloud/reference/flux/stdlib/strings/tolower/ +description: > + `strings.toLower()` converts a string to lowercase. menu: flux_0_x_ref: name: strings.toLower parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/totitle - - /flux/v0.x/stdlib/strings/toupper - - /flux/v0.x/stdlib/strings/title -introduced: 0.18.0 + identifier: strings/toLower +weight: 101 --- -The `strings.toLower()` function converts a string to lowercase. + + +`strings.toLower()` converts a string to lowercase. + + + +##### Function type signature ```js -import "strings" - -strings.toLower(v: "KOALA") - -// returns "koala" +(v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to convert. +### v +({{< req >}}) +String value to convert. + + + ## Examples -###### Convert all values of a column to lower case +### Convert all values of a column to lower case + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with exclamation: strings.toLower(v: r.exclamation)})) +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.toLower(v: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | smpl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | smpl_phw664 | t1 | +| 2021-01-01T00:00:30Z | smpl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | smpl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | smpl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_b5eida | t2 | +| 2021-01-01T00:00:10Z | smpl_eu4oxp | t2 | +| 2021-01-01T00:00:20Z | smpl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | smpl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | smpl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | smpl_dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/totitle.md b/content/flux/v0.x/stdlib/strings/totitle.md index 56b487056..59ba67f4e 100644 --- a/content/flux/v0.x/stdlib/strings/totitle.md +++ b/content/flux/v0.x/stdlib/strings/totitle.md @@ -1,58 +1,70 @@ --- title: strings.toTitle() function -description: The strings.toTitle() function converts all characters in a string to title case. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/totitle/ - - /influxdb/v2.0/reference/flux/stdlib/strings/totitle/ - - /influxdb/cloud/reference/flux/stdlib/strings/totitle/ +description: > + `strings.toTitle()` converts all characters in a string to title case. menu: flux_0_x_ref: name: strings.toTitle parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/toupper - - /flux/v0.x/stdlib/strings/tolower - - /flux/v0.x/stdlib/strings/title -introduced: 0.18.0 + identifier: strings/toTitle +weight: 101 --- -The `strings.toTitle()` function converts all characters in a string to title case. + -### v {data-type="string"} -The string value to convert. +`strings.toTitle()` converts all characters in a string to title case. -## Examples +#### toTitle vs toUpper +The results of `toTitle()` and `toUpper()` are often the same, however the +difference is visible when using special characters: -###### Covert characters in a string to title case -```js -import "strings" - -data - |> map(fn: (r) => ({ r with pageTitle: strings.toTitle(v: r.pageTitle) })) -``` - -{{% note %}} -#### The difference between toTitle and toUpper -The results of `toTitle()` and `toUpper` are often the same, however the difference -is visible with special characters: - -```js +```no_run str = "dz" strings.toTitle(v: str) // Returns Dz strings.toUpper(v: str) // Returns DZ ``` -{{% /note %}} + +##### Function type signature + +```js +(v: string) => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### v +({{< req >}}) +String value to convert. + + + + +## Examples + +### Convert characters in a string to title case + +```js +import "sampledata" +import "strings" + +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.toTitle(v: r._value)})) +``` + diff --git a/content/flux/v0.x/stdlib/strings/toupper.md b/content/flux/v0.x/stdlib/strings/toupper.md index 9870aea3c..420cf7247 100644 --- a/content/flux/v0.x/stdlib/strings/toupper.md +++ b/content/flux/v0.x/stdlib/strings/toupper.md @@ -1,58 +1,116 @@ --- title: strings.toUpper() function -description: The strings.toUpper() function converts a string to uppercase. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/toupper/ - - /influxdb/v2.0/reference/flux/stdlib/strings/toupper/ - - /influxdb/cloud/reference/flux/stdlib/strings/toupper/ +description: > + `strings.toUpper()` converts a string to uppercase. menu: flux_0_x_ref: name: strings.toUpper parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/totitle - - /flux/v0.x/stdlib/strings/tolower - - /flux/v0.x/stdlib/strings/title -introduced: 0.18.0 + identifier: strings/toUpper +weight: 101 --- -The `strings.toUpper()` function converts a string to uppercase. + -### v {data-type="string"} -The string value to convert. +`strings.toUpper()` converts a string to uppercase. -## Examples +#### toUpper vs toTitle +The results of `toUpper()` and `toTitle()` are often the same, however the +difference is visible when using special characters: -###### Convert all values of a column to upper case -```js -import "strings" - -data - |> map(fn: (r) => ({ r with envVars: strings.toUpper(v: r.envVars) })) -``` - -{{% note %}} -#### The difference between toTitle and toUpper -The results of `toUpper()` and `toTitle` are often the same, however the difference -is visible when using special characters: - -```js +```no_run str = "dz" strings.toUpper(v: str) // Returns DZ strings.toTitle(v: str) // Returns Dz ``` -{{% /note %}} + +##### Function type signature + +```js +(v: string) => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### v +({{< req >}}) +String value to convert. + + + + +## Examples + +### Convert all values of a column to upper case + +```js +import "sampledata" +import "strings" + +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.toUpper(v: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | SMPL_G9QCZS | t1 | +| 2021-01-01T00:00:10Z | SMPL_0MGV9N | t1 | +| 2021-01-01T00:00:20Z | SMPL_PHW664 | t1 | +| 2021-01-01T00:00:30Z | SMPL_GUVZY4 | t1 | +| 2021-01-01T00:00:40Z | SMPL_5V3CCE | t1 | +| 2021-01-01T00:00:50Z | SMPL_S9FMGY | t1 | + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | SMPL_B5EIDA | t2 | +| 2021-01-01T00:00:10Z | SMPL_EU4OXP | t2 | +| 2021-01-01T00:00:20Z | SMPL_5G7TZ4 | t2 | +| 2021-01-01T00:00:30Z | SMPL_SOX1UT | t2 | +| 2021-01-01T00:00:40Z | SMPL_WFM757 | t2 | +| 2021-01-01T00:00:50Z | SMPL_DTN2BV | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/trim.md b/content/flux/v0.x/stdlib/strings/trim.md index 20a3c0f56..9d92614c9 100644 --- a/content/flux/v0.x/stdlib/strings/trim.md +++ b/content/flux/v0.x/stdlib/strings/trim.md @@ -1,54 +1,112 @@ --- title: strings.trim() function description: > - The strings.trim() function removes leading and trailing characters specified - in the cutset from a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/trim/ - - /influxdb/v2.0/reference/flux/stdlib/strings/trim/ - - /influxdb/cloud/reference/flux/stdlib/strings/trim/ + `strings.trim()` removes leading and trailing characters specified in the cutset from a string. menu: flux_0_x_ref: name: strings.trim parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/trimleft - - /flux/v0.x/stdlib/strings/trimright - - /flux/v0.x/stdlib/strings/trimprefix - - /flux/v0.x/stdlib/strings/trimsuffix - - /flux/v0.x/stdlib/strings/trimspace -introduced: 0.18.0 + identifier: strings/trim +weight: 101 --- -The `strings.trim()` function removes leading and trailing characters specified -in the [`cutset`](#cutset) from a string. + + +`strings.trim()` removes leading and trailing characters specified in the cutset from a string. + + + +##### Function type signature ```js -import "strings" - -strings.trim(v: ".abc.", cutset: ".") - -// returns "abc" +(cutset: string, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} +### v +({{< req >}}) String to remove characters from. -### cutset {data-type="string"} -The leading and trailing characters to remove from the string. -Only characters that match the `cutset` string exactly are trimmed. + + +### cutset +({{< req >}}) +Leading and trailing characters to remove from the string. + +Only characters that match the cutset string exactly are trimmed. + ## Examples -###### Trim leading and trailing periods from all values in a column +### Trim leading and trailing periods from all values in a column + ```js import "strings" data - |> map(fn: (r) => ({r with variables: strings.trim(v: r.variables, cutset: ".")})) + |> map(fn: (r) => ({r with _value: strings.trim(v: r._value, cutset: "smpl_")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | .smpl_g9qczs. | t1 | +| 2021-01-01T00:00:10Z | .smpl_0mgv9n. | t1 | +| 2021-01-01T00:00:20Z | .smpl_phw664. | t1 | +| 2021-01-01T00:00:30Z | .smpl_guvzy4. | t1 | +| 2021-01-01T00:00:40Z | .smpl_5v3cce. | t1 | +| 2021-01-01T00:00:50Z | .smpl_s9fmgy. | t1 | + +| _time | _value | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | .smpl_b5eida. | t2 | +| 2021-01-01T00:00:10Z | .smpl_eu4oxp. | t2 | +| 2021-01-01T00:00:20Z | .smpl_5g7tz4. | t2 | +| 2021-01-01T00:00:30Z | .smpl_sox1ut. | t2 | +| 2021-01-01T00:00:40Z | .smpl_wfm757. | t2 | +| 2021-01-01T00:00:50Z | .smpl_dtn2bv. | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | .smpl_g9qczs. | t1 | +| 2021-01-01T00:00:10Z | .smpl_0mgv9n. | t1 | +| 2021-01-01T00:00:20Z | .smpl_phw664. | t1 | +| 2021-01-01T00:00:30Z | .smpl_guvzy4. | t1 | +| 2021-01-01T00:00:40Z | .smpl_5v3cce. | t1 | +| 2021-01-01T00:00:50Z | .smpl_s9fmgy. | t1 | + +| _time | _value | *tag | +| -------------------- | ------------- | ---- | +| 2021-01-01T00:00:00Z | .smpl_b5eida. | t2 | +| 2021-01-01T00:00:10Z | .smpl_eu4oxp. | t2 | +| 2021-01-01T00:00:20Z | .smpl_5g7tz4. | t2 | +| 2021-01-01T00:00:30Z | .smpl_sox1ut. | t2 | +| 2021-01-01T00:00:40Z | .smpl_wfm757. | t2 | +| 2021-01-01T00:00:50Z | .smpl_dtn2bv. | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/trimleft.md b/content/flux/v0.x/stdlib/strings/trimleft.md index a020f217d..11e1f4345 100644 --- a/content/flux/v0.x/stdlib/strings/trimleft.md +++ b/content/flux/v0.x/stdlib/strings/trimleft.md @@ -1,52 +1,112 @@ --- title: strings.trimLeft() function description: > - The strings.trimLeft() function removes specified leading characters from a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/trimleft/ - - /influxdb/v2.0/reference/flux/stdlib/strings/trimleft/ - - /influxdb/cloud/reference/flux/stdlib/strings/trimleft/ + `strings.trimLeft()` removes specified leading characters from a string. menu: flux_0_x_ref: name: strings.trimLeft parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/trim - - /flux/v0.x/stdlib/strings/trimright - - /flux/v0.x/stdlib/strings/trimprefix - - /flux/v0.x/stdlib/strings/trimsuffix - - /flux/v0.x/stdlib/strings/trimspace -introduced: 0.18.0 + identifier: strings/trimLeft +weight: 101 --- -The `strings.trimLeft()` function removes specified leading characters from a string. + + +`strings.trimLeft()` removes specified leading characters from a string. + + + +##### Function type signature ```js -import "strings" - -strings.trimLeft(v: ".abc.", cutset: ".") - -// returns "abc." +(cutset: string, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -String to remove characters from. +### v +({{< req >}}) +String to to remove characters from + + + +### cutset +({{< req >}}) +Leading characters to trim from the string. + + -### cutset {data-type="string"} -The leading characters to remove from the string. -Only characters that match the `cutset` string exactly are removed. ## Examples -###### Trim leading periods from all values in a column +### Trim leading periods from all values in a column + ```js import "strings" data - |> map(fn: (r) => ({r with variables: strings.trimLeft(v: r.variables, cutset: ".")})) + |> map(fn: (r) => ({r with _value: strings.trimLeft(v: r._value, cutset: ".")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------- | ---- | +| 2021-01-01T00:00:00Z | ...smpl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | ...smpl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | ...smpl_phw664 | t1 | +| 2021-01-01T00:00:30Z | ...smpl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | ...smpl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | ...smpl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | -------------- | ---- | +| 2021-01-01T00:00:00Z | ...smpl_b5eida | t2 | +| 2021-01-01T00:00:10Z | ...smpl_eu4oxp | t2 | +| 2021-01-01T00:00:20Z | ...smpl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | ...smpl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | ...smpl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | ...smpl_dtn2bv | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | smpl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | smpl_phw664 | t1 | +| 2021-01-01T00:00:30Z | smpl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | smpl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | smpl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_b5eida | t2 | +| 2021-01-01T00:00:10Z | smpl_eu4oxp | t2 | +| 2021-01-01T00:00:20Z | smpl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | smpl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | smpl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | smpl_dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/trimprefix.md b/content/flux/v0.x/stdlib/strings/trimprefix.md index 5048ebcc9..29e691eaa 100644 --- a/content/flux/v0.x/stdlib/strings/trimprefix.md +++ b/content/flux/v0.x/stdlib/strings/trimprefix.md @@ -1,53 +1,113 @@ --- title: strings.trimPrefix() function description: > - The `strings.trimPrefix()` function removes a prefix from a string. - Strings that do not start with the prefix are returned unchanged. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/trimprefix/ - - /influxdb/v2.0/reference/flux/stdlib/strings/trimprefix/ - - /influxdb/cloud/reference/flux/stdlib/strings/trimprefix/ + `strings.trimPrefix()` removes a prefix from a string. Strings that do not start with the prefix are returned unchanged. menu: flux_0_x_ref: name: strings.trimPrefix parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/trim - - /flux/v0.x/stdlib/strings/trimleft - - /flux/v0.x/stdlib/strings/trimright - - /flux/v0.x/stdlib/strings/trimsuffix - - /flux/v0.x/stdlib/strings/trimspace -introduced: 0.27.0 + identifier: strings/trimPrefix +weight: 101 --- -The `strings.trimPrefix()` function removes a prefix from a string. -Strings that do not start with the prefix are returned unchanged. + + +`strings.trimPrefix()` removes a prefix from a string. Strings that do not start with the prefix are returned unchanged. + + + +##### Function type signature ```js -import "strings" - -strings.trimPrefix(v: "123_abc", prefix: "123") - -// returns "_abc" +(prefix: string, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to trim. +### v +({{< req >}}) +String to trim. + + + +### prefix +({{< req >}}) +Prefix to remove. + + -### prefix {data-type="string"} -The prefix to remove. ## Examples -###### Remove a prefix from all values in a column +### Trim a prefix from all values in a column + ```js +import "sampledata" import "strings" -data - |> map(fn: (r) => ({r with sensorID: strings.trimPrefix(v: r.sensorId, prefix: "s12_")})) +sampledata.string() + |> map(fn: (r) => ({r with _value: strings.trimPrefix(v: r._value, prefix: "smpl_")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | smpl_g9qczs | +| 2021-01-01T00:00:10Z | t1 | smpl_0mgv9n | +| 2021-01-01T00:00:20Z | t1 | smpl_phw664 | +| 2021-01-01T00:00:30Z | t1 | smpl_guvzy4 | +| 2021-01-01T00:00:40Z | t1 | smpl_5v3cce | +| 2021-01-01T00:00:50Z | t1 | smpl_s9fmgy | + +| _time | *tag | _value | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | smpl_b5eida | +| 2021-01-01T00:00:10Z | t2 | smpl_eu4oxp | +| 2021-01-01T00:00:20Z | t2 | smpl_5g7tz4 | +| 2021-01-01T00:00:30Z | t2 | smpl_sox1ut | +| 2021-01-01T00:00:40Z | t2 | smpl_wfm757 | +| 2021-01-01T00:00:50Z | t2 | smpl_dtn2bv | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | g9qczs | t1 | +| 2021-01-01T00:00:10Z | 0mgv9n | t1 | +| 2021-01-01T00:00:20Z | phw664 | t1 | +| 2021-01-01T00:00:30Z | guvzy4 | t1 | +| 2021-01-01T00:00:40Z | 5v3cce | t1 | +| 2021-01-01T00:00:50Z | s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | b5eida | t2 | +| 2021-01-01T00:00:10Z | eu4oxp | t2 | +| 2021-01-01T00:00:20Z | 5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | sox1ut | t2 | +| 2021-01-01T00:00:40Z | wfm757 | t2 | +| 2021-01-01T00:00:50Z | dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/trimright.md b/content/flux/v0.x/stdlib/strings/trimright.md index 4d1779a39..2dc1f196e 100644 --- a/content/flux/v0.x/stdlib/strings/trimright.md +++ b/content/flux/v0.x/stdlib/strings/trimright.md @@ -1,53 +1,112 @@ --- title: strings.trimRight() function description: > - The strings.trimRight() function removes trailing characters specified in the cutset from a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/trimright/ - - /influxdb/v2.0/reference/flux/stdlib/strings/trimright/ - - /influxdb/cloud/reference/flux/stdlib/strings/trimright/ + `strings.trimRight()` removes trailing characters specified in the cutset from a string. menu: flux_0_x_ref: name: strings.trimRight parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/trim - - /flux/v0.x/stdlib/strings/trimleft - - /flux/v0.x/stdlib/strings/trimprefix - - /flux/v0.x/stdlib/strings/trimsuffix - - /flux/v0.x/stdlib/strings/trimspace -introduced: 0.18.0 + identifier: strings/trimRight +weight: 101 --- -The `strings.trimRight()` function removes trailing characters specified in the -[`cutset`](#cutset) from a string. + + +`strings.trimRight()` removes trailing characters specified in the cutset from a string. + + + +##### Function type signature ```js -import "strings" - -strings.trimRight(v: ".abc.", cutset: ".") - -// returns ".abc" +(cutset: string, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -String to remove characters from. +### v +({{< req >}}) +String to to remove characters from + + + +### cutset +({{< req >}}) +Trailing characters to trim from the string. + +Only characters that match the cutset string exactly are trimmed. -### cutset {data-type="string"} -The trailing characters to trim from the string. -Only characters that match the `cutset` string exactly are trimmed. ## Examples -###### Trim trailing periods from all values in a column +### Trim trailing periods from all values in a column + ```js import "strings" data - |> map(fn: (r) => ({r with variables: strings.trimRight(v: r.variables, cutset: ".")})) + |> map(fn: (r) => ({r with _value: strings.trimRight(v: r._value, cutset: ".")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | -------------- | ---- | +| 2021-01-01T00:00:00Z | smpl_g9qczs... | t1 | +| 2021-01-01T00:00:10Z | smpl_0mgv9n... | t1 | +| 2021-01-01T00:00:20Z | smpl_phw664... | t1 | +| 2021-01-01T00:00:30Z | smpl_guvzy4... | t1 | +| 2021-01-01T00:00:40Z | smpl_5v3cce... | t1 | +| 2021-01-01T00:00:50Z | smpl_s9fmgy... | t1 | + +| _time | _value | *tag | +| -------------------- | -------------- | ---- | +| 2021-01-01T00:00:00Z | smpl_b5eida... | t2 | +| 2021-01-01T00:00:10Z | smpl_eu4oxp... | t2 | +| 2021-01-01T00:00:20Z | smpl_5g7tz4... | t2 | +| 2021-01-01T00:00:30Z | smpl_sox1ut... | t2 | +| 2021-01-01T00:00:40Z | smpl_wfm757... | t2 | +| 2021-01-01T00:00:50Z | smpl_dtn2bv... | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | smpl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | smpl_phw664 | t1 | +| 2021-01-01T00:00:30Z | smpl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | smpl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | smpl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_b5eida | t2 | +| 2021-01-01T00:00:10Z | smpl_eu4oxp | t2 | +| 2021-01-01T00:00:20Z | smpl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | smpl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | smpl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | smpl_dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/trimspace.md b/content/flux/v0.x/stdlib/strings/trimspace.md index c56a7462e..2583cacdf 100644 --- a/content/flux/v0.x/stdlib/strings/trimspace.md +++ b/content/flux/v0.x/stdlib/strings/trimspace.md @@ -1,47 +1,106 @@ --- title: strings.trimSpace() function -description: The strings.trimSpace() function removes leading and trailing spaces from a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/trimspace/ - - /influxdb/v2.0/reference/flux/stdlib/strings/trimspace/ - - /influxdb/cloud/reference/flux/stdlib/strings/trimspace/ +description: > + `strings.trimSpace()` removes leading and trailing spaces from a string. menu: flux_0_x_ref: name: strings.trimSpace parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/trim - - /flux/v0.x/stdlib/strings/trimleft - - /flux/v0.x/stdlib/strings/trimright - - /flux/v0.x/stdlib/strings/trimprefix - - /flux/v0.x/stdlib/strings/trimsuffix -introduced: 0.18.0 + identifier: strings/trimSpace +weight: 101 --- -The `strings.trimSpace()` function removes leading and trailing spaces from a string. + + +`strings.trimSpace()` removes leading and trailing spaces from a string. + + + +##### Function type signature ```js -import "strings" - -strings.trimSpace(v: " abc ") - -// returns "abc" +(v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} +### v +({{< req >}}) String to remove spaces from. + + + ## Examples -###### Trim leading and trailing spaces from all values in a column +### Trim leading and trailing spaces from all values in a column + ```js import "strings" data - |> map(fn: (r) => ({ r with userInput: strings.trimSpace(v: r.userInput) })) + |> map(fn: (r) => ({r with _value: strings.trimSpace(v: r._value)})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ----------------- | ---- | +| 2021-01-01T00:00:00Z | smpl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | smpl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | smpl_phw664 | t1 | +| 2021-01-01T00:00:30Z | smpl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | smpl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | smpl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ----------------- | ---- | +| 2021-01-01T00:00:00Z | smpl_b5eida | t2 | +| 2021-01-01T00:00:10Z | smpl_eu4oxp | t2 | +| 2021-01-01T00:00:20Z | smpl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | smpl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | smpl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | smpl_dtn2bv | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | smpl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | smpl_phw664 | t1 | +| 2021-01-01T00:00:30Z | smpl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | smpl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | smpl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_b5eida | t2 | +| 2021-01-01T00:00:10Z | smpl_eu4oxp | t2 | +| 2021-01-01T00:00:20Z | smpl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | smpl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | smpl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | smpl_dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/strings/trimsuffix.md b/content/flux/v0.x/stdlib/strings/trimsuffix.md index 287b3bc04..3daad00e5 100644 --- a/content/flux/v0.x/stdlib/strings/trimsuffix.md +++ b/content/flux/v0.x/stdlib/strings/trimsuffix.md @@ -1,53 +1,112 @@ --- title: strings.trimSuffix() function description: > - The `strings.trimSuffix()` function removes a suffix from a string. - Strings that do not end with the suffix are returned unchanged. -aliases: - - /influxdb/v2.0/reference/flux/functions/strings/trimsuffix/ - - /influxdb/v2.0/reference/flux/stdlib/strings/trimsuffix/ - - /influxdb/cloud/reference/flux/stdlib/strings/trimsuffix/ + `strings.trimSuffix()` removes a suffix from a string. menu: flux_0_x_ref: name: strings.trimSuffix parent: strings -weight: 301 -related: - - /flux/v0.x/stdlib/strings/trim - - /flux/v0.x/stdlib/strings/trimleft - - /flux/v0.x/stdlib/strings/trimright - - /flux/v0.x/stdlib/strings/trimprefix - - /flux/v0.x/stdlib/strings/trimspace -introduced: 0.27.0 + identifier: strings/trimSuffix +weight: 101 --- -The `strings.trimSuffix()` function removes a suffix from a string. + + +`strings.trimSuffix()` removes a suffix from a string. + Strings that do not end with the suffix are returned unchanged. -_**Output data type:** String_ +##### Function type signature ```js -import "strings" - -strings.trimSuffix(v: "123_abc", suffix: "abc") - -// returns "123_" +(suffix: string, v: string) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The string value to trim. +### v +({{< req >}}) +String to trim + + + +### suffix +({{< req >}}) +Suffix to remove. + + -### suffix {data-type="string"} -The suffix to remove. ## Examples -###### Remove a suffix from all values in a column +### Remove a suffix from all values in a column + ```js import "strings" data - |> map(fn: (r) => ({r with sensorID: strings.trimSuffix(v: r.sensorId, suffix: "_s12")})) + |> map(fn: (r) => ({r with _value: strings.trimSuffix(v: r._value, suffix: "_ex1")})) ``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | --------------- | ---- | +| 2021-01-01T00:00:00Z | smpl_g9qczs_ex1 | t1 | +| 2021-01-01T00:00:10Z | smpl_0mgv9n_ex1 | t1 | +| 2021-01-01T00:00:20Z | smpl_phw664_ex1 | t1 | +| 2021-01-01T00:00:30Z | smpl_guvzy4_ex1 | t1 | +| 2021-01-01T00:00:40Z | smpl_5v3cce_ex1 | t1 | +| 2021-01-01T00:00:50Z | smpl_s9fmgy_ex1 | t1 | + +| _time | _value | *tag | +| -------------------- | --------------- | ---- | +| 2021-01-01T00:00:00Z | smpl_b5eida_ex1 | t2 | +| 2021-01-01T00:00:10Z | smpl_eu4oxp_ex1 | t2 | +| 2021-01-01T00:00:20Z | smpl_5g7tz4_ex1 | t2 | +| 2021-01-01T00:00:30Z | smpl_sox1ut_ex1 | t2 | +| 2021-01-01T00:00:40Z | smpl_wfm757_ex1 | t2 | +| 2021-01-01T00:00:50Z | smpl_dtn2bv_ex1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_g9qczs | t1 | +| 2021-01-01T00:00:10Z | smpl_0mgv9n | t1 | +| 2021-01-01T00:00:20Z | smpl_phw664 | t1 | +| 2021-01-01T00:00:30Z | smpl_guvzy4 | t1 | +| 2021-01-01T00:00:40Z | smpl_5v3cce | t1 | +| 2021-01-01T00:00:50Z | smpl_s9fmgy | t1 | + +| _time | _value | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | smpl_b5eida | t2 | +| 2021-01-01T00:00:10Z | smpl_eu4oxp | t2 | +| 2021-01-01T00:00:20Z | smpl_5g7tz4 | t2 | +| 2021-01-01T00:00:30Z | smpl_sox1ut | t2 | +| 2021-01-01T00:00:40Z | smpl_wfm757 | t2 | +| 2021-01-01T00:00:50Z | smpl_dtn2bv | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/system/_index.md b/content/flux/v0.x/stdlib/system/_index.md index dbd77b5d2..fdba7df92 100644 --- a/content/flux/v0.x/stdlib/system/_index.md +++ b/content/flux/v0.x/stdlib/system/_index.md @@ -1,28 +1,44 @@ --- -title: Flux system package -list_title: system package +title: system package description: > - The Flux `system` package provides functions for reading values from the system. - Import the `system` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/system/ - - /influxdb/v2.0/reference/flux/stdlib/system/ - - /influxdb/cloud/reference/flux/stdlib/system/ + The `system` package provides functions for reading values from the system. menu: flux_0_x_ref: - name: system - parent: Standard library + name: system + parent: stdlib + identifier: system weight: 11 -flux/v0.x/tags: [system, functions, package] -introduced: 0.18.0 +cascade: + + introduced: 0.18.0 --- -The Flux `system` package provides functions for reading values from the system. + + +The `system` package provides functions for reading values from the system. Import the `system` package: ```js import "system" ``` + + + ## Functions + {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/system/time.md b/content/flux/v0.x/stdlib/system/time.md index bccfa99bd..2c25986e5 100644 --- a/content/flux/v0.x/stdlib/system/time.md +++ b/content/flux/v0.x/stdlib/system/time.md @@ -1,46 +1,53 @@ --- title: system.time() function -description: The `system.time()` function returns the current system time. -aliases: - - /influxdb/v2.0/reference/flux/functions/misc/systemtime - - /influxdb/v2.0/reference/flux/functions/built-in/misc/systemtime - - /influxdb/v2.0/reference/flux/functions/system/time/ - - /influxdb/v2.0/reference/flux/stdlib/system/time/ - - /influxdb/cloud/reference/flux/stdlib/system/time/ +description: > + `system.time()` returns the current system time. menu: flux_0_x_ref: name: system.time parent: system -weight: 401 + identifier: system/time +weight: 101 flux/v0.x/tags: [date/time] -related: - - /flux/v0.x/stdlib/universe/now/ - - /flux/v0.x/stdlib/universe/today/ -introduced: 0.18.0 --- -The `system.time()` function returns the current system time. + + +`system.time()` returns the current system time. + + + +##### Function type signature ```js -import "system" - -system.time() +() => time ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + + ## Examples + +### Return a stream of tables with the current system time + ```js +import "array" import "system" -data - |> set(key: "processed_at", value: string(v: system.time() )) +array.from(rows: [{time: system.time()}]) ``` -{{% note %}} -#### system.time() vs now() -`system.time()` returns the system time (UTC) at which `system.time()` is executed. -Each instance of `system.time()` in a Flux script returns a unique value. - -[`now()`](/flux/v0.x/stdlib/universe/now/) returns the current system time (UTC). -`now()` is cached at runtime, so all instances of `now()` in a Flux script -return the same value. -{{% /note %}} diff --git a/content/flux/v0.x/stdlib/testing/_index.md b/content/flux/v0.x/stdlib/testing/_index.md index a27dc590a..06238f158 100644 --- a/content/flux/v0.x/stdlib/testing/_index.md +++ b/content/flux/v0.x/stdlib/testing/_index.md @@ -1,81 +1,58 @@ --- -title: Flux testing package -list_title: testing package +title: testing package description: > - The Flux `testing` package provide functions for testing Flux operations. - Import the `testing` package. -aliases: - - /influxdb/v2.0/reference/flux/functions/testing/ - - /influxdb/v2.0/reference/flux/stdlib/testing/ - - /influxdb/cloud/reference/flux/stdlib/testing/ + The `testing` package provides functions for testing Flux operations. menu: flux_0_x_ref: - name: testing - parent: Standard library + name: testing + parent: stdlib + identifier: testing weight: 11 -flux/v0.x/tags: [testing, functions, package] -introduced: 0.112.0 +cascade: + + introduced: 0.14.0 --- -The Flux `testing` package provide functions for testing Flux operations. + + +The `testing` package provides functions for testing Flux operations. Import the `testing` package: ```js import "testing" ``` + + ## Options -The `testing` package includes the following options: ```js -import "testing" - option testing.load = (tables=<-) => tables -option testing.loadMem = (csv) => c.from(csv: csv) -option testing.loadStorage = (csv) => c.from(csv: csv) - |> range(start: 1800-01-01T00:00:00Z, stop: 2200-12-31T11:59:59Z) - |> map( - fn: (r) => ({r with - _field: if exists r._field then r._field else die(msg: "test input table does not have _field column"), - _measurement: if exists r._measurement then r._measurement else die(msg: "test input table does not have _measurement column"), - _time: if exists r._time then r._time else die(msg: "test input table does not have _time column"), - }), - ) ``` + +### load -### load {data-type="function"} -Function option that loads tests data from a stream of tables. -Default is: +`load` loads test data from a stream of tables. -```js -(tables=<-) => tables -``` - -### loadMem {data-type="function"} -Function option that loads annotated CSV test data from memory to emulate query -results returned by Flux. -Default is: - -```js -(csv) => c.from(csv: csv) -``` - -### loadStorage {data-type="function"} -Function option that loads annotated CSV test data as if queried from InfluxDB. -Ensures tests behave correctly in both the Flux and InfluxDB test suites. -Default is: - -```js -(csv) => c.from(csv: csv) - |> range(start: 1800-01-01T00:00:00Z, stop: 2200-12-31T11:59:59Z) - |> map( - fn: (r) => ({r with - _field: if exists r._field then r._field else die(msg: "test input table does not have _field column"), - _measurement: if exists r._measurement then r._measurement else die(msg: "test input table does not have _measurement column"), - _time: if exists r._time then r._time else die(msg: "test input table does not have _time column"), - }), - ) -``` ## Functions + {{< children type="functions" show="pages" >}} + +## Packages + +{{< children show="sections" >}} diff --git a/content/flux/v0.x/stdlib/testing/assertempty.md b/content/flux/v0.x/stdlib/testing/assertempty.md index 300de2543..8261193d1 100644 --- a/content/flux/v0.x/stdlib/testing/assertempty.md +++ b/content/flux/v0.x/stdlib/testing/assertempty.md @@ -1,52 +1,70 @@ --- title: testing.assertEmpty() function -description: The testing.assertEmpty() function tests if an input stream is empty. -aliases: - - /influxdb/v2.0/reference/flux/functions/testing/assertempty/ - - /influxdb/v2.0/reference/flux/stdlib/testing/assertempty/ - - /influxdb/cloud/reference/flux/stdlib/testing/assertempty/ +description: > + `testing.assertEmpty()` tests if an input stream is empty. If not empty, the function returns an error. menu: flux_0_x_ref: name: testing.assertEmpty parent: testing -weight: 301 -flux/v0.x/tags: [tests, transformations] + identifier: testing/assertEmpty +weight: 101 +flux/v0.x/tags: [tests] introduced: 0.18.0 --- -The `testing.assertEmpty()` function tests if an input stream is empty. -If not empty, the function returns an error. + + +`testing.assertEmpty()` tests if an input stream is empty. If not empty, the function returns an error. + +assertEmpty can be used to perform in-line tests in a query. + +##### Function type signature ```js -import "testing" - -testing.assertEmpty() +(<-tables: stream[A]) => stream[A] ``` -_The `testing.assertEmpty()` function can be used to perform in-line tests in a query._ +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -#### Check if there is a difference between streams -This example uses the [`testing.diff()` function](/flux/v0.x/stdlib/testing/diff) -which outputs the diff for the two streams. -The `.testing.assertEmpty()` function checks to see if the diff is empty. +### Check if there is a difference between streams + +This example uses `testing.diff()` to output the difference between two streams of tables. +`testing.assertEmpty()` checks to see if the difference is empty. ```js +import "sampledata" import "testing" -got = from(bucket: "example-bucket") - |> range(start: -15m) -want = from(bucket: "backup_example-bucket") - |> range(start: -15m) +want = sampledata.int() +got = sampledata.float() |> toInt() got |> testing.diff(want: want) |> testing.assertEmpty() ``` + diff --git a/content/flux/v0.x/stdlib/testing/assertequals.md b/content/flux/v0.x/stdlib/testing/assertequals.md index 2693c5689..b6ba7d22e 100644 --- a/content/flux/v0.x/stdlib/testing/assertequals.md +++ b/content/flux/v0.x/stdlib/testing/assertequals.md @@ -1,71 +1,97 @@ --- title: testing.assertEquals() function -description: The testing.assertEquals() function tests whether two streams have identical data. -aliases: - - /influxdb/v2.0/reference/flux/functions/tests/assertequals - - /influxdb/v2.0/reference/flux/functions/testing/assertequals/ - - /influxdb/v2.0/reference/flux/stdlib/testing/assertequals/ - - /influxdb/cloud/reference/flux/stdlib/testing/assertequals/ +description: > + `testing.assertEquals()` tests whether two streams of tables are identical. menu: flux_0_x_ref: name: testing.assertEquals parent: testing -weight: 301 -flux/v0.x/tags: [tests, transformations] -introduced: 0.14.0 + identifier: testing/assertEquals +weight: 101 +flux/v0.x/tags: [tests] --- -The `testing.assertEquals()` function tests whether two streams have identical data. + + +`testing.assertEquals()` tests whether two streams of tables are identical. + If equal, the function outputs the tested data stream unchanged. If unequal, the function returns an error. -```js -import "testing" +assertEquals can be used to perform in-line tests in a query. -testing.assertEquals( - name: "streamEquality", - got: got, - want: want, -) +##### Function type signature + +```js +(<-got: stream[A], name: string, want: stream[A]) => stream[A] ``` -_The `testing.assertEquals()` function can be used to perform in-line tests in a query._ +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### name {data-type="string"} -Unique name given to the assertion. +### name +({{< req >}}) +Unique assertion name. + + + +### got + +Data to test. Default is piped-forward data (`<-`). + + + +### want +({{< req >}}) +Expected data to test against. + -### got {data-type="stream of tables"} -The stream containing data to test. -Defaults to piped-forward data (`<-`). -### want {data-type="stream of tables"} -The stream that contains the expected data to test against. ## Examples -##### Assert of separate streams +- [Test if streams of tables are different](#test-if-streams-of-tables-are-different) +- [Test if streams of tables are different mid-script](#test-if-streams-of-tables-are-different-mid-script) + +### Test if streams of tables are different + ```js +import "sampledata" import "testing" -want = from(bucket: "backup-example-bucket") - |> range(start: -5m) +want = sampledata.int() +got = sampledata.float() |> toInt() -got = from(bucket: "example-bucket") - |> range(start: -5m) - -testing.assertEquals(got: got, want: want) +testing.assertEquals(name: "test_equality", got: got, want: want) ``` -##### Inline assertion + +### Test if streams of tables are different mid-script + ```js import "testing" -want = from(bucket: "backup-example-bucket") - |> range(start: -5m) +want = + from(bucket: "backup-example-bucket") + |> range(start: -5m) from(bucket: "example-bucket") |> range(start: -5m) |> testing.assertEquals(want: want) ``` + diff --git a/content/flux/v0.x/stdlib/testing/assertequalvalues.md b/content/flux/v0.x/stdlib/testing/assertequalvalues.md new file mode 100644 index 000000000..457641420 --- /dev/null +++ b/content/flux/v0.x/stdlib/testing/assertequalvalues.md @@ -0,0 +1,79 @@ +--- +title: testing.assertEqualValues() function +description: > + `testing.assertEqualValues()` tests whether two values are equal. +menu: + flux_0_x_ref: + name: testing.assertEqualValues + parent: testing + identifier: testing/assertEqualValues +weight: 101 +flux/v0.x/tags: [tests] +introduced: 0.141.0 +--- + + + +`testing.assertEqualValues()` tests whether two values are equal. + + + +##### Function type signature + +```js +(got: A, want: A) => stream[{v: A, _diff: string}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### got +({{< req >}}) +Value to test. + + + +### want +({{< req >}}) +Expected value to test against. + + + + +## Examples + +### Test if two values are equal + +```js +import "testing" + +testing.assertEqualValues(got: 5, want: 12) +``` + +{{< expand-wrapper >}} +{{% expand "View example input" %}} + +#### Input data + +| _diff | v | +| ------ | -- | +| - | 12 | +| + | 5 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/testing/benchmark.md b/content/flux/v0.x/stdlib/testing/benchmark.md index 32a64259a..dbe25f9d0 100644 --- a/content/flux/v0.x/stdlib/testing/benchmark.md +++ b/content/flux/v0.x/stdlib/testing/benchmark.md @@ -1,49 +1,74 @@ --- title: testing.benchmark() function description: > - The `testing.benchmark()` function executes a test case without comparing test output with the expected test output. - This lets you accurately benchmark a test case without the added overhead of comparing - test output that occurs in [`testing.run()`](/flux/v0.x/stdlib/testing/run/). + `testing.benchmark()` executes a test case without comparing test output with the expected test output. + This lets you accurately benchmark a test case without the added overhead of + comparing test output that occurs in `testing.run()`. menu: flux_0_x_ref: name: testing.benchmark parent: testing -aliases: - - /influxdb/v2.0/reference/flux/stdlib/testing/benchmark/ - - /influxdb/cloud/reference/flux/stdlib/testing/benchmark/ -weight: 301 -flux/v0.x/tags: [tests, transformations] + identifier: testing/benchmark +weight: 101 + introduced: 0.49.0 --- -The `testing.benchmark()` function executes a test case without comparing test output with the expected test output. -This lets you accurately benchmark a test case without the added overhead of comparing -test output that occurs in [`testing.run()`](/flux/v0.x/stdlib/testing/run/). + + +`testing.benchmark()` executes a test case without comparing test output with the expected test output. +This lets you accurately benchmark a test case without the added overhead of +comparing test output that occurs in `testing.run()`. + + + +##### Function type signature ```js -import "testing" - -testing.benchmark(case: exampleTestCase) +(case: () => {A with input: B, fn: (<-: B) => C}) => C ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### case {data-type="function"} +### case +({{< req >}}) Test case to benchmark. + + + ## Examples -##### Define and benchmark a test case -The following script defines a test case for the `sum()` function and enables -[profilers](/flux/v0.x/stdlib/profiler/) to measure query performance. +### Define and benchmark a test case + +The following script defines a test case for the sum() function and enables +profilers to measure query performance. ```js +import "csv" import "testing" import "profiler" option profiler.enabledProfilers = ["query", "operator"] -inData = " +inData = + " #datatype,string,long,string,dateTime:RFC3339,string,double #group,false,false,true,false,true,false #default,_result,,,,, @@ -53,7 +78,8 @@ inData = " ,,0,m,2021-01-03T00:00:00Z,t,2.2 " -outData = " +outData = + " #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,double #group,false,false,true,true,true,true,false #default,_result,,,,,, @@ -61,11 +87,13 @@ outData = " ,,0,2021-01-01T00:00:00Z,2021-01-03T01:00:00Z,m,t,4.8 " -t_sum = (table=<-) => table - |> range(start: 2021-01-01T00:00:00Z, stop: 2021-01-03T01:00:00Z) - |> sum() +t_sum = (table=<-) => + table + |> range(start: 2021-01-01T00:00:00Z, stop: 2021-01-03T01:00:00Z) + |> sum() -test _sum = () => ({input: testing.loadStorage(csv: inData), want: testing.loadMem(csv: outData), fn: t_sum}) +test _sum = () => ({input: csv.from(csv: inData), want: csv.from(csv: outData), fn: t_sum}) testing.benchmark(case: _sum) ``` + diff --git a/content/flux/v0.x/stdlib/testing/diff.md b/content/flux/v0.x/stdlib/testing/diff.md index 001a2f821..5810e8cbe 100644 --- a/content/flux/v0.x/stdlib/testing/diff.md +++ b/content/flux/v0.x/stdlib/testing/diff.md @@ -1,82 +1,137 @@ --- title: testing.diff() function -description: The testing.diff() function produces a diff between two streams. -aliases: - - /influxdb/v2.0/reference/flux/functions/testing/diff/ - - /influxdb/v2.0/reference/flux/stdlib/testing/diff/ - - /influxdb/cloud/reference/flux/stdlib/testing/diff/ +description: > + `testing.diff()` produces a diff between two streams. menu: flux_0_x_ref: name: testing.diff parent: testing -weight: 301 -flux/v0.x/tags: [tests, transformations] + identifier: testing/diff +weight: 101 +flux/v0.x/tags: [tests] introduced: 0.18.0 --- -The `testing.diff()` function produces a diff between two streams. + + +`testing.diff()` produces a diff between two streams. + +The function matches tables from each stream based on group keys. For each matched table, it produces a diff. Any added or removed rows are added to the table as a row. -An additional string column with the name `diff` is created and contains a `-` if the -row was present in the `got` table and not in the `want` table or `+` if the opposite is true. +An additional string column with the name diff is created and contains a +`-` if the row was present in the `got` table and not in the `want` table or +`+` if the opposite is true. -The diff function is guaranteed to emit at least one row if the tables are -different and no rows if the tables are the same. _The exact diff produced may change._ +`diff()` function emits at least one row if the tables are +different and no rows if the tables are the same. +The exact diff produced may change. +`diff()` can be used to perform in-line diffs in a query. -_The `testing.diff()` function can be used to perform in-line diffs in a query._ +##### Function type signature + +```js +( + <-got: stream[A], + want: stream[A], + ?epsilon: float, + ?nansEqual: bool, + ?verbose: bool, +) => stream[{A with _diff: string}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### got {data-type="stream of tables"} -Stream containing data to test. -Default is piped-forward data (`<-`). +### got -### want {data-type="stream of tables"} -Stream that contains the expected data to test against. +Stream containing data to test. Default is piped-forward data (`<-`). + + + +### want +({{< req >}}) +Stream that contains data to test against. + + + +### epsilon + +Specify how far apart two float values can be, but still considered equal. Defaults to 0.000000001. + + + +### verbose + +Include detailed differences in output. Default is `false`. + + + +### nansEqual + +Consider `NaN` float values equal. Default is `false`. -### epsilon {data-type="float"} -Specifies how far apart two **float** values can be, but still considered equal. -Default is `0.000001`. -### nansEqual {data-type="bool"} -Consider `NaN` float values equal. -Default is `false`. -### verbose {data-type="bool"} -Include detailed differences in output. -Default is `false`. ## Examples -##### Diff separate streams +- [Output a diff between two streams of tables](#output-a-diff-between-two-streams-of-tables) +- [Return a diff between a stream of tables an the expected output](#return-a-diff-between-a-stream-of-tables-an-the-expected-output) + +### Output a diff between two streams of tables + ```js +import "sampledata" import "testing" -want = from(bucket: "backup-example-bucket") - |> range(start: -5m) -got = from(bucket: "example-bucket") - |> range(start: -5m) +want = sampledata.int() +got = + sampledata.int() + |> map(fn: (r) => ({r with _value: if r._value > 15 then r._value + 1 else r._value})) testing.diff(got: got, want: want) ``` -##### Inline diff +{{< expand-wrapper >}} +{{% expand "View example input" %}} + +#### Input data + +| *tag | _diff | _time | _value | +| ---- | ------ | -------------------- | ------- | +| t1 | - | 2021-01-01T00:00:30Z | 17 | +| t1 | + | 2021-01-01T00:00:30Z | 18 | + +| *tag | _diff | _time | _value | +| ---- | ------ | -------------------- | ------- | +| t2 | - | 2021-01-01T00:00:00Z | 19 | +| t2 | + | 2021-01-01T00:00:00Z | 20 | +| t2 | - | 2021-01-01T00:00:30Z | 19 | +| t2 | + | 2021-01-01T00:00:30Z | 20 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Return a diff between a stream of tables an the expected output + ```js -iimport "testing" +import "testing" want = from(bucket: "backup-example-bucket") |> range(start: -5m) @@ -84,3 +139,4 @@ from(bucket: "example-bucket") |> range(start: -5m) |> testing.diff(want: want) ``` + diff --git a/content/flux/v0.x/stdlib/testing/expect/_index.md b/content/flux/v0.x/stdlib/testing/expect/_index.md new file mode 100644 index 000000000..5380924bd --- /dev/null +++ b/content/flux/v0.x/stdlib/testing/expect/_index.md @@ -0,0 +1,47 @@ +--- +title: expect package +description: > + The `expect` package includes functions to mark + any expectations for a testcase to be satisfied + before the testcase finishes running. +menu: + flux_0_x_ref: + name: expect + parent: testing + identifier: testing/expect +weight: 21 +--- + + + +The `expect` package includes functions to mark +any expectations for a testcase to be satisfied +before the testcase finishes running. +Import the `testing/expect` package: + +```js +import "testing/expect" +``` + +These functions are intended to be called at the +beginning of a testcase, but it doesn't really +matter when they get invoked within the testcase. + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/testing/expect/planner.md b/content/flux/v0.x/stdlib/testing/expect/planner.md new file mode 100644 index 000000000..fb6588d36 --- /dev/null +++ b/content/flux/v0.x/stdlib/testing/expect/planner.md @@ -0,0 +1,52 @@ +--- +title: expect.planner() function +description: > + `expect.planner()` will cause the present testcase to + expect the given planner rules will be invoked + exactly as many times as the number given. +menu: + flux_0_x_ref: + name: expect.planner + parent: testing/expect + identifier: testing/expect/planner +weight: 201 +--- + + + +`expect.planner()` will cause the present testcase to +expect the given planner rules will be invoked +exactly as many times as the number given. + +The key is the name of the planner rule. + +##### Function type signature + +```js +(rules: [string:int]) => {} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### rules +({{< req >}}) +Mapping of rules names to expected counts. + + + diff --git a/content/flux/v0.x/stdlib/testing/inspect.md b/content/flux/v0.x/stdlib/testing/inspect.md index a609cfd29..4d1a72ad5 100644 --- a/content/flux/v0.x/stdlib/testing/inspect.md +++ b/content/flux/v0.x/stdlib/testing/inspect.md @@ -1,39 +1,71 @@ --- title: testing.inspect() function description: > - The `testing.inspect()` function returns information about a test case. + `testing.inspect()` returns information about a test case. menu: flux_0_x_ref: name: testing.inspect parent: testing -aliases: - - /influxdb/v2.0/reference/flux/stdlib/testing/inspect/ - - /influxdb/cloud/reference/flux/stdlib/testing/inspect/ -weight: 301 -flux/v0.x/tags: [tests, transformations] + identifier: testing/inspect +weight: 101 + introduced: 0.18.0 --- -The `testing.inspect()` function returns information about a test case. + + +`testing.inspect()` returns information about a test case. + + + +##### Function type signature ```js -import "testing" - -testing.inspect(case: exampleTestCase) +( + case: () => {A with want: stream[C], input: B, fn: (<-: B) => stream[C]}, +) => { + want: stream[C], + input: B, + got: stream[C], + fn: (<-: B) => stream[C], + diff: stream[{C with _diff: string}], +} where C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### case {data-type="function"} +### case +({{< req >}}) Test case to inspect. + + + ## Examples -##### Define and inspect a test case +### Define and inspect a test case + ```js import "testing" -inData = " +inData = + " #datatype,string,long,string,dateTime:RFC3339,string,double #group,false,false,true,false,true,false #default,_result,,,,, @@ -43,7 +75,8 @@ inData = " ,,0,m,2021-01-03T00:00:00Z,t,2.2 " -outData = " +outData = + " #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,double #group,false,false,true,true,true,true,false #default,_result,,,,,, @@ -51,19 +84,20 @@ outData = " ,,0,2021-01-01T00:00:00Z,2021-01-03T01:00:00Z,m,t,4.8 " -t_sum = (table=<-) => table - |> range(start: 2021-01-01T00:00:00Z, stop: 2021-01-03T01:00:00Z) - |> sum() +t_sum = (table=<-) => + table + |> range(start: 2021-01-01T00:00:00Z, stop: 2021-01-03T01:00:00Z) + |> sum() -test _sum = () => ({input: testing.loadStorage(csv: inData), want: testing.loadMem(csv: outData), fn: t_sum}) +test _sum = () => ({input: csv.from(csv: inData), want: csv.from(csv: outData), fn: t_sum}) -testing.inpsect(case: _sum) - -// Returns: { -// fn: (<-table: [{_time: time | t10997}]) -> [t10996], -// input: fromCSV -> range -> map, -// want: fromCSV -> yield, -// got: fromCSV -> range -> map -> range -> sum -> yield, -// diff: ( fromCSV; fromCSV -> range -> map -> range -> sum; ) -> diff -> yield +testing.inpsect(case: _sum)// Returns: { +// fn: (<-table: [{_time: time | t10997}]) -> [t10996], +// input: fromCSV -> range -> map, +// want: fromCSV -> yield, +// got: fromCSV -> range -> map -> range -> sum -> yield, +// diff: ( fromCSV; fromCSV -> range -> map -> range -> sum; ) -> diff -> yield // } + ``` + diff --git a/content/flux/v0.x/stdlib/testing/load.md b/content/flux/v0.x/stdlib/testing/load.md index 8c04e32c1..1e44e0ac7 100644 --- a/content/flux/v0.x/stdlib/testing/load.md +++ b/content/flux/v0.x/stdlib/testing/load.md @@ -1,58 +1,84 @@ --- title: testing.load() function description: > - The `testing.load()` function loads tests data from a stream of tables. + `testing.load()` loads test data from a stream of tables. menu: flux_0_x_ref: name: testing.load parent: testing -aliases: - - /influxdb/v2.0/reference/flux/stdlib/testing/load/ - - /influxdb/cloud/reference/flux/stdlib/testing/load/ -weight: 301 -flux/v0.x/tags: [tests, inputs, transformations] + identifier: testing/load +weight: 101 + introduced: 0.112.0 --- -The `testing.load()` function loads tests data from a stream of tables. + + +`testing.load()` loads test data from a stream of tables. + + + +##### Function type signature ```js -import "testing" - -testing.load() +(<-tables: A) => A ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -##### Load a raw stream of tables in a test case -The following test uses [`array.from()`](/flux/v0.x/stdlib/array/from/) -to create two streams of tables to compare in the test. +### Load a raw stream of tables in a test case + +The following test uses `array.from()` to create two streams of tables to +compare in the test. ```js import "testing" import "array" -got = array.from( - rows: [ - {_time: 2021-01-01T00:00:00Z, _measurement: "m", _field: "t", _value: 1.2}, - {_time: 2021-01-01T01:00:00Z, _measurement: "m", _field: "t", _value: 0.8}, - {_time: 2021-01-01T02:00:00Z, _measurement: "m", _field: "t", _value: 3.2}, - ] -) +got = + array.from( + rows: [ + {_time: 2021-01-01T00:00:00Z, _measurement: "m", _field: "t", _value: 1.2}, + {_time: 2021-01-01T01:00:00Z, _measurement: "m", _field: "t", _value: 0.8}, + {_time: 2021-01-01T02:00:00Z, _measurement: "m", _field: "t", _value: 3.2}, + ], + ) -want = array.from( - rows: [ - {_time: 2021-01-01T00:00:00Z, _measurement: "m", _field: "t", _value: 1.2}, - {_time: 2021-01-01T01:00:00Z, _measurement: "m", _field: "t", _value: 0.8}, - {_time: 2021-01-01T02:00:00Z, _measurement: "m", _field: "t", _value: 3.1}, - ] -) +want = + array.from( + rows: [ + {_time: 2021-01-01T00:00:00Z, _measurement: "m", _field: "t", _value: 1.2}, + {_time: 2021-01-01T01:00:00Z, _measurement: "m", _field: "t", _value: 0.8}, + {_time: 2021-01-01T02:00:00Z, _measurement: "m", _field: "t", _value: 3.1}, + ], + ) -testing.diff(got: testing.load(tables: got), want: testing.load(tables: want)) +testing.load(tables: got) + |> testing.diff(want: want) ``` + diff --git a/content/flux/v0.x/stdlib/testing/loadmem.md b/content/flux/v0.x/stdlib/testing/loadmem.md deleted file mode 100644 index a41b7e5e7..000000000 --- a/content/flux/v0.x/stdlib/testing/loadmem.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: testing.loadMem() function -description: > - The `testing.loadMem()` function loads annotated CSV test data from memory to - emulate query results returned by Flux. -menu: - flux_0_x_ref: - name: testing.loadMem - parent: testing -aliases: - - /influxdb/v2.0/reference/flux/stdlib/testing/loadmem/ - - /influxdb/cloud/reference/flux/stdlib/testing/loadmem/ -weight: 301 -flux/v0.x/tags: [tests, inputs] -introduced: 0.20.0 ---- - -The `testing.loadMem()` function loads [annotated CSV](/influxdb/cloud/reference/syntax/annotated-csv/) -test data from memory to emulate query results returned by Flux. - -```js -import "testing" - -testing.loadMem(csv: csvData) -``` - -## Parameters - -### csv {data-type="string"} -[Annotated CSV](/influxdb/cloud/reference/syntax/annotated-csv/) data to load. - -## Examples - -```js -import "testing" - -csvData = " -#datatype,string,long,string,dateTime:RFC3339,string,double -#group,false,false,true,false,true,false -#default,_result,,,,, -,result,table,_measurement,_time,_field,_value -,,0,m,2021-01-01T00:00:00Z,t,1.2 -,,0,m,2021-01-02T00:00:00Z,t,1.4 -,,0,m,2021-01-03T00:00:00Z,t,2.2 -" - -testing.loadMem(csv: csvData) -``` diff --git a/content/flux/v0.x/stdlib/testing/loadstorage.md b/content/flux/v0.x/stdlib/testing/loadstorage.md deleted file mode 100644 index 5666bbde3..000000000 --- a/content/flux/v0.x/stdlib/testing/loadstorage.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: testing.loadStorage() function -description: > - The `testing.loadStorage()` function loads annotated CSV test data as if it were queried from InfluxDB. - This function ensures tests behave correctly in both the Flux and InfluxDB test suites. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/testing/loadstorage/ - - /influxdb/cloud/reference/flux/stdlib/testing/loadstorage/ -weight: 301 -flux/v0.x/tags: [tests, inputs] -introduced: 0.20.0 -removed: 0.171.0 ---- - -{{% warn %}} -#### Removed in Flux 0.171.0 -`testing.loadStorage()` was removed in Flux 0.171.0 and is no longer supported. -{{% /warn %}} - -The `testing.loadStorage()` function loads [annotated CSV](/influxdb/cloud/reference/syntax/annotated-csv/) -test data as if it were queried from InfluxDB. -This function ensures tests behave correctly in both the Flux and InfluxDB test suites. -Test data requires the following columns: - -- `_field` -- `_measurement` -- `_time` - -```js -import "testing" - -testing.loadStorage(csv: csvData) -``` - -## Parameters - -### csv {data-type="string"} -[Annotated CSV](/influxdb/cloud/reference/syntax/annotated-csv/) data to load. - -## Examples - -```js -import "testing" - -csvData = " -#datatype,string,long,string,dateTime:RFC3339,string,double -#group,false,false,true,false,true,false -#default,_result,,,,, -,result,table,_measurement,_time,_field,_value -,,0,m,2021-01-01T00:00:00Z,t,1.2 -,,0,m,2021-01-02T00:00:00Z,t,1.4 -,,0,m,2021-01-03T00:00:00Z,t,2.2 -" - -testing.loadStorage(csv: csvData) -``` diff --git a/content/flux/v0.x/stdlib/testing/run.md b/content/flux/v0.x/stdlib/testing/run.md index c15e963ae..e72269354 100644 --- a/content/flux/v0.x/stdlib/testing/run.md +++ b/content/flux/v0.x/stdlib/testing/run.md @@ -1,38 +1,64 @@ --- title: testing.run() function -description: The `testing.run()` function executes a specified test case. +description: > + `testing.run()` executes a specified test case. menu: flux_0_x_ref: name: testing.run parent: testing -aliases: - - /influxdb/v2.0/reference/flux/stdlib/testing/run/ - - /influxdb/cloud/reference/flux/stdlib/testing/run/ -weight: 301 -flux/v0.x/tags: [tests] + identifier: testing/run +weight: 101 + introduced: 0.20.0 --- -The `testing.run()` function executes a specified test case. + + +`testing.run()` executes a specified test case. + + + +##### Function type signature ```js -import "testing" - -testing.run(case: exampleTestCase) +(case: () => {A with want: stream[C], input: B, fn: (<-: B) => stream[C]}) => stream[{C with _diff: string}] where C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### case {data-type="function"} +### case +({{< req >}}) Test case to run. + + + ## Examples -##### Define and execute a test case +### Define and execute a test case + ```js +import "csv" import "testing" -inData = " +inData = + " #datatype,string,long,string,dateTime:RFC3339,string,double #group,false,false,true,false,true,false #default,_result,,,,, @@ -42,7 +68,8 @@ inData = " ,,0,m,2021-01-03T00:00:00Z,t,2.2 " -outData = " +outData = + " #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,double #group,false,false,true,true,true,true,false #default,_result,,,,,, @@ -50,11 +77,13 @@ outData = " ,,0,2021-01-01T00:00:00Z,2021-01-03T01:00:00Z,m,t,4.8 " -t_sum = (table=<-) => table - |> range(start: 2021-01-01T00:00:00Z, stop: 2021-01-03T01:00:00Z) - |> sum() +t_sum = (table=<-) => + table + |> range(start: 2021-01-01T00:00:00Z, stop: 2021-01-03T01:00:00Z) + |> sum() -test _sum = () => ({input: testing.loadStorage(csv: inData), want: testing.loadMem(csv: outData), fn: t_sum}) +test _sum = () => ({input: csv.from(csv: inData), want: csv.from(csv: outData), fn: t_sum}) testing.run(case: _sum) ``` + diff --git a/content/flux/v0.x/stdlib/timezone/_index.md b/content/flux/v0.x/stdlib/timezone/_index.md index 64e492c57..7968f7f03 100644 --- a/content/flux/v0.x/stdlib/timezone/_index.md +++ b/content/flux/v0.x/stdlib/timezone/_index.md @@ -1,32 +1,53 @@ --- -title: Flux timezone package -list_title: timezone package +title: timezone package description: > - The Flux `timezone` package provide functions for timezones on the - [location option](/flux/v0.x/stdlib/universe/#location). - Import the `timezone` package. + The `timezone` package defines functions for setting timezones + on the location option in package universe. menu: flux_0_x_ref: - name: timezone - parent: Standard library + name: timezone + parent: stdlib + identifier: timezone weight: 11 -flux/v0.x/tags: [timezone, location, functions, package] cascade: + introduced: 0.134.0 --- -The Flux `timezone` package provide functions for timezones on the -[location option](/flux/v0.x/stdlib/universe/#location). -Import the `timezone` package. + + +The `timezone` package defines functions for setting timezones +on the location option in package universe. +Import the `timezone` package: + +```js import "timezone" ``` ## Constants + ```js timezone.utc = {zone: "UTC", offset: 0h} ``` +- **timezone.utc** is the default location with a completely linear clock and no offset. +It is used as the default for location-related options. + + ## Functions -{{< children type="functions" show="pages" >}} \ No newline at end of file + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/timezone/fixed.md b/content/flux/v0.x/stdlib/timezone/fixed.md index 3a9d65b88..fce38f56e 100644 --- a/content/flux/v0.x/stdlib/timezone/fixed.md +++ b/content/flux/v0.x/stdlib/timezone/fixed.md @@ -1,77 +1,75 @@ --- title: timezone.fixed() function description: > - `timezone.fixed()` constructs a location with a fixed offset. + `timezone.fixed()` returns a location record with a fixed offset. menu: flux_0_x_ref: name: timezone.fixed parent: timezone + identifier: timezone/fixed weight: 101 -flux/v0.x/tags: [timezone, location, data/time] +flux/v0.x/tags: [date/time, location] --- -`timezone.fixed()` constructs a timezone record with a fixed offset from UTC. -Fixed timezones are not affected by location-based time shifts in the clock -such as daylight savings time or summertime. + + +`timezone.fixed()` returns a location record with a fixed offset. + + + +##### Function type signature ```js -import "timezone" - -timezone.fixed(offset: -2h) - -// Returns {offset: -2h, zone: UTC} +(offset: A) => {zone: string, offset: A} ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### offset {data-type="duration"} +### offset ({{< req >}}) -The fixed duration for the location offset. -The duration is the offset from UTC time. +Fixed duration for the location offset. +This duration is the offset from UTC. + + + ## Examples -##### Apply a fixed timezone offset to windows +- [Return a fixed location record](#return-a-fixed-location-record) +- [Set the location option using a fixed location](#set-the-location-option-using-a-fixed-location) + +### Return a fixed location record + ```js -import "array" import "timezone" -option location = timezone.fixed(offset: -8h) +timezone.fixed(offset: -8h)// Returns {offset: -8h, zone: "UTC"} -data = array.from( - rows: [ - {_time: 2021-01-01T00:06:00Z, _value: 1}, - {_time: 2021-01-02T00:06:00Z, _value: 2}, - {_time: 2021-01-03T00:06:00Z, _value: 3}, - ], -) - |> range(start: 2021-01-01T00:00:00Z, stop: 2021-01-04T00:00:00Z) - -data - |> window(every: 1d) ``` -{{< expand-wrapper >}} -{{% expand "View example input and output data" %}} -#### Input data -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-04T00:00:00Z | 2021-01-01T00:06:00Z | 1 | -| 2021-01-01T00:00:00Z | 2021-01-04T00:00:00Z | 2021-01-02T00:06:00Z | 2 | -| 2021-01-01T00:00:00Z | 2021-01-04T00:00:00Z | 2021-01-03T00:06:00Z | 3 | -#### Output data -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T08:00:00Z | 2021-01-01T00:06:00Z | 1 | +### Set the location option using a fixed location +```js +import "timezone" -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-01-01T08:00:00Z | 2021-01-02T08:00:00Z | 2021-01-02T00:06:00Z | 2 | +// This results in midnight at 00:00:00-08:00 on any day. +option location = timezone.fixed(offset: -8h) +``` -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-01-02T08:00:00Z | 2021-01-03T08:00:00Z | 2021-01-03T00:06:00Z | 3 | -{{% /expand %}} -{{< /expand-wrapper >}} \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/timezone/location.md b/content/flux/v0.x/stdlib/timezone/location.md index 3db41a721..204b7971e 100644 --- a/content/flux/v0.x/stdlib/timezone/location.md +++ b/content/flux/v0.x/stdlib/timezone/location.md @@ -1,33 +1,73 @@ --- title: timezone.location() function description: > - `timezone.location()` loads a timezone based on a location name. + `timezone.location()` returns a location record based on a location or timezone name. menu: flux_0_x_ref: name: timezone.location parent: timezone + identifier: timezone/location weight: 101 -flux/v0.x/tags: [timezone, location, data/time] +flux/v0.x/tags: [date/time, location] --- -`timezone.location()` constructs a timezone record based on a specific location. -Setting the timezone by location accounts for location-based time shifts in the -clock such as daylight savings time or summertime. + + +`timezone.location()` returns a location record based on a location or timezone name. + + + +##### Function type signature + +```js +(name: string) => {zone: string, offset: duration} +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### name +({{< req >}}) +Location name (as defined by your operating system timezone database). + + + + +## Examples + +- [Return a timezone-based location record](#return-a-timezone-based-location-record) +- [Set the location option using a timezone-based location](#set-the-location-option-using-a-timezone-based-location) + +### Return a timezone-based location record ```js import "timezone" -timezone.location(name: "America/Los_Angeles") +timezone.location(name: "America/Los_Angeles")// Returns {offset: 0ns, zone: "America/Los_Angeles"} -// Returns {offset: 0ns, zone: "America/Los_Angeles"} ``` -## Parameters -### name {data-type="string"} -({{< req >}}) -Location name _(as defined by your operating system timezone database)_. +### Set the location option using a timezone-based location + +```js +import "timezone" + +option location = timezone.location(name: "America/Los_Angeles") +``` + diff --git a/content/flux/v0.x/stdlib/types/_index.md b/content/flux/v0.x/stdlib/types/_index.md index 7132a1c37..71997e452 100644 --- a/content/flux/v0.x/stdlib/types/_index.md +++ b/content/flux/v0.x/stdlib/types/_index.md @@ -1,28 +1,44 @@ --- -title: Flux types package -list_title: types package +title: types package description: > - The Flux `types` package provides functions for working with - [Flux basic types](/flux/v0.x/data/data-types/basic/). - Import the `types` package. + The `types` package provides functions for working with Flux's types. menu: flux_0_x_ref: - name: types - parent: Standard library + name: types + parent: stdlib + identifier: types weight: 11 -flux/v0.x/tags: [types, functions, package] cascade: + flux/v0.x/tags: [types] introduced: 0.141.0 --- -The Flux `types` package provides functions for working with -[Flux basic types](/flux/v0.x/data/data-types/basic/). -Import the `types` package. + + +The `types` package provides functions for working with Flux's types. +Import the `types` package: ```js import "types" ``` + + + ## Functions {{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/types/istype.md b/content/flux/v0.x/stdlib/types/istype.md index c0eea9793..e50190172 100644 --- a/content/flux/v0.x/stdlib/types/istype.md +++ b/content/flux/v0.x/stdlib/types/istype.md @@ -1,39 +1,57 @@ --- title: types.isType() function description: > - `types.isType()` tests if a value is a specified [Flux basic type](/flux/v0.x/data-types/basic/). + `types.isType()` tests if a value is a specified type. menu: flux_0_x_ref: name: types.isType parent: types + identifier: types/isType weight: 101 -flux/v0.x/tags: [tests, types] +flux/v0.x/tags: [types, tests] --- -`types.isType()` tests if a value is a specified [Flux basic type](/flux/v0.x/data-types/basic/). -Use this function to filter your data by type. Often used to downsample or -[aggregate data by type](#aggregate-or-select-data-based-on-type). + + +`types.isType()` tests if a value is a specified type. + + + +##### Function type signature ```js -import "types" - -types.isType(v: 12, type: "int") - -// Returns true +(type: string, v: A) => bool where A: Basic ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters ### v ({{< req >}}) Value to test. -### type {data-type="string"} + + +### type ({{< req >}}) -Flux basic type. - -**Supported values:** +String describing the type to check against. +**Supported types**: - string - bytes - int @@ -44,92 +62,114 @@ Flux basic type. - duration - regexp + ## Examples -### Filter fields by type +- [Filter by value type](#filter-by-value-type) +- [Aggregate or select data based on type](#aggregate-or-select-data-based-on-type) + +### Filter by value type + ```js -import "strings" +import "types" data |> filter(fn: (r) => types.isType(v: r._value, type: "string")) ``` {{< expand-wrapper >}} -{{% expand "View example input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data +#### Input data -| _time | _field | _value (int) | -| :------------------- | :----- | -------------------------------------------: | -| 2022-01-01T00:00:00Z | foo | 12 | -| 2022-01-01T00:01:00Z | foo | 15 | -| 2022-01-01T00:02:00Z | foo | 9 | +| _time | *_field | _value | +| -------------------- | ------- | ------- | +| 2022-01-01T00:00:00Z | foo | 12 | +| 2022-01-01T00:01:00Z | foo | 15 | +| 2022-01-01T00:02:00Z | foo | 9 | -| _time | _field | _value (string) | -| :------------------- | :----- | ----------------------------------------------: | -| 2022-01-01T00:00:00Z | bar | 0jCcsMYM | -| 2022-01-01T00:01:00Z | bar | jHvuDw35 | -| 2022-01-01T00:02:00Z | bar | HE5uCIC2 | +| _time | *_field | _value | +| ------ | ------- | ------- | -{{% /flex-content %}} -{{% flex-content %}} +| _time | *_field | _value | +| -------------------- | ------- | -------- | +| 2022-01-01T00:00:00Z | bar | 0jCcsMYM | +| 2022-01-01T00:01:00Z | bar | jHvuDw35 | +| 2022-01-01T00:02:00Z | bar | HE5uCIC2 | -##### Output data -| _time | _field | _value (string) | -| :------------------- | :----- | ----------------------------------------------: | -| 2022-01-01T00:00:00Z | bar | 0jCcsMYM | -| 2022-01-01T00:01:00Z | bar | jHvuDw35 | -| 2022-01-01T00:02:00Z | bar | HE5uCIC2 | +#### Output data + +| _time | *_field | _value | +| -------------------- | ------- | -------- | +| 2022-01-01T00:00:00Z | bar | 0jCcsMYM | +| 2022-01-01T00:01:00Z | bar | jHvuDw35 | +| 2022-01-01T00:02:00Z | bar | HE5uCIC2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} - ### Aggregate or select data based on type -```javascript -data = () => from(bucket: "example-bucket") - |> range(start: -1m) -nonNumericData = data() - |> filter(fn: (r) => types.isType(v: r._value, type: "string") or types.isType(v: r._value, type: "bool")) - |> aggregateWindow(every: 30s, fn: last) +```js +import "types" -numericData = data() - |> filter(fn: (r) => types.isType(v: r._value, type: "int") or types.isType(v: r._value, type: "float")) - |> aggregateWindow(every: 30s, fn: mean) +nonNumericData = + data + |> filter(fn: (r) => types.isType(v: r._value, type: "string") or types.isType(v: r._value, type: "bool")) + |> aggregateWindow(every: 30s, fn: last) -> union(tables: [nonNumericData, numericData]) +numericData = + data + |> filter(fn: (r) => types.isType(v: r._value, type: "int") or types.isType(v: r._value, type: "float")) + |> aggregateWindow(every: 30s, fn: mean) + +union(tables: [nonNumericData, numericData]) ``` {{< expand-wrapper >}} -{{% expand "View example input and output" %}} +{{% expand "View example input and ouput" %}} #### Input data -| _start | _stop | _time | type | _value | -| :------------------- | :------------------- | :------------------- | :---- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | float | -2.18 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | float | 10.92 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | float | 7.35 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | float | 17.53 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | float | 15.23 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | float | 4.43 | -| _start | _stop | _time | type | _value | -| :------------------- | :------------------- | :------------------- | :--- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | bool | true | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | bool | true | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | bool | false | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | bool | true | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | bool | false | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | bool | false | +| *_start | *_stop | _time | *type | _value | +| -------------------- | -------------------- | -------------------- | ----- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | bool | true | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | bool | true | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | bool | false | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | bool | true | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | bool | false | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | bool | false | -| _start | _stop | _time | type | _value | -| :------------------- | :------------------- | :------------------- | :----- | ----------: | +| *_start | *_stop | _time | *type | _value | +| ------- | ------ | ------ | ----- | ------- | + +| *_start | *_stop | _time | *type | _value | +| -------------------- | -------------------- | -------------------- | ----- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | float | -2.18 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | float | 10.92 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | float | 7.35 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | float | 17.53 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | float | 15.23 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | float | 4.43 | + +| *_start | *_stop | _time | _value | *type | +| ------- | ------ | ------ | ------- | ----- | + +| *_start | *_stop | _time | _value | *type | +| -------------------- | -------------------- | -------------------- | ------- | ----- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | int | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | int | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | int | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | int | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | int | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | int | + +| *_start | *_stop | _time | *type | _value | +| ------- | ------ | ------ | ----- | ------- | + +| *_start | *_stop | _time | *type | _value | +| -------------------- | -------------------- | -------------------- | ------ | ----------- | | 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | string | smpl_g9qczs | | 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | string | smpl_0mgv9n | | 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | string | smpl_phw664 | @@ -137,34 +177,32 @@ numericData = data() | 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | string | smpl_5v3cce | | 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | string | smpl_s9fmgy | -| _start | _stop | _time | type | _value | -| :------------------- | :------------------- | :------------------- | :--- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | int | -2 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | int | 10 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | int | 7 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | int | 17 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | int | 15 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | int | 4 | #### Output data -| _start | _stop | _time | type | _value | -| :------------------- | :------------------- | :------------------- | :--- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | bool | false | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | bool | false | +| *_start | *_stop | _time | *type | _value | +| -------------------- | -------------------- | -------------------- | ----- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | bool | false | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | bool | false | -| _start | _stop | _time | type | _value | -| :------------------- | :------------------- | :------------------- | :---- | -----------------: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | float | 5.363333333333333 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | float | 12.396666666666668 | +| *_start | *_stop | *type | _value | _time | +| ------- | ------ | ----- | ------- | ------ | -| _start | _stop | _time | type | _value | -| :------------------- | :------------------- | :------------------- | :--- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | int | 5 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | int | 12 | +| *_start | *_stop | *type | _value | _time | +| -------------------- | -------------------- | ----- | ------------------ | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | float | 5.363333333333333 | 2021-01-01T00:00:30Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | float | 12.396666666666668 | 2021-01-01T00:01:00Z | -| _start | _stop | _time | type | _value | -| :------------------- | :------------------- | :------------------- | :----- | ----------: | +| *_start | *_stop | *type | _value | _time | +| -------------------- | -------------------- | ----- | ------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | int | 5 | 2021-01-01T00:00:30Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | int | 12 | 2021-01-01T00:01:00Z | + +| *_start | *_stop | _time | *type | _value | +| ------- | ------ | ------ | ----- | ------- | + +| *_start | *_stop | _time | *type | _value | +| -------------------- | -------------------- | -------------------- | ------ | ----------- | | 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | string | smpl_phw664 | | 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | string | smpl_s9fmgy | diff --git a/content/flux/v0.x/stdlib/universe/_index.md b/content/flux/v0.x/stdlib/universe/_index.md index 61feaf2b8..d02ceba25 100644 --- a/content/flux/v0.x/stdlib/universe/_index.md +++ b/content/flux/v0.x/stdlib/universe/_index.md @@ -1,43 +1,63 @@ --- -title: Flux universe package (built-in) -list_title: universe package (built-in) +title: universe package description: > - The Flux `universe` package includes all functions that do not require a package import statement and are usable without any extra setup. - Functions in the `universe` package provide a foundation for working with data using Flux. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/ - - /influxdb/cloud/reference/flux/stdlib/built-in/ + The `universe` package provides options and primitive functions that are + loaded into the Flux runtime by default and do not require an + import statement. menu: flux_0_x_ref: name: universe (built-in) + parent: stdlib identifier: universe - parent: Standard library weight: 10 -flux/v0.x/tags: [built-in, functions, package] +cascade: + + introduced: 0.14.0 --- -The Flux `universe` package includes all functions that do not require a package import statement and are usable without any extra setup. -The "built-in" functions in the `universe` package provide a foundation for working with data using Flux. + + +The `universe` package provides options and primitive functions that are +loaded into the Flux runtime by default and do not require an +import statement. + +## Constants ```js -option now = () => system.time() -option location = timezone.utc +inf ``` -### now {data-type="function"} -Function option that, by default, returns the current system time. -The value of `now()` is cached at query time, so all instances of `now()` in a -script return the same time value. +- **inf** represents an infinte float value. -### location {data-type="record"} -Location used to determine timezone. Default is [`timezone.utc`](/flux/v0.x/stdlib/timezone/#constants). +## Options -Flux uses the timezone information (commonly referred to as "tz" or "zoneinfo") -provided by the operating system. +```js +option now = system.time +``` + +### now +`now` is a function option that, by default, returns the current system time. + +#### now() vs system.time() +`now()` returns the current system time (UTC). `now()` is cached at runtime, +so all executions of `now()` in a Flux script return the same time value. +`system.time()` returns the system time (UTC) at which `system.time()` is executed. +Each instance of `system.time()` in a Flux script returns a unique value. ## Functions -{{< children type="functions" >}} + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/universe/aggregatewindow.md b/content/flux/v0.x/stdlib/universe/aggregatewindow.md index 2761eddd1..2c21e5905 100644 --- a/content/flux/v0.x/stdlib/universe/aggregatewindow.md +++ b/content/flux/v0.x/stdlib/universe/aggregatewindow.md @@ -1,189 +1,200 @@ --- title: aggregateWindow() function -description: The `aggregateWindow()` function applies an aggregate function to fixed windows of time. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/aggregatewindow - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/aggregatewindow/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/aggregatewindow/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/aggregatewindow/ +description: > + `aggregateWindow()` groups data into fixed windows of time and applies an + aggregate or selector function to each window. menu: flux_0_x_ref: name: aggregateWindow parent: universe -weight: 102 -related: - - /{{< latest "influxdb" >}}/query-data/flux/window-aggregate/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#aggregations, InfluxQL – Aggregate functions - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-group-by-clause, InfluxQL – GROUP BY time() -flux/v0.x/tags: [transformations] + identifier: universe/aggregateWindow +weight: 101 +flux/v0.x/tags: [transformations, aggregates, selectors] introduced: 0.7.0 --- -`aggregateWindow()` applies an aggregate or selector function -(any function with a `column` parameter) to fixed windows of time. + + +`aggregateWindow()` groups data into fixed windows of time and applies an +aggregate or selector function to each window. + +All columns not in the group key other than the specified `column` are dropped +from output tables. This includes `_time`. `aggregateWindow()` uses the +`timeSrc` and `timeDst` parameters to assign a time to the aggregate value. + +`aggregateWindow()` requires `_start` and `_stop` columns in input data. +Use `range()` to assign `_start` and `_stop` values. + +#### Window by calendar months and years +`every`, `period`, and `offset` parameters support all valid duration units, +including calendar months (`1mo`) and years (`1y`). + +#### Window by week +When windowing by week (`1w`), weeks are determined using the Unix epoch +(1970-01-01T00:00:00Z UTC). The Unix epoch was on a Thursday, so all +calculated weeks begin on Thursday. + +##### Function type signature ```js -aggregateWindow( - every: 1m, - period: 1m, - fn: mean, - column: "_value", - timeSrc: "_stop", - timeDst: "_time", - location: timezone.utc, - offset: 0s, - createEmpty: true, -) +( + <-tables: stream[D], + every: duration, + fn: (<-: stream[B], column: A) => stream[C], + ?column: A, + ?createEmpty: bool, + ?location: {zone: string, offset: duration}, + ?offset: duration, + ?period: duration, + ?timeDst: string, + ?timeSrc: string, +) => stream[E] where B: Record, C: Record, D: Record, E: Record ``` -`aggregateWindow()` requires that input data have `_start` and `_stop` columns to -calculate windows of time to operate on. Use [`range()`](/flux/v0.x/stdlib/universe/range/) -to assign `_start` and `_stop` values. - -As data is windowed into separate tables and processed, the `_time` column is dropped from each group key. -This function copies the timestamp from a remaining column into the `_time` column. - -`aggregateWindow()` restores the original `_start` and `_stop` values of input data -and, by default, uses `_stop` to set the `_time` value for each aggregated window. -Each row in the output of `aggregateWindow` represents an aggregated window ending at `_time`. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -{{% note %}} -Make sure `fn` parameter names match each specified parameter. -To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} +### every +({{< req >}}) +Duration of time between windows. -### every {data-type="duration"} -Duration of windows. -{{% note %}} -#### Calendar months and years -`every` supports all [valid duration units](/flux/v0.x/spec/types/#duration-types), -including **calendar months (`1mo`)** and **years (`1y`)**. +### period -#### Aggregate by week -When aggregating by week (`1w`), weeks are determined using the -**Unix epoch (1970-01-01T00:00:00Z UTC)**. The Unix epoch was on a Thursday, so -all calculated weeks begin on Thursday. -{{% /note %}} +Duration of windows. Default is the `every` value. -### period {data-type="duration"} -Duration of the window. -Period is the length of each interval. -The period can be negative, indicating the start and stop boundaries are reversed. -Defaults to `every` value. +`period` can be negative, indicating the start and stop boundaries are reversed. -### fn {data-type="function"} +### offset -[Aggregate](/flux/v0.x/function-types/#aggregates) -or [selector function](/flux/v0.x/function-types/#selectors) -used to operate on each window of time. +Duration to shift the window boundaries by. Defualt is `0s`. -{{% note %}} -Only aggregate and selector functions with a `column` parameter (singular) work with `aggregateWindow()`. -{{% /note %}} - -### column {data-type="string"} - -The column on which to operate. -Defaults to `"_value"`. - -### timeSrc {data-type="string"} - -The time column from which time is copied for the aggregate record. -Defaults to `"_stop"`. - -### timeDst {data-type="string"} - -The "time destination" column to which time is copied for the aggregate record. -Defaults to `"_time"`. - -### location {data-type="record"} - -Location used to determine timezone. -Default is the [`location` option](/flux/v0.x/stdlib/universe/#location). - -_Flux uses the timezone database (commonly referred to as "tz" or "zoneinfo") -provided by the operating system._ - -### offset {data-type="duration"} - -Duration to shift the window boundaries by. Default is `0s`. `offset` can be negative, indicating that the offset goes backwards in time. -### createEmpty {data-type="bool"} +### fn +({{< req >}}) +Aggreate or selector function to apply to each time window. + + + +### location + +Location used to determine timezone. Default is the `location` option. + + + +### column + +Column to operate on. + + + +### timeSrc + +Column to use as the source of the new time value for aggregate values. +Default is `_stop`. + + + +### timeDst + +Column to store time values for aggregate values in. +Default is `_time`. + + + +### createEmpty + +Create empty tables for empty window. Default is `false`. + +**Note:** When using `createEmpty: true`, aggregate functions return empty +tables, but selector functions do not. By design, selectors drop empty tables. + +### tables + +Input data. Default is piped-forward data (`<-`). -For windows without data, create a single-row table for each empty window (using -[`table.fill()`](/flux/v0.x/stdlib/experimental/table/fill/)). -Defaults to `true`. -{{% note %}} -When using `createEmpty: true`, [aggregate functions](/flux/v0.x/function-types/#aggregates) -return empty tables, but [selector functions](/flux/v0.x/function-types/#selectors) do not. -By design, selectors drop empty tables. -{{% /note %}} -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Use an aggregate function with default parameters](#use-an-aggregate-function-with-default-parameters) - [Specify parameters of the aggregate function](#specify-parameters-of-the-aggregate-function) - [Window and aggregate by calendar month](#window-and-aggregate-by-calendar-month) -- [Window and aggregate by calendar week starting on Monday](#window-and-aggregate-by-calendar-week-starting-on-monday) -#### Use an aggregate function with default parameters -The following example uses the default parameters of the -[`mean()` function](/flux/v0.x/stdlib/universe/mean/) -to aggregate time-based windows: +### Use an aggregate function with default parameters ```js -import "sampledata" - -data = sampledata.float() - |> range(start: sampledata.start, stop: sampledata.stop) - data |> aggregateWindow(every: 20s, fn: mean) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -##### Input data -{{% flux/sample set="float" includeRange=true %}} +{{% expand "View example input and ouput" %}} -##### Output data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t1 | 4.37 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t1 | 12.440000000000001 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | t1 | 9.83 | +#### Input data + +| *_start | *_stop | _time | *tag | _value | +| -------------------- | -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t1 | 4.43 | + +| *_start | *_stop | _time | *tag | _value | +| -------------------- | -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| *_start | *_stop | *tag | _value | _time | +| -------------------- | -------------------- | ---- | ------------------ | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 4.37 | 2021-01-01T00:00:20Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 12.440000000000001 | 2021-01-01T00:00:40Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 9.83 | 2021-01-01T00:01:00Z | + +| *_start | *_stop | *tag | _value | _time | +| -------------------- | -------------------- | ---- | ----------------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 12.41 | 2021-01-01T00:00:20Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 8.01 | 2021-01-01T00:00:40Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 7.859999999999999 | 2021-01-01T00:01:00Z | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t2 | 12.41 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t2 | 8.01 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | t2 | 7.859999999999999 | {{% /expand %}} {{< /expand-wrapper >}} +### Specify parameters of the aggregate function -#### Specify parameters of the aggregate function -To use functions that don't provide defaults for required parameters with `aggregateWindow()`, -define an anonymous function with `column` and `tables` parameters that pipes-forward -tables into the aggregate or selector function with all required parameters defined: +To use functions that don’t provide defaults for required parameters with +`aggregateWindow()`, define an anonymous function with `column` and `tables` +parameters that pipes-forward tables into the aggregate or selector function +with all required parameters defined: ```js -import "sampledata" - -data = sampledata.float() - |> range(start: sampledata.start, stop: sampledata.stop) - data |> aggregateWindow( column: "_value", @@ -193,91 +204,86 @@ data ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -##### Input data -{{% flux/sample set="float" includeRange=true %}} +{{% expand "View example input and ouput" %}} -##### Output data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t1 | 10.92 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t1 | 17.53 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | t1 | 15.23 | +#### Input data + +| *_start | *_stop | _time | *tag | _value | +| -------------------- | -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t1 | 4.43 | + +| *_start | *_stop | _time | *tag | _value | +| -------------------- | -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| *_start | *_stop | *tag | _value | _time | +| -------------------- | -------------------- | ---- | ------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 10.92 | 2021-01-01T00:00:20Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 17.53 | 2021-01-01T00:00:40Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 15.23 | 2021-01-01T00:01:00Z | + +| *_start | *_stop | *tag | _value | _time | +| -------------------- | -------------------- | ---- | ------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 19.85 | 2021-01-01T00:00:20Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 19.77 | 2021-01-01T00:00:40Z | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 13.86 | 2021-01-01T00:01:00Z | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t2 | 19.85 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t2 | 19.77 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | t2 | 13.86 | {{% /expand %}} {{< /expand-wrapper >}} -#### Window and aggregate by calendar month +### Window and aggregate by calendar month + ```js -import "sampledata" - -data = sampledata.float() - |> range(start: sampledata.start, stop: sampledata.stop) - data |> aggregateWindow(every: 1mo, fn: mean) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -##### Input data -{{% flux/sample set="float" includeRange=true %}} +{{% expand "View example input and ouput" %}} -##### Output data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | t1 | 8.88 | +#### Input data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | t2 | 9.426666666666668 | -{{% /expand %}} -{{< /expand-wrapper >}} +| *_start | *_stop | _time | *tag | _value | +| -------------------- | -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t1 | 4.43 | -#### Window and aggregate by calendar week starting on Monday +| *_start | *_stop | _time | *tag | _value | +| -------------------- | -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t2 | 1.86 | -Flux increments weeks from the Unix epoch, which was a Thursday. -Because of this, by default, all `1w` windows begin on Thursday. -Use the `offset` parameter to shift the start of weekly windows to the desired day. - -| Week start | Offset | -| :--------- | :----: | -| Monday | -3d | -| Tuesday | -2d | -| Wednesday | -1d | -| Thursday | 0d | -| Friday | 1d | -| Saturday | 2d | -| Sunday | 3d | - -```js -import "sampledata" - -data = sampledata.float() - |> range(start: sampledata.start, stop: sampledata.stop) - -data - |> aggregateWindow(every: 1w, offset: -3d, fn: mean) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -##### Input data -{{% flux/sample set="float" includeRange=true %}} #### Output data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | t1 | 8.88 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:01:00Z | t2 | 9.426666666666668 | +| *_start | *_stop | *tag | _value | _time | +| -------------------- | -------------------- | ---- | ------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 8.88 | 2021-01-01T00:01:00Z | + +| *_start | *_stop | *tag | _value | _time | +| -------------------- | -------------------- | ---- | ----------------- | -------------------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 9.426666666666668 | 2021-01-01T00:01:00Z | {{% /expand %}} -{{< /expand-wrapper >}} \ No newline at end of file +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/bool.md b/content/flux/v0.x/stdlib/universe/bool.md index 9eb04bf94..86491e43c 100644 --- a/content/flux/v0.x/stdlib/universe/bool.md +++ b/content/flux/v0.x/stdlib/universe/bool.md @@ -1,94 +1,148 @@ --- title: bool() function -description: The `bool()` function converts a single value to a boolean. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/bool/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/bool/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/bool/ +description: > + `bool()` converts a value to a boolean type. menu: flux_0_x_ref: name: bool parent: universe -weight: 102 + identifier: universe/bool +weight: 101 flux/v0.x/tags: [type-conversions] -related: - - /flux/v0.x/data-types/basic/bool/ - - /flux/v0.x/stdlib/universe/tobool/ introduced: 0.7.0 --- -The `bool()` function converts a single value to a boolean. + + +`bool()` converts a value to a boolean type. + + + +##### Function type signature ```js -bool(v: "true") +(v: A) => bool ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string, int, uint, float"} -The value to convert. +### v +({{< req >}}) +Value to convert. + + + ## Examples -#### Convert a numeric column to a boolean column +- [Convert strings to booleans](#convert-strings-to-booleans) +- [Convert numeric values to booleans](#convert-numeric-values-to-booleans) +- [Convert all values in a column to booleans](#convert-all-values-in-a-column-to-booleans) + +### Convert strings to booleans + ```js -import "sampledata" +bool(v: "true") -data = sampledata.numericBool() - |> rename(columns: {_value: "online"}) +// Returns true +bool(v: "false")// Returns false +``` + + +### Convert numeric values to booleans + +```js +bool(v: 1.0) + +// Returns true +bool(v: 0.0) + +// Returns false +bool(v: 1) + +// Returns true +bool(v: 0) + +// Returns false +bool(v: uint(v: 1)) + +// Returns true +bool(v: uint(v: 0))// Returns false + +``` + + +### Convert all values in a column to booleans + +If converting the `_value` column to boolean types, use `toBool()`. +If converting columns other than `_value`, use `map()` to iterate over each +row and `bool()` to covert a column value to a boolean type. + +```js data - |> map(fn: (r) => ({r with online: bool(v: r.online)})) + |> map(fn: (r) => ({r with powerOn: bool(v: r.powerOn)})) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -| _time | tag | online | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | 1 | -| 2021-01-01T00:00:10Z | t1 | 1 | -| 2021-01-01T00:00:20Z | t1 | 0 | -| 2021-01-01T00:00:30Z | t1 | 1 | -| 2021-01-01T00:00:40Z | t1 | 0 | -| 2021-01-01T00:00:50Z | t1 | 0 | +#### Input data -| _time | tag | online | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 0 | -| 2021-01-01T00:00:10Z | t2 | 1 | -| 2021-01-01T00:00:20Z | t2 | 0 | -| 2021-01-01T00:00:30Z | t2 | 1 | -| 2021-01-01T00:00:40Z | t2 | 1 | -| 2021-01-01T00:00:50Z | t2 | 0 | +| _time | powerOn | *tag | +| -------------------- | -------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 0 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 0 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | -{{% /flex-content %}} -{{% flex-content %}} +| _time | powerOn | *tag | +| -------------------- | -------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 1 | t2 | +| 2021-01-01T00:00:20Z | 0 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | -##### Output data -| _time | tag | online | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | true | -| 2021-01-01T00:00:10Z | t1 | true | -| 2021-01-01T00:00:20Z | t1 | false | -| 2021-01-01T00:00:30Z | t1 | true | -| 2021-01-01T00:00:40Z | t1 | false | -| 2021-01-01T00:00:50Z | t1 | false | -| _time | tag | online | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | false | -| 2021-01-01T00:00:10Z | t2 | true | -| 2021-01-01T00:00:20Z | t2 | false | -| 2021-01-01T00:00:30Z | t2 | true | -| 2021-01-01T00:00:40Z | t2 | true | -| 2021-01-01T00:00:50Z | t2 | false | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | powerOn | *tag | +| -------------------- | -------- | ---- | +| 2021-01-01T00:00:00Z | true | t1 | +| 2021-01-01T00:00:10Z | true | t1 | +| 2021-01-01T00:00:20Z | false | t1 | +| 2021-01-01T00:00:30Z | true | t1 | +| 2021-01-01T00:00:40Z | false | t1 | +| 2021-01-01T00:00:50Z | false | t1 | + +| _time | powerOn | *tag | +| -------------------- | -------- | ---- | +| 2021-01-01T00:00:00Z | false | t2 | +| 2021-01-01T00:00:10Z | true | t2 | +| 2021-01-01T00:00:20Z | false | t2 | +| 2021-01-01T00:00:30Z | true | t2 | +| 2021-01-01T00:00:40Z | true | t2 | +| 2021-01-01T00:00:50Z | false | t2 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/bottom.md b/content/flux/v0.x/stdlib/universe/bottom.md index 26acf8c31..e7150df84 100644 --- a/content/flux/v0.x/stdlib/universe/bottom.md +++ b/content/flux/v0.x/stdlib/universe/bottom.md @@ -1,82 +1,114 @@ --- title: bottom() function -description: The `bottom()` function sorts a table by columns and keeps only the bottom n records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/bottom - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/bottom/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/bottom/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/bottom/ +description: > + `bottom()` sorts each input table by specified columns and keeps the bottom `n` + records in each table. menu: flux_0_x_ref: name: bottom parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#bottom, InfluxQL – BOTTOM() + identifier: universe/bottom +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `bottom()` function sorts a table by columns and keeps only the bottom `n` records. -_`bottom()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`bottom()` sorts each input table by specified columns and keeps the bottom `n` +records in each table. + +**Note:** `bottom()` drops empty tables. + +##### Function type signature ```js -bottom(n:10, columns: ["_value"]) +(<-tables: stream[A], n: int, ?columns: [string]) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`bottom()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} -Number of records to return. +### n +({{< req >}}) +Number of rows to return from each input table. + + + +### columns + +List of columns to sort by. Default is `["_value"]`. -### columns {data-type="array of strings"} -List of columns by which to sort. Sort precedence is determined by list order (left to right). -Default is `["_value"]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} -#### Return rows with the two lowest values +### Return rows with the two lowest values in each input table + ```js import "sampledata" sampledata.int() - |> bottom(n:2) + |> bottom(n: 2) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/buckets.md b/content/flux/v0.x/stdlib/universe/buckets.md deleted file mode 100644 index 884244015..000000000 --- a/content/flux/v0.x/stdlib/universe/buckets.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: buckets() function -description: The `buckets()` function returns a list of buckets in the organization. -aliases: - - /influxdb/v2.0/reference/flux/functions/inputs/buckets - - /influxdb/v2.0/reference/flux/functions/built-in/inputs/buckets/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/inputs/buckets/ - - /influxdb/cloud/reference/flux/stdlib/built-in/inputs/buckets/ -menu: - flux_0_x_ref: - name: buckets - parent: universe -weight: 102 -flux/v0.x/tags: [metadata] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-databases, InfluxQL - SHOW DATABASES]() -introduced: 0.16.0 ---- - -The `buckets()` function returns a list of buckets in the organization. - -```js -buckets() -``` diff --git a/content/flux/v0.x/stdlib/universe/bytes.md b/content/flux/v0.x/stdlib/universe/bytes.md index dfac974f1..327b86ee8 100644 --- a/content/flux/v0.x/stdlib/universe/bytes.md +++ b/content/flux/v0.x/stdlib/universe/bytes.md @@ -1,37 +1,60 @@ --- title: bytes() function -description: The `bytes()` function converts a single value to bytes. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/bytes/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/bytes/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/bytes/ +description: > + `bytes()` converts a string value to a bytes type. menu: flux_0_x_ref: name: bytes parent: universe -weight: 102 + identifier: universe/bytes +weight: 101 flux/v0.x/tags: [type-conversions] -related: - - /flux/v0.x/data-types/basic/bytes/ introduced: 0.40.0 --- -The `bytes()` function converts a single value to bytes. + + +`bytes()` converts a string value to a bytes type. + + + +##### Function type signature ```js -bytes(v: "1m") +(v: A) => bytes ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string"} -The value to convert. +### v +({{< req >}}) +Value to convert. + + + ## Examples + +### Convert a string to bytes + ```js -from(bucket: "sensor-data") - |> range(start: -1m) - |> map(fn: (r) => ({r with _value: bytes(v: r._value)})) +bytes(v: "Example string")// Returns 0x4578616d706c6520737472696e67 + ``` + diff --git a/content/flux/v0.x/stdlib/universe/chandemomentumoscillator.md b/content/flux/v0.x/stdlib/universe/chandemomentumoscillator.md index 2eeb31d5f..6e75f1329 100644 --- a/content/flux/v0.x/stdlib/universe/chandemomentumoscillator.md +++ b/content/flux/v0.x/stdlib/universe/chandemomentumoscillator.md @@ -1,61 +1,82 @@ --- title: chandeMomentumOscillator() function description: > - The `chandeMomentumOscillator()` function applies the technical momentum indicator - developed by Tushar Chande. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/chandemomentumoscillator/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/chandemomentumoscillator/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/chandemomentumoscillator/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/chandemomentumoscillator/ + `chandeMomentumOscillator()` applies the technical momentum indicator developed + by Tushar Chande to input data. menu: flux_0_x_ref: name: chandeMomentumOscillator parent: universe -weight: 102 + identifier: universe/chandeMomentumOscillator +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#triple-exponential-moving-average, InfluxQL CHANDE_MOMENTUM_OSCILLATOR() introduced: 0.39.0 --- -The `chandeMomentumOscillator()` function applies the technical momentum indicator -developed by Tushar Chande. + + +`chandeMomentumOscillator()` applies the technical momentum indicator developed +by Tushar Chande to input data. + +The Chande Momentum Oscillator (CMO) indicator does the following: + +1. Determines the median value of the each input table and calculates the + difference between the sum of rows with values greater than the median + and the sum of rows with values lower than the median. +2. Divides the result of step 1 by the sum of all data movement over a given + time period. +3. Multiplies the result of step 2 by 100 and returns a value between -100 and +100. + +#### Output tables +For each input table with `x` rows, `chandeMomentumOscillator()` outputs a +table with `x - n` rows. + +##### Function type signature ```js -chandeMomentumOscillator( - n: 10, - columns: ["_value"], -) +(<-tables: stream[A], n: int, ?columns: [string]) => stream[B] where A: Record, B: Record ``` -The Chande Momentum Oscillator (CMO) indicator calculates the difference between -the sum of all recent data points with values greater than the median value of the data set -and the sum of all recent data points with values lower than the median value of the data set, -then divides the result by the sum of all data movement over a given time period. -It then multiplies the result by 100 and returns a value between -100 and +100. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} -The period or number of points to use in the calculation. +### n +({{< req >}}) +Period or number of points to use in the calculation. + + + +### columns + +List of columns to operate on. Default is `["_value"]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -### columns {data-type="array of strings"} -The columns to operate on. -Defaults to `["_value"]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Output tables -For each input table with `x` rows, `chandeMomentumOscillator()` outputs a table -with `x - n` rows. ## Examples -#### Transform data with a two point Chande Momentum Oscillator -{{% flux/sample-example-intro %}} +### Apply the Chande Momentum Oscillator to input data ```js import "sampledata" @@ -64,31 +85,3 @@ sampledata.int() |> chandeMomentumOscillator(n: 2) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample set="int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| _time | tag | _value | -| :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:20Z | t1 | 60 | -| 2021-01-01T00:00:30Z | t1 | 53.84615384615385 | -| 2021-01-01T00:00:40Z | t1 | 66.66666666666667 | -| 2021-01-01T00:00:50Z | t1 | -100 | - -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:20Z | t2 | -100 | -| 2021-01-01T00:00:30Z | t2 | 51.724137931034484 | -| 2021-01-01T00:00:40Z | t2 | 57.142857142857146 | -| 2021-01-01T00:00:50Z | t2 | -100 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} diff --git a/content/flux/v0.x/stdlib/universe/columns.md b/content/flux/v0.x/stdlib/universe/columns.md index d3ad962dc..39607247e 100644 --- a/content/flux/v0.x/stdlib/universe/columns.md +++ b/content/flux/v0.x/stdlib/universe/columns.md @@ -1,52 +1,70 @@ --- title: columns() function description: > - The `columns()` function lists the column labels of input tables. - For each input table, it outputs a table with the same group key columns, - plus a new column containing the labels of the input table's columns. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/columns - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/columns/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/columns/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/columns/ + `columns()` returns the column labels in each input table. menu: flux_0_x_ref: name: columns parent: universe -weight: 102 -flux/v0.x/tags: [transformations, metadata] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-measurements, InfluxQL – SHOW MEASUREMENTS - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-field-keys, InfluxQL – SHOW FIELD KEYS - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW TAG KEYS - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW SERIES + identifier: universe/columns +weight: 101 +flux/v0.x/tags: [transformations] introduced: 0.14.0 --- -The `columns()` function lists the column labels of input tables. -For each input table, it outputs a table with the same group key columns, -plus a new column containing the labels of the input table's columns. -Each row in an output table contains the group key value and the label of one column of the input table. -Each output table has the same number of rows as the number of columns of the input table. + + +`columns()` returns the column labels in each input table. + +For each input table, `columns` outputs a table with the same group key +columns and a new column containing the column labels in the input table. +Each row in an output table contains the group key value and the label of one + column of the input table. +Each output table has the same number of rows as the number of columns of the +input table. + +##### Function type signature ```js -columns(column: "_value") +(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -The name of the output column in which to store the column labels. -Defaults to `"_value"`. +### column + +Name of the output column to store column labels in. +Default is "_value". + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} -#### List all columns per table +### List all columns per input table + ```js import "sampledata" @@ -54,29 +72,3 @@ sampledata.string() |> columns(column: "labels") ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "string" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| tag | labels | -| :-- | -----: | -| t1 | _time | -| t1 | tag | -| t1 | _value | - -| tag | labels | -| :-- | -----: | -| t2 | _time | -| t2 | tag | -| t2 | _value | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} diff --git a/content/flux/v0.x/stdlib/universe/contains.md b/content/flux/v0.x/stdlib/universe/contains.md index 6c6494736..07c603c7a 100644 --- a/content/flux/v0.x/stdlib/universe/contains.md +++ b/content/flux/v0.x/stdlib/universe/contains.md @@ -1,96 +1,121 @@ --- title: contains() function -description: The `contains()` function tests whether a value is a member of a set. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/tests/contains/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/tests/contains/ - - /influxdb/cloud/reference/flux/stdlib/built-in/tests/contains/ +description: > + `contains()` tests if an array contains a specified value and returns `true` or `false`. menu: flux_0_x_ref: name: contains parent: universe -weight: 102 -related: - - /flux/v0.x/data-types/composite/array/ -flux/v0.x/tags: [tests] + identifier: universe/contains +weight: 101 + introduced: 0.19.0 --- -The `contains()` function tests whether a value is a member of a set. -If the value is a member of the set, the function returns `true`. -If the value is not a member of the set, the functions returns `false`. + + +`contains()` tests if an array contains a specified value and returns `true` or `false`. + + + +##### Function type signature ```js -contains( - value: 1, - set: [1,2,3], -) +(set: [A], value: A) => bool where A: Nullable ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### value {data-type="string, bool, time, int, uint, float"} +### value +({{< req >}}) Value to search for. -### set {data-type="array"} -Set of values to search in. + + +### set +({{< req >}}) +Array to search. + + + ## Examples -#### Filter on a set of specific fields +### Filter on a set of specific fields + ```js -import "influxdata/influxdb/sample" +fields = ["f1", "f2"] -fields = ["temperature", "humidity"] - -sample.data(set: "airSensor") - |> range(start: -30m) +data |> filter(fn: (r) => contains(value: r._field, set: fields)) ``` -{{% expand "View example input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Example input data -| _time | _field | _value | -| :------------------- | :---------- | -----: | -| 2020-01-01T00:00:00Z | temperature | 74.1 | -| 2020-01-01T00:01:00Z | temperature | 73.9 | -| 2020-01-01T00:02:00Z | temperature | 74.0 | -| 2020-01-01T00:03:00Z | temperature | 74.2 | +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| _time | _field | _value | -| :------------------- | :------- | -----: | -| 2020-01-01T00:00:00Z | humidity | 35.5 | -| 2020-01-01T00:01:00Z | humidity | 35.4 | -| 2020-01-01T00:02:00Z | humidity | 35.5 | -| 2020-01-01T00:03:00Z | humidity | 35.6 | +#### Input data -| _time | _field | _value | -| :------------------- | :----- | -----: | -| 2020-01-01T00:00:00Z | co | 0.65 | -| 2020-01-01T00:01:00Z | co | 0.66 | -| 2020-01-01T00:02:00Z | co | 0.66 | -| 2020-01-01T00:03:00Z | co | 0.67 | +| *_field | _measurement | _time | _value | *tag | +| ------- | ------------- | -------------------- | ------- | ---- | +| f1 | m | 2021-01-01T00:00:00Z | -2 | t1 | +| f1 | m | 2021-01-01T00:00:50Z | 4 | t1 | -{{% /flex-content %}} -{{% flex-content %}} +| *_field | _measurement | _time | _value | *tag | +| ------- | ------------- | -------------------- | ------- | ---- | +| f1 | m | 2021-01-01T00:00:10Z | 4 | t2 | +| f1 | m | 2021-01-01T00:00:20Z | -3 | t2 | +| f1 | m | 2021-01-01T00:00:50Z | 1 | t2 | -##### Example output data -| _time | _field | _value | -| :------------------- | :---------- | -----: | -| 2020-01-01T00:00:00Z | temperature | 74.1 | -| 2020-01-01T00:01:00Z | temperature | 73.9 | -| 2020-01-01T00:02:00Z | temperature | 74.0 | -| 2020-01-01T00:03:00Z | temperature | 74.2 | +| *_field | _measurement | _time | _value | *tag | +| ------- | ------------- | -------------------- | ------- | ---- | +| f2 | m | 2021-01-01T00:00:10Z | 10 | t1 | +| f2 | m | 2021-01-01T00:00:20Z | 7 | t1 | -| _time | _field | _value | -| :------------------- | :------- | -----: | -| 2020-01-01T00:00:00Z | humidity | 35.5 | -| 2020-01-01T00:01:00Z | humidity | 35.4 | -| 2020-01-01T00:02:00Z | humidity | 35.5 | -| 2020-01-01T00:03:00Z | humidity | 35.6 | +| *_field | _measurement | _time | _value | *tag | +| ------- | ------------- | -------------------- | ------- | ---- | +| f3 | m | 2021-01-01T00:00:30Z | 17 | t1 | +| f3 | m | 2021-01-01T00:00:40Z | 15 | t1 | -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} \ No newline at end of file +| *_field | _measurement | _time | _value | *tag | +| ------- | ------------- | -------------------- | ------- | ---- | +| f3 | m | 2021-01-01T00:00:00Z | 19 | t2 | +| f3 | m | 2021-01-01T00:00:30Z | 19 | t2 | +| f3 | m | 2021-01-01T00:00:40Z | 13 | t2 | + + +#### Output data + +| *_field | _measurement | _time | _value | *tag | +| ------- | ------------- | -------------------- | ------- | ---- | +| f1 | m | 2021-01-01T00:00:00Z | -2 | t1 | +| f1 | m | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_field | _measurement | _time | _value | *tag | +| ------- | ------------- | -------------------- | ------- | ---- | +| f1 | m | 2021-01-01T00:00:10Z | 4 | t2 | +| f1 | m | 2021-01-01T00:00:20Z | -3 | t2 | +| f1 | m | 2021-01-01T00:00:50Z | 1 | t2 | + +| *_field | _measurement | _time | _value | *tag | +| ------- | ------------- | -------------------- | ------- | ---- | +| f2 | m | 2021-01-01T00:00:10Z | 10 | t1 | +| f2 | m | 2021-01-01T00:00:20Z | 7 | t1 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/count.md b/content/flux/v0.x/stdlib/universe/count.md index 27fa60761..51ab174fb 100644 --- a/content/flux/v0.x/stdlib/universe/count.md +++ b/content/flux/v0.x/stdlib/universe/count.md @@ -1,59 +1,75 @@ --- title: count() function -description: The `count()` function outputs the number of non-null records in a column. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/count - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/count/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/count/ +description: > + `count()` returns the number of records in a column. menu: flux_0_x_ref: name: count parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#count, InfluxQL – COUNT() - - /flux/v0.x/stdlib/experimental/count/ + identifier: universe/count +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `count()` function outputs the number of records in a column. -It counts both null and non-null records. -_`count()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`count()` returns the number of records in a column. + +The function counts both null and non-null records. -{{% note %}} #### Empty tables `count()` returns `0` for empty tables. -To keep empty tables in your data, set the following parameters for the following functions: +To keep empty tables in your data, set the following parameters for the +following functions: -| Function | Parameter | -| :--------------------------------------------------------------- | :------------------ | -| [filter()](/flux/v0.x/stdlib/universe/filter/) | `onEmpty: "keep"` | -| [window()](/flux/v0.x/stdlib/universe/window/) | `createEmpty: true` | -| [aggregateWindow()](/flux/v0.x/stdlib/universe/aggregatewindow/) | `createEmpty: true` | -{{% /note %}} +| Function | Parameter | +| :------------------ | :------------------ | +| `filter()` | `onEmpty: "keep"` | +| `window()` | `createEmpty: true` | +| `aggregateWindow()` | `createEmpty: true` | + +##### Function type signature + +```js +(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -The column on which to operate. -Defaults to `"_value"`. +### column + +Column to count values in and store the total count. + + + +### tables + +Input data. Default is piped-wforward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} -#### Count the number of rows in each input table +### Count the number of rows in each input table + ```js import "sampledata" @@ -61,25 +77,3 @@ sampledata.string() |> count() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "string" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | 6 | - -| tag | _value | -| :-- | -----: | -| t2 | 6 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} diff --git a/content/flux/v0.x/stdlib/universe/cov.md b/content/flux/v0.x/stdlib/universe/cov.md index a483d3f33..f48876467 100644 --- a/content/flux/v0.x/stdlib/universe/cov.md +++ b/content/flux/v0.x/stdlib/universe/cov.md @@ -1,106 +1,98 @@ --- title: cov() function -description: The `cov()` function computes the covariance between two streams by first joining the streams, then performing the covariance operation. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/cov - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/cov/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/cov/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/cov/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/cov/ +description: > + `cov()` computes the covariance between two streams of tables. menu: flux_0_x_ref: name: cov parent: universe -weight: 102 -flux/v0.x/tags: [transformations] + identifier: universe/cov +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `cov()` function computes the covariance between two streams by first joining the streams, -then performing the covariance operation. + + +`cov()` computes the covariance between two streams of tables. + + + +##### Function type signature ```js -cov(x: stream1, y: stream2, on: ["_time", "_field"], pearsonr: false) +(on: [string], x: A, y: B, ?pearsonr: bool) => stream[C] where C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### x {data-type="stream of tables"} +### x ({{< req >}}) -First input stream used to calculate the covariance. -Values in the `_value` columns must be [float values](/flux/v0.x/data-types/basic/float/). +First input stream. -### y {data-type="stream of tables"} + + +### y ({{< req >}}) -Second input stream used to calculate the covariance. -Values in the `_value` columns must be [float values](/flux/v0.x/data-types/basic/float/). +Second input stream. -### on {data-type="array of strings"} + + +### on ({{< req >}}) List of columns to join on. -### pearsonr {data-type="bool"} -Normalize results to the Pearson R coefficient. -Default is `false`. + + +### pearsonr + +Normalize results to the Pearson R coefficient. Default is `false`. + + + ## Examples -The following example uses [`generate.from()`](/flux/v0.x/stdlib/generate/from/) -to generate sample data and show how `cov()` transforms data. + +### Return the covariance between two streams of tables ```js import "generate" -stream1 = generate.from( - count: 5, - fn: (n) => n * n, - start: 2021-01-01T00:00:00Z, - stop: 2021-01-01T00:01:00Z, -) - |> toFloat() +stream1 = + generate.from(count: 5, fn: (n) => n * n, start: 2021-01-01T00:00:00Z, stop: 2021-01-01T00:01:00Z) + |> toFloat() -stream2 = generate.from( - count: 5, - fn: (n) => n * n * n / 2, - start: 2021-01-01T00:00:00Z, - stop: 2021-01-01T00:01:00Z, -) - |> toFloat() +stream2 = + generate.from(count: 5, fn: (n) => n * n * n / 2, start: 2021-01-01T00:00:00Z, stop: 2021-01-01T00:01:00Z) + |> toFloat() cov(x: stream1, y: stream2, on: ["_time"]) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} - -#### Input data -{{< flex >}} -{{% flex-content %}} -##### stream1 -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T00:00:00Z | 0.0 | -| 2021-01-01T00:00:12Z | 1.0 | -| 2021-01-01T00:00:24Z | 4.0 | -| 2021-01-01T00:00:36Z | 9.0 | -| 2021-01-01T00:00:48Z | 16.0 | -{{% /flex-content %}} -{{% flex-content %}} -##### stream2 -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T00:00:00Z | 0.0 | -| 2021-01-01T00:00:12Z | 0.0 | -| 2021-01-01T00:00:24Z | 4.0 | -| 2021-01-01T00:00:36Z | 13.0 | -| 2021-01-01T00:00:48Z | 32.0 | -{{% /flex-content %}} -{{< /flex >}} +{{% expand "View example output" %}} #### Output data -| _value | -| -----: | -| 87.75 | + +| _value | +| ------- | +| 87.75 | {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/covariance.md b/content/flux/v0.x/stdlib/universe/covariance.md index 5c17f6b06..1580679a3 100644 --- a/content/flux/v0.x/stdlib/universe/covariance.md +++ b/content/flux/v0.x/stdlib/universe/covariance.md @@ -1,84 +1,100 @@ --- title: covariance() function -description: The `covariance()` function computes the covariance between two columns. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/covariance - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/covariance/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/covariance/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/covariance/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/covariance/ +description: > + `covariance()` computes the covariance between two columns. menu: flux_0_x_ref: name: covariance parent: universe -weight: 102 -flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/cov/ + identifier: universe/covariance +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `covariance()` function computes the covariance between two columns. - -_**Output data type:** Float_ + + +`covariance()` computes the covariance between two columns. + + + +##### Function type signature ```js -covariance(columns: ["column_x", "column_y"], pearsonr: false, valueDst: "_value") +(<-tables: stream[A], columns: [string], ?pearsonr: bool, ?valueDst: string) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### columns {data-type="array of strings"} -({{< req >}}) A list of **two columns** on which to operate. +### columns +({{< req >}}) +List of two columns to operate on. + + + +### pearsonr + +Normalize results to the Pearson R coefficient. Default is `false`. + + + +### valueDst + +Column to store the result in. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -### pearsonr {data-type="bool"} -Normalized results to the Pearson R coefficient. -Default is `false`. -### valueDst {data-type="string"} -The column into which the result will be placed. -Defaults to `"_value"`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -The following example uses [`generate.from()`](/flux/v0.x/stdlib/generate/from/) -to generate sample data and show how `covariance()` transforms data. + +### Calculate the covariance between two columns ```js -import "generate" - -data = generate.from(count: 5, fn: (n) => n * n, start: 2021-01-01T00:00:00Z, stop: 2021-01-01T00:01:00Z) - |> toFloat() - |> map(fn: (r) => ({_time: r._time, x: r._value, y: r._value * r._value / 2.0})) - data |> covariance(columns: ["x", "y"]) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -| _time | x | y | -| :------------------- | ---: | ----: | -| 2021-01-01T00:00:00Z | 0.0 | 0.0 | -| 2021-01-01T00:00:12Z | 1.0 | 0.5 | -| 2021-01-01T00:00:24Z | 4.0 | 8.0 | -| 2021-01-01T00:00:36Z | 9.0 | 40.5 | -| 2021-01-01T00:00:48Z | 16.0 | 128.0 | +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | x | y | +| -------------------- | -- | ---- | +| 2021-01-01T00:00:00Z | 0 | 0 | +| 2021-01-01T00:00:12Z | 1 | 0.5 | +| 2021-01-01T00:00:24Z | 4 | 8 | +| 2021-01-01T00:00:36Z | 9 | 40.5 | +| 2021-01-01T00:00:48Z | 16 | 128 | -##### Output data -| _value | -| -----: | -| 345.75 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _value | +| ------- | +| 345.75 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/cumulativesum.md b/content/flux/v0.x/stdlib/universe/cumulativesum.md index 2fb92cc8c..9de8bee8d 100644 --- a/content/flux/v0.x/stdlib/universe/cumulativesum.md +++ b/content/flux/v0.x/stdlib/universe/cumulativesum.md @@ -1,80 +1,114 @@ --- title: cumulativeSum() function -description: The `cumulativeSum()` function computes a running sum for non-null records in the table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/cumulativesum - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/cumulativesum/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/cumulativesum/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/cumulativesum/ +description: > + `cumulativeSum()` computes a running sum for non-null records in a table. menu: flux_0_x_ref: name: cumulativeSum parent: universe -weight: 102 + identifier: universe/cumulativeSum +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/cumulativesum/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#cumulative-sum, InfluxQL – CUMULATIVE_SUM() introduced: 0.7.0 --- -The `cumulativeSum()` function computes a running sum for non-null records in the table. + + +`cumulativeSum()` computes a running sum for non-null records in a table. + The output table schema will be the same as the input table. -_**Output data type:** Float_ +##### Function type signature ```js -cumulativeSum(columns: ["_value"]) +(<-tables: stream[A], ?columns: [string]) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### columns {data-type="array of strings"} -A list of columns on which to operate. -Defaults to `["_value"]`. +### columns + +List of columns to operate on. Default is `["_value"]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the running total of values in each table ```js import "sampledata" -sampledata.string() +sampledata.int() |> cumulativeSum() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -{{% flux/sample set="int" %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -{{% /flex-content %}} -{{% flex-content %}} +#### Input data -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 8 | -| 2021-01-01T00:00:20Z | t1 | 15 | -| 2021-01-01T00:00:30Z | t1 | 32 | -| 2021-01-01T00:00:40Z | t1 | 47 | -| 2021-01-01T00:00:50Z | t1 | 51 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 23 | -| 2021-01-01T00:00:20Z | t2 | 20 | -| 2021-01-01T00:00:30Z | t2 | 39 | -| 2021-01-01T00:00:40Z | t2 | 52 | -| 2021-01-01T00:00:50Z | t2 | 53 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 8 | t1 | +| 2021-01-01T00:00:20Z | 15 | t1 | +| 2021-01-01T00:00:30Z | 32 | t1 | +| 2021-01-01T00:00:40Z | 47 | t1 | +| 2021-01-01T00:00:50Z | 51 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 23 | t2 | +| 2021-01-01T00:00:20Z | 20 | t2 | +| 2021-01-01T00:00:30Z | 39 | t2 | +| 2021-01-01T00:00:40Z | 52 | t2 | +| 2021-01-01T00:00:50Z | 53 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/derivative.md b/content/flux/v0.x/stdlib/universe/derivative.md index 22b248fce..e7689493c 100644 --- a/content/flux/v0.x/stdlib/universe/derivative.md +++ b/content/flux/v0.x/stdlib/universe/derivative.md @@ -1,113 +1,100 @@ --- title: derivative() function -description: The `derivative()` function computes the rate of change per unit of time between subsequent non-null records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/derivative - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/derivative/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/derivative/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/derivative/ +description: > + `derivative()` computes the rate of change per unit of time between subsequent + non-null records. menu: flux_0_x_ref: name: derivative parent: universe -weight: 102 + identifier: universe/derivative +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/rate/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#derivative, InfluxQL – DERIVATIVE() introduced: 0.7.0 --- -The `derivative()` function computes the rate of change per [`unit`](#unit) of time between subsequent non-null records. -It assumes rows are ordered by the `_time` column. -The output table schema is the same as the input table. - -_**Output data type:** Float_ + + +`derivative()` computes the rate of change per unit of time between subsequent +non-null records. + +The function assumes rows are ordered by the `_time`. + +#### Output tables +The output table schema will be the same as the input table. +For each input table with `n` rows, `derivative()` outputs a table with +`n - 1` rows. + +##### Function type signature ```js -derivative( - unit: 1s, - nonNegative: false, - columns: ["_value"], - timeColumn: "_time", -) +( + <-tables: stream[A], + ?columns: [string], + ?nonNegative: bool, + ?timeColumn: string, + ?unit: duration, +) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### unit {data-type="duration"} -The time duration used when creating the derivative. -Default is `1s`. +### unit -### nonNegative {data-type="bool"} -Indicates if the derivative is allowed to be negative. Default is `false`. -When `true`, if a value is less than the previous value, it is assumed the -previous value should have been a zero. +Time duration used to calculate the derivative. Default is `1s`. -### columns {data-type="string"} -The columns to use to compute the derivative. -Default is `["_value"]`. -### timeColumn {data-type="string"} -The column containing time values. -Default is `"_time"`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### nonNegative + +Disallow negative derivative values. Default is `false`. + +When `true`, if a value is less than the previous value, the function +assumes the previous value should have been a zero. + +### columns + +List of columns to operate on. Default is `["_value"]`. + + + +### timeColumn + +Column containing time values to use in the calculation. +Default is `_time`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -## Output tables -For each input table with `n` rows, `derivative()` outputs a table with `n - 1` rows. ## Examples -{{% flux/sample-example-intro plural=true %}} -- [Calculate the rate of change per second](#calculate-the-rate-of-change-per-second) - [Calculate the non-negative rate of change per second](#calculate-the-non-negative-rate-of-change-per-second) - [Calculate the rate of change per second with null values](#calculate-the-rate-of-change-per-second-with-null-values) -#### Calculate the rate of change per second -```js -import "sampledata" +### Calculate the non-negative rate of change per second -sampledata.int() - |> derivative() -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample set="int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t1 | 1.2 | -| 2021-01-01T00:00:20Z | t1 | -0.3 | -| 2021-01-01T00:00:30Z | t1 | 1 | -| 2021-01-01T00:00:40Z | t1 | -0.2 | -| 2021-01-01T00:00:50Z | t1 | -1.1 | - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | -1.5 | -| 2021-01-01T00:00:20Z | t2 | -0.7 | -| 2021-01-01T00:00:30Z | t2 | 2.2 | -| 2021-01-01T00:00:40Z | t2 | -0.6 | -| 2021-01-01T00:00:50Z | t2 | -1.2 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} - -#### Calculate the non-negative rate of change per second ```js import "sampledata" @@ -116,72 +103,100 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t1 | 1.2 | -| 2021-01-01T00:00:20Z | t1 | | -| 2021-01-01T00:00:30Z | t1 | 1 | -| 2021-01-01T00:00:40Z | t1 | | -| 2021-01-01T00:00:50Z | t1 | | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | | -| 2021-01-01T00:00:20Z | t2 | | -| 2021-01-01T00:00:30Z | t2 | 2.2 | -| 2021-01-01T00:00:40Z | t2 | | -| 2021-01-01T00:00:50Z | t2 | | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 1.2 | t1 | +| 2021-01-01T00:00:20Z | | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | | t2 | +| 2021-01-01T00:00:20Z | | t2 | +| 2021-01-01T00:00:30Z | 2.2 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | | t2 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Calculate the rate of change per second with null values +### Calculate the rate of change per second with null values + ```js import "sampledata" sampledata.int(includeNull: true) |> derivative() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -{{% flux/sample "int" true %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -{{% /flex-content %}} -{{% flex-content %}} +#### Input data -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t1 | | -| 2021-01-01T00:00:20Z | t1 | 0.45 | -| 2021-01-01T00:00:30Z | t1 | | -| 2021-01-01T00:00:40Z | t1 | | -| 2021-01-01T00:00:50Z | t1 | -0.1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | | -| 2021-01-01T00:00:20Z | t2 | -0.7 | -| 2021-01-01T00:00:30Z | t2 | 2.2 | -| 2021-01-01T00:00:40Z | t2 | | -| 2021-01-01T00:00:50Z | t2 | -0.9 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 0.45 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | -0.1 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | | t2 | +| 2021-01-01T00:00:20Z | -0.7 | t2 | +| 2021-01-01T00:00:30Z | 2.2 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | -0.9 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/die.md b/content/flux/v0.x/stdlib/universe/die.md new file mode 100644 index 000000000..3c838b2c0 --- /dev/null +++ b/content/flux/v0.x/stdlib/universe/die.md @@ -0,0 +1,59 @@ +--- +title: die() function +description: > + `die()` stops the Flux script execution and returns an error message. +menu: + flux_0_x_ref: + name: die + parent: universe + identifier: universe/die +weight: 101 + +introduced: 0.82.0 +--- + + + +`die()` stops the Flux script execution and returns an error message. + + + +##### Function type signature + +```js +(msg: string) => A +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### msg +({{< req >}}) +Error message to return. + + + + +## Examples + +### Force a script to exit with an error message + +```js +die(msg: "This is an error message") +``` + diff --git a/content/flux/v0.x/stdlib/universe/difference.md b/content/flux/v0.x/stdlib/universe/difference.md index 74136287e..03bbb7fe6 100644 --- a/content/flux/v0.x/stdlib/universe/difference.md +++ b/content/flux/v0.x/stdlib/universe/difference.md @@ -1,216 +1,270 @@ --- title: difference() function -description: The `difference()` function computes the difference between subsequent non-null records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/difference - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/difference/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/difference/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/difference/ +description: > + `difference()` returns the difference between subsequent values. menu: flux_0_x_ref: name: difference parent: universe -weight: 102 + identifier: universe/difference +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#difference, InfluxQL – DIFFERENCE() introduced: 0.7.1 --- -The `difference()` function computes the difference between subsequent records. -The user-specified columns of numeric type are subtracted while others are kept intact. + -### keepFirst {data-type="bool"} -Indicates the first row should be kept. -If `true`, the difference will be `null`. -Default is `false`. +`difference()` returns the difference between subsequent values. -### initialZero {data-type="bool"} -Use zero (`0`) as the initial value in the difference calculation when the -subsequent value is less than the previous value and [`nonNegative`](#nonnegative) -is `true`. -Default is `false`. - -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). - -## Subtraction rules for numeric types +### Subtraction rules for numeric types - The difference between two non-null values is their algebraic difference; or `null`, if the result is negative and `nonNegative: true`; - `null` minus some value is always `null`; -- Some value `v` minus `null` is `v` minus the last non-null value seen before `v`; - or `null` if `v` is the first non-null value seen. -- If `nonNegative` and `initialZero` are set to true, `difference()` returns the - difference between 0 and the subsequent value. If the subsequent value is - less than zero, `difference()` returns _null_. +- Some value `v` minus `null` is `v` minus the last non-null value seen + before `v`; or `null` if `v` is the first non-null value seen. +- If `nonNegative` and `initialZero` are set to `true`, `difference()` + returns the difference between `0` and the subsequent value. + If the subsequent value is less than zero, `difference()` returns `null`. + +### Output tables +For each input table with `n` rows, `difference()` outputs a table with +`n - 1` rows. + +##### Function type signature + +```js +( + <-tables: stream[A], + ?columns: [string], + ?initialZero: bool, + ?keepFirst: bool, + ?nonNegative: bool, +) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### nonNegative + +Disallow negative differences. Default is `false`. + +When `true`, if a value is less than the previous value, the function +assumes the previous value should have been a zero. + +### columns + +List of columns to operate on. Default is `["_value"]`. + + + +### keepFirst + +Keep the first row in each input table. Default is `false`. + +If `true`, the difference of the first row of each output table is null. + +### initialZero + +Use zero (0) as the initial value in the difference calculation +when the subsequent value is less than the previous value and `nonNegative` is +`true`. Default is `false`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -## Output tables -For each input table with `n` rows, `difference()` outputs a table with `n - 1` rows. ## Examples -{{% flux/sample-example-intro plural=true %}} - [Calculate the difference between subsequent values](#calculate-the-difference-between-subsequent-values) - [Calculate the non-negative difference between subsequent values](#calculate-the-non-negative-difference-between-subsequent-values) - [Calculate the difference between subsequent values with null values](#calculate-the-difference-between-subsequent-values-with-null-values) - [Keep the first value when calculating the difference between values](#keep-the-first-value-when-calculating-the-difference-between-values) -#### Calculate the difference between subsequent values +### Calculate the difference between subsequent values ```js import "sampledata" -data = sampledata.int() - -data +sampledata.int() |> difference() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t1 | 12 | -| 2021-01-01T00:00:20Z | t1 | -3 | -| 2021-01-01T00:00:30Z | t1 | 10 | -| 2021-01-01T00:00:40Z | t1 | -2 | -| 2021-01-01T00:00:50Z | t1 | -11 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | -15 | -| 2021-01-01T00:00:20Z | t2 | -7 | -| 2021-01-01T00:00:30Z | t2 | 22 | -| 2021-01-01T00:00:40Z | t2 | -6 | -| 2021-01-01T00:00:50Z | t2 | -12 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 12 | t1 | +| 2021-01-01T00:00:20Z | -3 | t1 | +| 2021-01-01T00:00:30Z | 10 | t1 | +| 2021-01-01T00:00:40Z | -2 | t1 | +| 2021-01-01T00:00:50Z | -11 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | -15 | t2 | +| 2021-01-01T00:00:20Z | -7 | t2 | +| 2021-01-01T00:00:30Z | 22 | t2 | +| 2021-01-01T00:00:40Z | -6 | t2 | +| 2021-01-01T00:00:50Z | -12 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Calculate the non-negative difference between subsequent values +### Calculate the non-negative difference between subsequent values + ```js import "sampledata" -data = sampledata.int() - -data - |> difference(nonNegative: true): +sampledata.int() + |> difference(nonNegative: true) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t1 | 12 | -| 2021-01-01T00:00:20Z | t1 | | -| 2021-01-01T00:00:30Z | t1 | 10 | -| 2021-01-01T00:00:40Z | t1 | | -| 2021-01-01T00:00:50Z | t1 | | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | | -| 2021-01-01T00:00:20Z | t2 | | -| 2021-01-01T00:00:30Z | t2 | 22 | -| 2021-01-01T00:00:40Z | t2 | | -| 2021-01-01T00:00:50Z | t2 | | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 12 | t1 | +| 2021-01-01T00:00:20Z | | t1 | +| 2021-01-01T00:00:30Z | 10 | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | | t2 | +| 2021-01-01T00:00:20Z | | t2 | +| 2021-01-01T00:00:30Z | 22 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | | t2 | + {{% /expand %}} {{< /expand-wrapper >}} +### Calculate the difference between subsequent values with null values -#### Calculate the difference between subsequent values with null values ```js import "sampledata" -data = sampledata.int(includeNull: true) - -data +sampledata.int(includeNull: true) |> difference() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" true %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t1 | | -| 2021-01-01T00:00:20Z | t1 | 9 | -| 2021-01-01T00:00:30Z | t1 | | -| 2021-01-01T00:00:40Z | t1 | | -| 2021-01-01T00:00:50Z | t1 | -3 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | | -| 2021-01-01T00:00:20Z | t2 | -7 | -| 2021-01-01T00:00:30Z | t2 | 22 | -| 2021-01-01T00:00:40Z | t2 | | -| 2021-01-01T00:00:50Z | t2 | -18 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 9 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | -3 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | | t2 | +| 2021-01-01T00:00:20Z | -7 | t2 | +| 2021-01-01T00:00:30Z | 22 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | -18 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Keep the first value when calculating the difference between values +### Keep the first value when calculating the difference between values + ```js import "sampledata" @@ -218,36 +272,49 @@ sampledata.int() |> difference(keepFirst: true) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | | -| 2021-01-01T00:00:10Z | t1 | 12 | -| 2021-01-01T00:00:20Z | t1 | -3 | -| 2021-01-01T00:00:30Z | t1 | 10 | -| 2021-01-01T00:00:40Z | t1 | -2 | -| 2021-01-01T00:00:50Z | t1 | -11 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | tw | | -| 2021-01-01T00:00:10Z | t2 | -15 | -| 2021-01-01T00:00:20Z | t2 | -7 | -| 2021-01-01T00:00:30Z | t2 | 22 | -| 2021-01-01T00:00:40Z | t2 | -6 | -| 2021-01-01T00:00:50Z | t2 | -12 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t1 | +| 2021-01-01T00:00:10Z | 12 | t1 | +| 2021-01-01T00:00:20Z | -3 | t1 | +| 2021-01-01T00:00:30Z | 10 | t1 | +| 2021-01-01T00:00:40Z | -2 | t1 | +| 2021-01-01T00:00:50Z | -11 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | -15 | t2 | +| 2021-01-01T00:00:20Z | -7 | t2 | +| 2021-01-01T00:00:30Z | 22 | t2 | +| 2021-01-01T00:00:40Z | -6 | t2 | +| 2021-01-01T00:00:50Z | -12 | t2 | + {{% /expand %}} - +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/display.md b/content/flux/v0.x/stdlib/universe/display.md index efd71e565..dd5f90f8c 100644 --- a/content/flux/v0.x/stdlib/universe/display.md +++ b/content/flux/v0.x/stdlib/universe/display.md @@ -6,123 +6,132 @@ menu: flux_0_x_ref: name: display parent: universe -weight: 102 + identifier: universe/display +weight: 101 + introduced: 0.154.0 --- + + `display()` returns the Flux literal representation of any value as a string. -```js -display(v: "example value") -``` - -[Basic types](/flux/v0.x/data-types/basic/) are converted directly to a string. -[Bytes types](/flux/v0.x/data-types/basic/bytes/) are represented as a string of -lowercase hexadecimal characters prefixed with `0x`. -[Composite types](/flux/v0.x/data-types/composite/) (arrays, dictionaries, and records) -are represented in a syntax similar to their equivalent Flux literal representation. +Basic types are converted directly to a string. +Bytes types are represented as a string of lowercase hexadecimal characters prefixed with `0x`. +Composite types (arrays, dictionaries, and records) are represented in a syntax similar +to their equivalent Flux literal representation. Note the following about the resulting string representation: - - It cannot always be parsed back into the original value. - It may span multiple lines. - It may change between Flux versions. -{{% note %}} -`display()` differs from [`string()`](/flux/v0.x/stdlib/universe/string/) in -that `display()` recursively converts values inside composite types to strings. -`string()` does not operate on composite types. -{{% /note %}} +`display()` differs from `string()` in that `display()` recursively converts values inside +composite types to strings. `string()` does not operate on composite types. + +##### Function type signature + +```js +(v: A) => string +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters ### v +({{< req >}}) Value to convert for display. + + + ## Examples -- [Display composite values as part of a table](#display-composite-values-as-part-of-a-table) +- [Display a value as part of a table](#display-a-value-as-part-of-a-table) - [Display a record](#display-a-record) - [Display an array](#display-an-array) - [Display a dictionary](#display-a-dictionary) - [Display bytes](#display-bytes) - [Display a composite value](#display-a-composite-value) -### Display composite values as part of a table -Use [`array.from()`](/flux/v0.x/stdlib/array/from/) and `display()` to quickly -observe any value. +### Display a value as part of a table + +Use `array.from()` and `display()` to quickly observe any value. ```js import "array" -array.from( - rows: [ - { - dict: display(v: ["a":1, "b": 2]), - record: display(v:{x: 1, y: 2}), - array: display(v: [5,6,7]) - } - ] -) +array.from(rows: [{dict: display(v: ["a": 1, "b": 2]), record: display(v: {x: 1, y: 2}), array: display(v: [5, 6, 7])}]) ``` -#### Output data -| dict | record | array | -| :----------- | :----------- | :-------- | -| [a: 1, b: 2] | {x: 1, y: 2} | [5, 6, 7] | ### Display a record + ```js x = {a: 1, b: 2, c: 3} -display(v: x) +display(v: x)// Returns {a: 1, b: 2, c: 3} -// Returns {a: 1, b: 2, c: 3} ``` + ### Display an array + ```js x = [1, 2, 3] -display(v: x) +display(v: x)// Returns [1, 2, 3] -// Returns [1, 2, 3] ``` + ### Display a dictionary + ```js x = ["a": 1, "b": 2, "c": 3] -display(v: x) +display(v: x)// Returns [a: 1, b: 2, c: 3] -// Returns [a: 1, b: 2, c: 3] ``` + ### Display bytes + ```js -x = bytes(v:"abc") +x = bytes(v: "abc") -display(v: x) +display(v: x)// Returns 0x616263 -// Returns 0x616263 ``` + ### Display a composite value + ```js -x = { - bytes: bytes(v: "abc"), - string: "str", - array: [1,2,3], - dict: ["a": 1, "b": 2, "c": 3], -} +x = {bytes: bytes(v: "abc"), string: "str", array: [1, 2, 3], dict: ["a": 1, "b": 2, "c": 3]} -display(v: x) - -// Returns +display(v: x)// Returns // { // array: [1, 2, 3], // bytes: 0x616263, // dict: [a: 1, b: 2, c: 3], // string: str // } -``` \ No newline at end of file + +``` + diff --git a/content/flux/v0.x/stdlib/universe/distinct.md b/content/flux/v0.x/stdlib/universe/distinct.md index e424d0386..a84f9e49c 100644 --- a/content/flux/v0.x/stdlib/universe/distinct.md +++ b/content/flux/v0.x/stdlib/universe/distinct.md @@ -1,94 +1,124 @@ --- title: distinct() function -description: The `distinct()` function returns the unique values for a given column. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/distinct - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/distinct/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/distinct/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/distinct/ +description: > + `distinct()` returns all unique values in a specified column. menu: flux_0_x_ref: name: distinct parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#distinct, InfluxQL – DISTINCT() + identifier: universe/distinct +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `distinct()` function returns the unique values for a given column. -The `_value` of each output record is set to the distinct value in the specified column. -`null` is considered its own distinct value if it is present. -_`distinct()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`distinct()` returns all unique values in a specified column. + +The `_value` of each output record is set to a distinct value in the specified column. +`null` is considered its own distinct value if present. + +##### Function type signature ```js -distinct(column: "host") +(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record ``` -{{% warn %}} -#### Empty tables -`distinct()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -Column to return unique values from. -Default is `_value`. +### column + +Column to return unique values from. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} -#### Return distinct values from the _value column +- [Return distinct values from the _value column](#return-distinct-values-from-the-_value-column) +- [Return distinct values from a non-default column](#return-distinct-values-from-a-non-default-column) +- [Return distinct values from data with null values](#return-distinct-values-from-data-with-null-values) + +### Return distinct values from the _value column + ```js import "sampledata" -data = sampledata.int() - -data +sampledata.int() |> distinct() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | -2 | -| t1 | 10 | -| t1 | 7 | -| t1 | 17 | -| t1 | 15 | -| t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | _value | -| :-- | -----: | -| t2 | 19 | -| t2 | 4 | -| t2 | -3 | -| t2 | 13 | -| t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | -2 | +| t1 | 10 | +| t1 | 7 | +| t1 | 17 | +| t1 | 15 | +| t1 | 4 | + +| *tag | _value | +| ---- | ------- | +| t2 | 19 | +| t2 | 4 | +| t2 | -3 | +| t2 | 13 | +| t2 | 1 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Return distinct values from a non-default column +### Return distinct values from a non-default column + ```js import "sampledata" @@ -97,31 +127,44 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | t1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | _value | -| :-- | -----: | -| t2 | t2 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | t1 | + +| *tag | _value | +| ---- | ------- | +| t2 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Return distinct values from with null values +### Return distinct values from data with null values + ```js import "sampledata" @@ -129,32 +172,46 @@ sampledata.int(includeNull: true) |> distinct() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" true %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | -2 | -| t1 | | -| t1 | 7 | -| t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | _value | -| :-- | -----: | -| t2 | | -| t2 | 4 | -| t2 | -3 | -| t2 | 19 | -| t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | -2 | +| t1 | | +| t1 | 7 | +| t1 | 4 | + +| *tag | _value | +| ---- | ------- | +| t2 | | +| t2 | 4 | +| t2 | -3 | +| t2 | 19 | +| t2 | 1 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/doubleema.md b/content/flux/v0.x/stdlib/universe/doubleema.md index a86db8caa..c3f30c94c 100644 --- a/content/flux/v0.x/stdlib/universe/doubleema.md +++ b/content/flux/v0.x/stdlib/universe/doubleema.md @@ -1,58 +1,74 @@ --- title: doubleEMA() function description: > - The `doubleEMA()` function calculates the exponential moving average of values - grouped into `n` number of points, giving more weight to recent data at double - the rate of `exponentialMovingAverage()`. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/doubleema/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/doubleema/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/doubleema/ + `doubleEMA()` returns the double exponential moving average (DEMA) of values in + the `_value` column grouped into `n` number of points, giving more weight to + recent data. menu: flux_0_x_ref: name: doubleEMA parent: universe -weight: 102 + identifier: universe/doubleEMA +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/movingaverage/ - - /flux/v0.x/stdlib/universe/tripleema/ - - /flux/v0.x/stdlib/universe/timedmovingaverage/ - - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#double-exponential-moving-average, InfluxQL DOUBLE_EXPONENTIAL_MOVING_AVERAGE() introduced: 0.38.0 --- -The `doubleEMA()` function calculates the exponential moving average of values in -the `_value` column grouped into `n` number of points, giving more weight to recent -data at double the rate of [`exponentialMovingAverage()`](/flux/v0.x/stdlib/universe/exponentialmovingaverage/). + + +`doubleEMA()` returns the double exponential moving average (DEMA) of values in +the `_value` column grouped into `n` number of points, giving more weight to +recent data. + +#### Double exponential moving average rules - A double exponential moving average is defined as `doubleEMA = 2 * EMA_N - EMA of EMA_N`. - `EMA` is an exponential moving average. - - `N = n` is the period used to calculate the EMA. + - `N = n` is the period used to calculate the `EMA`. - A true double exponential moving average requires at least `2 * n - 1` values. - If not enough values exist to calculate the double EMA, it returns a `NaN` value. -- `doubleEMA()` inherits all [exponential moving average rules](/flux/v0.x/stdlib/universe/exponentialmovingaverage/#exponential-moving-average-rules). + If not enough values exist to calculate the double `EMA`, it returns a `NaN` value. +- `doubleEMA()` inherits all `exponentialMovingAverage()` rules. + +##### Function type signature + +```js +(<-tables: stream[{A with _value: B}], n: int) => stream[C] where B: Numeric, C: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n +({{< req >}}) Number of points to average. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} -#### Calculate a three point double exponential moving average +### Calculate a three point double exponential moving average + ```js import "sampledata" @@ -61,28 +77,40 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:40Z | t1 | 16.627222222222223 | -| 2021-01-01T00:00:50Z | t1 | 8.301527777777778 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:40Z | t2 | 15.907222222222224 | -| 2021-01-01T00:00:50Z | t2 | 5.941527777777779 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:40Z | 16.333333333333336 | t1 | +| 2021-01-01T00:00:50Z | 7.916666666666668 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:40Z | 15.027777777777779 | t2 | +| 2021-01-01T00:00:50Z | 5.034722222222221 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/drop.md b/content/flux/v0.x/stdlib/universe/drop.md index 500bb2e69..438ce5829 100644 --- a/content/flux/v0.x/stdlib/universe/drop.md +++ b/content/flux/v0.x/stdlib/universe/drop.md @@ -1,103 +1,129 @@ --- title: drop() function -description: The `drop()` function removes specified columns from a table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/drop - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/drop/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/drop/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/drop/ +description: > + `drop()` removes specified columns from a table. menu: flux_0_x_ref: name: drop parent: universe -weight: 102 -related: - - /flux/v0.x/stdlib/universe/keep/ + identifier: universe/drop +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.7.0 --- -The `drop()` function removes specified columns from a table. + + +`drop()` removes specified columns from a table. + Columns are specified either through a list or a predicate function. -When a dropped column is part of the group key, it will be removed from the key. -If a specified column is not present in a table, it will return an error. +When a dropped column is part of the group key, it is removed from the key. +If a specified column is not present in a table, the function returns an error. + +##### Function type signature ```js -drop(columns: ["col1", "col2"]) - -// OR - -drop(fn: (column) => column =~ /usage*/) +(<-tables: stream[A], ?columns: [string], ?fn: (column: string) => bool) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -{{% note %}} -Make sure `fn` parameter names match each specified parameter. To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} +### columns + +List of columns to remove from input tables. Mutually exclusive with `fn`. + + + +### fn + +Predicate function with a `column` parameter that returns a boolean +value indicating whether or not the column should be removed from input tables. +Mutually exclusive with `columns`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -### columns {data-type="array of strings"} -Columns to removed from input tables. -_Mutually exclusive with `fn`._ -### fn {data-type="function"} -[Predicate function](/flux/v0.x/get-started/syntax-basics/#predicate-functions) -with a `column` parameter that returns a boolean value indicating whether or not -the column should be removed from input tables. -_Mutually exclusive with `columns`._ -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Drop a list of columns](#drop-a-list-of-columns) - [Drop columns matching a predicate](#drop-columns-matching-a-predicate) -#### Drop a list of columns +### Drop a list of columns ```js import "sampledata" sampledata.int() - |> drop(columns: ["_time", "tid"]) + |> drop(columns: ["_time", "tag"]) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _value | -| -----: | -| -2 | -| 10 | -| 7 | -| 17 | -| 15 | -| 4 | -| 19 | -| 4 | -| -3 | -| 19 | -| 13 | -| 1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _value | +| ------- | +| -2 | +| 10 | +| 7 | +| 17 | +| 15 | +| 4 | +| 19 | +| 4 | +| -3 | +| 19 | +| 13 | +| 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Drop columns matching a predicate +### Drop columns matching a predicate ```js import "sampledata" @@ -106,32 +132,46 @@ sampledata.int() |> drop(fn: (column) => column =~ /^t/) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T00:00:00Z | -2 | -| 2021-01-01T00:00:10Z | 10 | -| 2021-01-01T00:00:20Z | 7 | -| 2021-01-01T00:00:30Z | 17 | -| 2021-01-01T00:00:40Z | 15 | -| 2021-01-01T00:00:50Z | 4 | -| 2021-01-01T00:00:00Z | 19 | -| 2021-01-01T00:00:10Z | 4 | -| 2021-01-01T00:00:20Z | -3 | -| 2021-01-01T00:00:30Z | 19 | -| 2021-01-01T00:00:40Z | 13 | -| 2021-01-01T00:00:50Z | 1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | -2 | +| 2021-01-01T00:00:10Z | 10 | +| 2021-01-01T00:00:20Z | 7 | +| 2021-01-01T00:00:30Z | 17 | +| 2021-01-01T00:00:40Z | 15 | +| 2021-01-01T00:00:50Z | 4 | +| 2021-01-01T00:00:00Z | 19 | +| 2021-01-01T00:00:10Z | 4 | +| 2021-01-01T00:00:20Z | -3 | +| 2021-01-01T00:00:30Z | 19 | +| 2021-01-01T00:00:40Z | 13 | +| 2021-01-01T00:00:50Z | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/duplicate.md b/content/flux/v0.x/stdlib/universe/duplicate.md index 98b80b0de..35e4edbc7 100644 --- a/content/flux/v0.x/stdlib/universe/duplicate.md +++ b/content/flux/v0.x/stdlib/universe/duplicate.md @@ -1,48 +1,70 @@ --- title: duplicate() function -description: The `duplicate()` function duplicates a specified column in a table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/duplicate - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/duplicate/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/duplicate/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/duplicate/ +description: > + `duplicate()` duplicates a specified column in a table. menu: flux_0_x_ref: name: duplicate parent: universe -weight: 102 + identifier: universe/duplicate +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.7.0 --- -The `duplicate()` function duplicates a specified column in a table. -If the specified column is part of the group key, it will be duplicated, but will -not be part of the output table's group key. + + +`duplicate()` duplicates a specified column in a table. + +If the specified column is part of the group key, it will be duplicated, but +the duplicate column will not be part of the output’s group key. + +##### Function type signature ```js -duplicate(column: "column-name", as: "duplicate-name") +(<-tables: stream[A], as: string, column: string) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} +### column ({{< req >}}) Column to duplicate. -### as {data-type="string"} + + +### as ({{< req >}}) -Name assigned to the duplicate column. +Name to assign to the duplicate column. + +If the `as` column already exists, it will be overwritten by the duplicated column. + +### tables + +Input data. Default is piped-forward data (`<-`). + -{{% note %}} -If the `as` column already exists, this function will overwrite the existing values. -{{% /note %}} -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Duplicate a column ```js import "sampledata" @@ -52,36 +74,48 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | tag_dup | -| :------------------- | :-- | -----: | :------ | -| 2021-01-01T00:00:00Z | t1 | -2 | t1 | -| 2021-01-01T00:00:10Z | t1 | 10 | t1 | -| 2021-01-01T00:00:20Z | t1 | 7 | t1 | -| 2021-01-01T00:00:30Z | t1 | 17 | t1 | -| 2021-01-01T00:00:40Z | t1 | 15 | t1 | -| 2021-01-01T00:00:50Z | t1 | 4 | t1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | tag_dup | -| :------------------- | :-- | -----: | :------ | -| 2021-01-01T00:00:00Z | t2 | 19 | t2 | -| 2021-01-01T00:00:10Z | t2 | 4 | t2 | -| 2021-01-01T00:00:20Z | t2 | -3 | t2 | -| 2021-01-01T00:00:30Z | t2 | 19 | t2 | -| 2021-01-01T00:00:40Z | t2 | 13 | t2 | -| 2021-01-01T00:00:50Z | t2 | 1 | t2 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | tag_dup | +| -------------------- | ------- | ---- | -------- | +| 2021-01-01T00:00:00Z | -2 | t1 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | t1 | + +| _time | _value | *tag | tag_dup | +| -------------------- | ------- | ---- | -------- | +| 2021-01-01T00:00:00Z | 19 | t2 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/duration.md b/content/flux/v0.x/stdlib/universe/duration.md index c5928753e..6adc2983e 100644 --- a/content/flux/v0.x/stdlib/universe/duration.md +++ b/content/flux/v0.x/stdlib/universe/duration.md @@ -1,107 +1,116 @@ --- title: duration() function -description: The `duration()` function converts a single value to a duration. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/duration/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/duration/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/duration/ +description: > + `duration()` converts a value to a duration type. menu: flux_0_x_ref: name: duration parent: universe -weight: 102 + identifier: universe/duration +weight: 101 flux/v0.x/tags: [type-conversions] -related: - - /flux/v0.x/data-types/basic/duration/ introduced: 0.7.0 --- -The `duration()` function converts a single value to a duration. + + +`duration()` converts a value to a duration type. + +`duration()` treats integers and unsigned integers as nanoseconds. +For a string to be converted to a duration type, the string must use +duration literal representation. + +##### Function type signature ```js -duration(v: "1m") +(v: A) => duration ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string, int, uint"} +### v ({{< req >}}) Value to convert. -{{% note %}} -`duration()` assumes **numeric** input values are **nanoseconds**. -**String** input values must use [duration literal representation](/flux/v0.x/spec/lexical-elements/#duration-literals). -{{% /note %}} + + ## Examples -- [Convert an integer to a duration](#convert-an-integer-to-a-duration) - [Convert a string to a duration](#convert-a-string-to-a-duration) +- [Convert numeric types to durations](#convert-numeric-types-to-durations) - [Convert values in a column to durations](#convert-values-in-a-column-to-durations) -#### Convert an integer to a duration +### Convert a string to a duration + ```js -duration(v: 120000000) -// Returns 120ms +duration(v: "1h20m")// Returns 1h20m + ``` -#### Convert a string to a duration + +### Convert numeric types to durations + ```js -duration(v: "12h30m") -// Returns 12h30m +duration(v: 4800000000000) + +// Returns 1h20m +duration(v: uint(v: 9600000000000))// Returns 2h40m + ``` -#### Convert values in a column to durations -The following example uses [`generate.from()`](/flux/v0.x/stdlib/generate/from/) -to generate sample data and show how to iterate over values in a stream of tables -and convert them to duration values. -{{% note %}} +### Convert values in a column to durations + Flux does not support duration column types. -This example converts an integer to a duration and stores the value as a string. -{{% /note %}} +To store durations in a column, convert duration types to strings. ```js -import "generate" - -data = generate.from( - count: 5, - fn: (n) => (n + 1) * 3600000000000, - start: 2021-01-01T00:00:00Z, - stop: 2021-01-01T05:00:00Z, -) - data - |> map(fn:(r) => ({ r with _value: string(v: duration(v: r._value)) })) + |> map(fn: (r) => ({r with _value: string(v: duration(v: r._value))})) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -| _time | _value | -| :------------------- | -------------: | -| 2021-01-01T00:00:00Z | 3600000000000 | -| 2021-01-01T01:00:00Z | 7200000000000 | -| 2021-01-01T02:00:00Z | 10800000000000 | -| 2021-01-01T03:00:00Z | 14400000000000 | -| 2021-01-01T04:00:00Z | 18000000000000 | +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | tag | _value | +| -------------------- | ---- | --------- | +| 2022-01-01T05:00:00Z | t1 | -27000000 | +| 2022-01-01T09:00:10Z | t1 | 12000000 | +| 2022-01-01T11:00:20Z | t1 | 78000000 | +| 2022-01-01T16:00:30Z | t1 | 17000000 | +| 2022-01-01T19:00:40Z | t1 | 15000000 | +| 2022-01-01T20:00:50Z | t1 | -42000000 | -##### Output data -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T00:00:00Z | 1h | -| 2021-01-01T01:00:00Z | 2h | -| 2021-01-01T02:00:00Z | 3h | -| 2021-01-01T03:00:00Z | 4h | -| 2021-01-01T04:00:00Z | 5h | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | tag | +| -------------------- | ------- | ---- | +| 2022-01-01T05:00:00Z | -27ms | t1 | +| 2022-01-01T09:00:10Z | 12ms | t1 | +| 2022-01-01T11:00:20Z | 78ms | t1 | +| 2022-01-01T16:00:30Z | 17ms | t1 | +| 2022-01-01T19:00:40Z | 15ms | t1 | +| 2022-01-01T20:00:50Z | -42ms | t1 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/elapsed.md b/content/flux/v0.x/stdlib/universe/elapsed.md index fbac65fca..64078507c 100644 --- a/content/flux/v0.x/stdlib/universe/elapsed.md +++ b/content/flux/v0.x/stdlib/universe/elapsed.md @@ -1,57 +1,78 @@ --- title: elapsed() function -description: The `elapsed()` function returns the time between subsequent records. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/elapsed/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/elapsed/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/elapsed/ +description: > + `elapsed()` returns the time between subsequent records. menu: flux_0_x_ref: name: elapsed parent: universe -weight: 102 + identifier: universe/elapsed +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/contrib/tomhollingworth/events/duration/ introduced: 0.36.0 --- -The `elapsed()` function returns the time between subsequent records. -Given an input table, `elapsed()` returns the same table without the first record -(as elapsed time is not defined) and an additional column containing the elapsed time. + + +`elapsed()` returns the time between subsequent records. + +For each input table, `elapsed()` returns the same table without the first row +(because there is no previous time to derive the elapsed time from) and an +additional column containing the elapsed time. + +##### Function type signature ```js -elapsed( - unit: 1s, - timeColumn: "_time", - columnName: "elapsed", -) +(<-tables: stream[A], ?columnName: string, ?timeColumn: string, ?unit: duration) => stream[B] where A: Record, B: Record ``` -_`elapsed()` returns an errors if the `timeColumn` is not present in the input table._ +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### unit {data-type="duration"} -The unit time to returned. -_Default is `1s`._ +### unit + +Unit of time used in the calculation. Default is `1s`. + + + +### timeColumn + +Column to use to compute the elapsed time. Default is `_time`. + + + +### columnName + +Column to store elapsed times in. Default is `elapsed`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -### timeColumn {data-type="string"} -The column to use to compute the elapsed time. -_Default is `"_time"`._ -### columnName {data-type="string"} -The column to store elapsed times. -_Default is `"elapsed"`._ -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} -#### Calculate the time between points in seconds +### Calculate the time between points in seconds + ```js import "sampledata" @@ -59,32 +80,47 @@ sampledata.int() |> elapsed(unit: 1s) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -{{% flux/sample "int" %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -{{% /flex-content %}} -{{% flex-content %}} +#### Input data -##### Output data -| _time | tag | _value | elapsed | -| :------------------- | :-- | -----: | ------: | -| 2021-01-01T00:00:10Z | t1 | 10 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | 10 | -| 2021-01-01T00:00:30Z | t1 | 17 | 10 | -| 2021-01-01T00:00:40Z | t1 | 15 | 10 | -| 2021-01-01T00:00:50Z | t1 | 4 | 10 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -| _time | tag | _value | elapsed | -| :------------------- | :-- | -----: | ------: | -| 2021-01-01T00:00:10Z | t2 | 4 | 10 | -| 2021-01-01T00:00:20Z | t2 | -3 | 10 | -| 2021-01-01T00:00:30Z | t2 | 19 | 10 | -| 2021-01-01T00:00:40Z | t2 | 13 | 10 | -| 2021-01-01T00:00:50Z | t2 | 1 | 10 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | elapsed | +| -------------------- | ------- | ---- | -------- | +| 2021-01-01T00:00:10Z | 10 | t1 | 10 | +| 2021-01-01T00:00:20Z | 7 | t1 | 10 | +| 2021-01-01T00:00:30Z | 17 | t1 | 10 | +| 2021-01-01T00:00:40Z | 15 | t1 | 10 | +| 2021-01-01T00:00:50Z | 4 | t1 | 10 | + +| _time | _value | *tag | elapsed | +| -------------------- | ------- | ---- | -------- | +| 2021-01-01T00:00:10Z | 4 | t2 | 10 | +| 2021-01-01T00:00:20Z | -3 | t2 | 10 | +| 2021-01-01T00:00:30Z | 19 | t2 | 10 | +| 2021-01-01T00:00:40Z | 13 | t2 | 10 | +| 2021-01-01T00:00:50Z | 1 | t2 | 10 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/exponentialmovingaverage.md b/content/flux/v0.x/stdlib/universe/exponentialmovingaverage.md index 9a0bd8403..56ba1658a 100644 --- a/content/flux/v0.x/stdlib/universe/exponentialmovingaverage.md +++ b/content/flux/v0.x/stdlib/universe/exponentialmovingaverage.md @@ -1,38 +1,40 @@ --- title: exponentialMovingAverage() function description: > - The `exponentialMovingAverage()` function calculates the exponential moving average of values - in the `_value` column grouped into `n` number of points, giving more weight to recent data. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/ + `exponentialMovingAverage()` calculates the exponential moving average of `n` + number of values in the `_value` column giving more weight to more recent data. menu: flux_0_x_ref: name: exponentialMovingAverage parent: universe -weight: 102 + identifier: universe/exponentialMovingAverage +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/movingaverage/ - - /flux/v0.x/stdlib/universe/timedmovingaverage/ - - /flux/v0.x/stdlib/universe/doubleema/ - - /flux/v0.x/stdlib/universe/tripleema/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#exponential-moving-average, InfluxQL EXPONENTIAL_MOVING_AVERAGE() introduced: 0.37.0 --- -The `exponentialMovingAverage()` function calculates the exponential moving average of values -in the `_value` column grouped into `n` number of points, giving more weight to recent data. + + +`exponentialMovingAverage()` calculates the exponential moving average of `n` +number of values in the `_value` column giving more weight to more recent data. + +### Exponential moving average rules + +- The first value of an exponential moving average over `n` values is the algebraic mean of `n` values. - Subsequent values are calculated as `y(t) = x(t) * k + y(t-1) * (1 - k)`, where: - `y(t)` is the exponential moving average at time `t`. - `x(t)` is the value at time `t`. @@ -40,22 +42,36 @@ exponentialMovingAverage(n: 5) - The average over a period populated by only `null` values is `null`. - Exponential moving averages skip `null` values. +##### Function type signature + +```js +(<-tables: stream[{A with _value: B}], n: int) => stream[{A with _value: B}] where B: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### n {data-type="int"} -The number of points to average. +### n +({{< req >}}) +Number of values to average. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Calculate a three point exponential moving average](#calculate-a-three-point-exponential-moving-average) - [Calculate a three point exponential moving average with null values](#calculate-a-three-point-exponential-moving-average-with-null-values) -#### Calculate a three point exponential moving average +### Calculate a three point exponential moving average + ```js import "sampledata" @@ -64,37 +80,49 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t1 | 5 | -| 2021-01-01T00:00:30Z | t1 | 11 | -| 2021-01-01T00:00:40Z | t1 | 13 | -| 2021-01-01T00:00:50Z | t1 | 8.5 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:20Z | t2 | 6.666666666666667 | -| 2021-01-01T00:00:30Z | t2 | 12.833333333333334 | -| 2021-01-01T00:00:40Z | t2 | 12.916666666666668 | -| 2021-01-01T00:00:50Z | t2 | 6.958333333333334 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 5 | t1 | +| 2021-01-01T00:00:30Z | 11 | t1 | +| 2021-01-01T00:00:40Z | 13 | t1 | +| 2021-01-01T00:00:50Z | 8.5 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:20Z | 6.666666666666667 | t2 | +| 2021-01-01T00:00:30Z | 12.833333333333334 | t2 | +| 2021-01-01T00:00:40Z | 12.916666666666668 | t2 | +| 2021-01-01T00:00:50Z | 6.958333333333334 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Calculate a three point exponential moving average with null values +### Calculate a three point exponential moving average with null values ```js import "sampledata" @@ -103,31 +131,45 @@ sampledata.int(includeNull: true) |> exponentialMovingAverage(n: 3) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" true %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t1 | 2021-01-01T00:00:20Z | 2.5 | -| t1 | 2021-01-01T00:00:30Z | 2.5 | -| t1 | 2021-01-01T00:00:40Z | 2.5 | -| t1 | 2021-01-01T00:00:50Z | 3.25 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t2 | 2021-01-01T00:00:20Z | 0.5 | -| t2 | 2021-01-01T00:00:30Z | 9.75 | -| t2 | 2021-01-01T00:00:40Z | 9.75 | -| t2 | 2021-01-01T00:00:50Z | 5.375 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 2.5 | t1 | +| 2021-01-01T00:00:30Z | 2.5 | t1 | +| 2021-01-01T00:00:40Z | 2.5 | t1 | +| 2021-01-01T00:00:50Z | 3.25 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 0.5 | t2 | +| 2021-01-01T00:00:30Z | 9.75 | t2 | +| 2021-01-01T00:00:40Z | 9.75 | t2 | +| 2021-01-01T00:00:50Z | 5.375 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/fill.md b/content/flux/v0.x/stdlib/universe/fill.md index ae3a2374e..425f7edc0 100644 --- a/content/flux/v0.x/stdlib/universe/fill.md +++ b/content/flux/v0.x/stdlib/universe/fill.md @@ -1,140 +1,187 @@ --- title: fill() function -description: The `fill()` function replaces all null values in an input stream and replace them with a non-null value. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/fill - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/fill/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/fill/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/fill/ +description: > + `fill()` replaces all null values in input tables with a non-null value. menu: flux_0_x_ref: name: fill parent: universe -weight: 102 + identifier: universe/fill +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/fill/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#group-by-time-intervals-and-fill, InfluxQL – FILL introduced: 0.14.0 --- -The `fill()` function replaces all null values in an input stream with a non-null value. -The output stream is the same as the input stream with all null values replaced in the specified column. + + +`fill()` replaces all null values in input tables with a non-null value. + +Output tables are the same as the input tables with all null values replaced +in the specified column. + +##### Function type signature ```js -fill(column: "_value", value: 0.0) - -// OR - -fill(column: "_value", usePrevious: true) +(<-tables: stream[B], ?column: string, ?usePrevious: bool, ?value: A) => stream[C] where B: Record, C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -The column in which to replace null values. Defaults to `"_value"`. +### column -### value {data-type="string, bool, int, uint, float, duration, time"} -The constant value to use in place of nulls. -The value type must match the value type of the `column`. +Column to replace null values in. Default is `_value`. + + + +### value + +Constant value to replace null values with. + +Value type must match the type of the specified column. + +### usePrevious + +Replace null values with the previous non-null value. +Default is `false`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -### usePrevious {data-type="bool"} -When `true`, assigns the value set in the previous non-null row. -{{% note %}} -Cannot be used with `value`. -{{% /note %}} -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Fill null values with a specified non-null value](#fill-null-values-with-a-specified-non-null-value) - [Fill null values with the previous non-null value](#fill-null-values-with-the-previous-non-null-value) -#### Fill null values with a specified non-null value +### Fill null values with a specified non-null value + ```js import "sampledata" -sampledata.float(includeNull: true) - |> fill(value: 0.0) +sampledata.int(includeNull: true) + |> fill(value: 0) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "float" true %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2.18 | -| 2021-01-01T00:00:10Z | t1 | 0.0 | -| 2021-01-01T00:00:20Z | t1 | 7.35 | -| 2021-01-01T00:00:30Z | t1 | 0.0 | -| 2021-01-01T00:00:40Z | t1 | 0.0 | -| 2021-01-01T00:00:50Z | t1 | 4.43 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 0.0 | -| 2021-01-01T00:00:10Z | t2 | 4.97 | -| 2021-01-01T00:00:20Z | t2 | -3.75 | -| 2021-01-01T00:00:30Z | t2 | 19.77 | -| 2021-01-01T00:00:40Z | t2 | 0.0 | -| 2021-01-01T00:00:50Z | t2 | 1.86 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 0 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 0 | t1 | +| 2021-01-01T00:00:40Z | 0 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 0 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Fill null values with the previous non-null value +### Fill null values with the previous non-null value + ```js import "sampledata" -sampledata.float(includeNull: true) +sampledata.int(includeNull: true) |> fill(usePrevious: true) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "float" true %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2.18 | -| 2021-01-01T00:00:10Z | t1 | -2.18 | -| 2021-01-01T00:00:20Z | t1 | 7.35 | -| 2021-01-01T00:00:30Z | t1 | 7.35 | -| 2021-01-01T00:00:40Z | t1 | 7.35 | -| 2021-01-01T00:00:50Z | t1 | 4.43 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | | -| 2021-01-01T00:00:10Z | t2 | 4.97 | -| 2021-01-01T00:00:20Z | t2 | -3.75 | -| 2021-01-01T00:00:30Z | t2 | 19.77 | -| 2021-01-01T00:00:40Z | t2 | 19.77 | -| 2021-01-01T00:00:50Z | t2 | 1.86 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | -2 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 7 | t1 | +| 2021-01-01T00:00:40Z | 7 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 19 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/filter.md b/content/flux/v0.x/stdlib/universe/filter.md index 634d97670..07e9ef5a0 100644 --- a/content/flux/v0.x/stdlib/universe/filter.md +++ b/content/flux/v0.x/stdlib/universe/filter.md @@ -1,91 +1,86 @@ --- title: filter() function -description: The `filter()` function filters data based on conditions defined in a predicate function (fn). -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/filter - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/filter/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/filter/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/filter/ +description: > + `filter()` filters data based on conditions defined in a predicate function (`fn`). menu: flux_0_x_ref: name: filter parent: universe -weight: 102 + identifier: universe/filter +weight: 101 flux/v0.x/tags: [transformations, filters] -related: - - /{{< latest "influxdb" >}}/query-data/flux/query-fields/ - - /{{< latest "influxdb" >}}/query-data/flux/conditional-logic/ - - /{{< latest "influxdb" >}}/query-data/flux/exists/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-basic-select-statement, InfluxQL – SELECT introduced: 0.7.0 --- -The `filter()` function filters data based on conditions defined in a predicate function ([`fn`](#fn)). -The output tables have the same schema as the corresponding input tables. + + +`filter()` filters data based on conditions defined in a predicate function (`fn`). + +Output tables have the same schema as the corresponding input tables. + +##### Function type signature ```js -filter( - fn: (r) => r._measurement == "cpu", - onEmpty: "drop", -) +(<-tables: stream[A], fn: (r: A) => bool, ?onEmpty: string) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -{{% note %}} -Make sure `fn` parameter names match each specified parameter. To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} +### fn +({{< req >}}) +Single argument predicate function that evaluates `true` or `false`. -### fn {data-type="function"} +Records representing each row are passed to the function as `r`. +Records that evaluate to `true` are included in output tables. +Records that evaluate to _null_ or `false` are excluded from output tables. -A single argument predicate function that evaluates true or false. -Records are passed to the function. -Those that evaluate to true are included in the output tables. -Records that evaluate to _null_ or false are not included in the output tables. +### onEmpty -{{% note %}} -Records evaluated in `fn` functions are represented by `r`, short for "record" or "row". -{{% /note %}} +Action to take with empty tables. Default is `drop`. -### onEmpty {data-type="string"} -Defines the behavior for empty tables. -Potential values are `keep` and `drop`. -Defaults to `drop`. +**Supported values**: +- **keep**: Keep empty tables. +- **drop**: Drop empty tables. -##### drop -Tables without rows are dropped. +### tables + +Input data. Default is piped-forward data (`<-`). -##### keep -Tables without rows are output to the next transformation. -{{% warn %}} -Keeping empty tables with your first `filter()` function can have severe performance -costs since it retains empty tables from your entire data set. -For higher performance, use your first `filter()` function to do basic filtering, -then keep empty tables on subsequent `filter()` calls with smaller data sets. -_[See the example below](#keep-empty-tables-when-filtering)._ -{{% /warn %}} -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples - [Filter based on InfluxDB measurement, field, and tag](#filter-based-on-influxdb-measurement-field-and-tag) - [Keep empty tables when filtering](#keep-empty-tables-when-filtering) -- [Filter out null values](#filter-out-null-values) - [Filter values based on thresholds](#filter-values-based-on-thresholds) -#### Filter based on InfluxDB measurement, field, and tag +### Filter based on InfluxDB measurement, field, and tag + ```js from(bucket: "example-bucket") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_system" and r.cpu == "cpu-total") ``` -#### Keep empty tables when filtering -The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/). + +### Keep empty tables when filtering ```js import "sampledata" @@ -95,106 +90,87 @@ sampledata.int() |> filter(fn: (r) => r._value > 18, onEmpty: "keep") ``` -{{% note %}} -Use [`table.fill()`](/flux/v0.x/stdlib/experimental/table/fill/) to fill empty tables. -{{% /note %}} - {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:30Z | t2 | 19 | +| _time | _value | *tag | +| ------ | ------- | ---- | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Filter out null values -The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/). - -```js -import "sampledata" - -sampledata.int(includeNull: true) - |> filter(fn: (r) => exists r._value ) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "int" true %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:50Z | t1 | 4 | - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:50Z | t2 | 1 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} - -#### Filter values based on thresholds -The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/). +### Filter values based on thresholds ```js import "sampledata" sampledata.int() - |> filter(fn: (r) => r._value > 0 and r._value < 10 ) + |> filter(fn: (r) => r._value > 0 and r._value < 10) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/findcolumn.md b/content/flux/v0.x/stdlib/universe/findcolumn.md index a47bd6fbf..6176fd79c 100644 --- a/content/flux/v0.x/stdlib/universe/findcolumn.md +++ b/content/flux/v0.x/stdlib/universe/findcolumn.md @@ -1,55 +1,80 @@ --- title: findColumn() function description: > - The `findColumn()` function returns an array of values in a specified column from the - first table in a stream of tables where group key values match the specified predicate. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/ + `findColumn()` returns an array of values in a specified column from the first + table in a stream of tables that matches the specified predicate function. menu: flux_0_x_ref: name: findColumn parent: universe -weight: 102 + identifier: universe/findColumn +weight: 101 flux/v0.x/tags: [dynamic queries] -related: - - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ introduced: 0.68.0 --- -The `findColumn()` function returns an array of values in a specified column from the -first table in a stream of tables where the group key values match the specified predicate. -The function returns an empty array if no table is found or if the column label -is not present in the set of columns. + + +`findColumn()` returns an array of values in a specified column from the first +table in a stream of tables that matches the specified predicate function. + +The function returns an empty array if no table is found or if the column +label is not present in the set of columns. + +##### Function type signature ```js -findColumn( - fn: (key) => key._field == "fieldName", - column: "_value", -) +(<-tables: stream[B], column: string, fn: (key: A) => bool) => [C] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### fn {data-type="function"} -A predicate function for matching keys in a table's group key. -Expects a `key` argument that represents a group key in the input stream. +### column +({{< req >}}) +Column to extract. -### column {data-type="string"} -Name of the column to extract. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Example -{{% flux/sample-example-intro %}} +### fn +({{< req >}}) +Predicate function to evaluate input table group keys. + +`findColumn()` uses the first table that resolves as `true`. +The predicate function requires a `key` argument that represents each input +table's group key as a record. + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +### Extract a column as an array ```js import "sampledata" sampledata.int() - |> findColumn(fn: (key) => key.tag == "t1", column: "_value") - -// Returns [-2, 10, 7, 17, 15, 4] + |> findColumn(fn: (key) => key.tag == "t1", column: "_value")// Returns [-2, 10, 7, 17, 15, 4] + ``` + diff --git a/content/flux/v0.x/stdlib/universe/findrecord.md b/content/flux/v0.x/stdlib/universe/findrecord.md index a4b17dc0c..7ec443cdf 100644 --- a/content/flux/v0.x/stdlib/universe/findrecord.md +++ b/content/flux/v0.x/stdlib/universe/findrecord.md @@ -1,54 +1,83 @@ --- title: findRecord() function description: > - The `findRecord()` function returns a record at a specified index from the first - table in a stream of tables where the group key values match the specified predicate. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/ + `findRecord()` returns a row at a specified index as a record from the first + table in a stream of tables that matches the specified predicate function. menu: flux_0_x_ref: name: findRecord parent: universe -weight: 102 + identifier: universe/findRecord +weight: 101 flux/v0.x/tags: [dynamic queries] -related: - - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ introduced: 0.68.0 --- -The `findRecord()` function returns a record at a specified index from the first -table in a stream of tables where the group key values match the specified predicate. -The function returns an empty record if no table is found or if the index is out of bounds. + + +`findRecord()` returns a row at a specified index as a record from the first +table in a stream of tables that matches the specified predicate function. + +The function returns an empty record if no table is found or if the index is +out of bounds. + +##### Function type signature ```js -findRecord( - fn: (key) => key._field == "fieldName", - idx: 0, -) +(<-tables: stream[B], fn: (key: A) => bool, idx: int) => B where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### fn {data-type="function"} -A predicate function for matching keys in a table's group key. -Expects a `key` argument that represents a group key in the input stream. - -### idx {data-type="int"} +### idx +({{< req >}}) Index of the record to extract. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Example -{{% flux/sample-example-intro %}} + +### fn +({{< req >}}) +Predicate function to evaluate input table group keys. + +`findColumn()` uses the first table that resolves as `true`. +The predicate function requires a `key` argument that represents each input +table's group key as a record. + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +### Extract a row as a record ```js import "sampledata" sampledata.int() - |> findRecord(fn: (key) => key.tag == "t1", idx: 0) - -// Returns {_time: 2021-01-01T00:00:00.000000000Z, _value: -2, tag: t1} + |> findRecord( + fn: (key) => key.tag == "t1", + idx: 0, + )// Returns {_time: 2021-01-01T00:00:00.000000000Z, _value: -2, tag: t1} + ``` + diff --git a/content/flux/v0.x/stdlib/universe/first.md b/content/flux/v0.x/stdlib/universe/first.md index 470aae521..761887ff4 100644 --- a/content/flux/v0.x/stdlib/universe/first.md +++ b/content/flux/v0.x/stdlib/universe/first.md @@ -1,43 +1,63 @@ --- title: first() function -description: The `first()` function selects the first non-null record from an input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/first - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/first/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/first/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/first/ +description: > + `first()` returns the first non-null record from each input table. menu: flux_0_x_ref: name: first parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/first-last/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#first, InfluxQL – FIRST() + identifier: universe/first +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `first()` function selects the first non-null record from an input table. -_`first()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`first()` returns the first non-null record from each input table. + +**Note**: `first()` drops empty tables. + +##### Function type signature ```js -first() +(<-tables: stream[A], ?column: string) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`first()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### column + +Column to operate on. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} + +### Return the first row in each input table ```js import "sampledata" @@ -46,25 +66,39 @@ sampledata.int() |> first() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/float.md b/content/flux/v0.x/stdlib/universe/float.md index 413035dee..ed9a05c5f 100644 --- a/content/flux/v0.x/stdlib/universe/float.md +++ b/content/flux/v0.x/stdlib/universe/float.md @@ -1,123 +1,139 @@ --- title: float() function -description: The `float()` function converts a single value to a float. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/float/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/float/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/float/ +description: > + `float()` converts a value to a float type. menu: flux_0_x_ref: name: float parent: universe -weight: 102 + identifier: universe/float +weight: 101 flux/v0.x/tags: [type-conversions] -related: - - /flux/v0.x/data-types/basic/float/ - - /flux/v0.x/stdlib/universe/tofloat/ introduced: 0.7.0 --- -The `float()` function converts a single value to a float. + + +`float()` converts a value to a float type. + + + +##### Function type signature ```js -float(v: "3.14") +(v: A) => float ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string, bool, int, uint"} -The value to convert. +### v +({{< req >}}) +Value to convert. + + + ## Examples -- [Convert a string to a float value](#convert-a-string-to-a-float-value) -- [Convert a scientific notation string to a float value](#convert-a-scientific-notation-string-to-a-float-value) -- [Convert an integer to a float value](#convert-an-integer-to-a-float-value) -- [Convert all values in a column to float values](#convert-all-values-in-a-column-to-float-values) +- [Convert a string to a float](#convert-a-string-to-a-float) +- [Convert a scientific notation string to a float](#convert-a-scientific-notation-string-to-a-float) +- [Convert an integer to a float](#convert-an-integer-to-a-float) +- [Convert all values in a column to floats](#convert-all-values-in-a-column-to-floats) + +### Convert a string to a float -#### Convert a string to a float value ```js -float(v: "3.14") +float(v: "3.14")// Returns 3.14 -// Returns 3.14 (float) ``` -#### Convert a scientific notation string to a float value -```js -float(v: "1.23e+20") -// Returns 1.23e+20 (float) +### Convert a scientific notation string to a float + +```js +float(v: "1.23e+20")// Returns 1.23e+20 (float) + ``` -#### Convert an integer to a float value -```js -float(v: "10") -// Returns 10.0 +### Convert an integer to a float + +```js +float(v: "10")// Returns 10.0 + ``` -#### Convert all values in a column to float values -If updating values in the `_value` column, use [`toFloat()`](/flux/v0.x/stdlib/universe/tofloat/). -To update values in columns other than `_value`: -1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows. -2. Use `float()` to update the value of a column. +### Convert all values in a column to floats -_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._ +If converting the `_value` column to float types, use `toFloat()`. +If converting columns other than `_value`, use `map()` to iterate over each +row and `float()` to covert a column value to a float type. ```js -import "sampledata" - -data = sampledata.int() - |> rename(columns: {_value: "foo"}) - data - |> map(fn: (r) => ({r with foo: float(v: r.foo)})) + |> map(fn: (r) => ({r with exampleCol: float(v: r.exampleCol)})) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | tag | foo | -| :------------------- | :-- | --: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| _time | tag | foo | -| :------------------- | :-- | --: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | tag | foo | -| :------------------- | :-- | ---: | -| 2021-01-01T00:00:00Z | t1 | -2.0 | -| 2021-01-01T00:00:10Z | t1 | 10.0 | -| 2021-01-01T00:00:20Z | t1 | 7.0 | -| 2021-01-01T00:00:30Z | t1 | 17.0 | -| 2021-01-01T00:00:40Z | t1 | 15.0 | -| 2021-01-01T00:00:50Z | t1 | 4.0 | +#### Input data -| _time | tag | foo | -| :------------------- | :-- | ---: | -| 2021-01-01T00:00:00Z | t2 | 19.0 | -| 2021-01-01T00:00:10Z | t2 | 4.0 | -| 2021-01-01T00:00:20Z | t2 | -3.0 | -| 2021-01-01T00:00:30Z | t2 | 19.0 | -| 2021-01-01T00:00:40Z | t2 | 13.0 | -| 2021-01-01T00:00:50Z | t2 | 1.0 | -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} \ No newline at end of file +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/getcolumn.md b/content/flux/v0.x/stdlib/universe/getcolumn.md index d6effcb30..2623a81d0 100644 --- a/content/flux/v0.x/stdlib/universe/getcolumn.md +++ b/content/flux/v0.x/stdlib/universe/getcolumn.md @@ -1,55 +1,70 @@ --- title: getColumn() function description: > - The `getColumn()` function extracts a column from a table given its label. - If the label is not present in the set of columns, the function errors. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/stream-table/getcolumn/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn/ + `getColumn()` extracts a specified column from a table as an array. menu: flux_0_x_ref: name: getColumn parent: universe -weight: 102 + identifier: universe/getColumn +weight: 101 flux/v0.x/tags: [dynamic queries] -related: - - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ introduced: 0.29.0 --- -The `getColumn()` function extracts a column from a table given its label. -If the label is not present in the set of columns, the function errors. + + +`getColumn()` extracts a specified column from a table as an array. + +If the specified column is not present in the table, the function returns an error. + +##### Function type signature ```js -getColumn(column: "_value") +(<-table: stream[A], column: string) => [B] where A: Record ``` -{{% note %}} -#### Use tableFind() to extract a single table -`getColumn()` requires a single table as input. -Use [`tableFind()`](/flux/v0.x/stdlib/universe/tablefind/) -to extract a single table from a stream of tables. -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -Name of the column to extract. +### column +({{< req >}}) +Column to extract -### table {data-type="table"} -Input table. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Example -{{% flux/sample-example-intro %}} + +### table + +Input table. Default is piped-forward data (`<-`). + + + + +## Examples + +### Extract a column from a table ```js import "sampledata" sampledata.int() |> tableFind(fn: (key) => key.tag == "t1") - |> getColumn(column: "_value") - -// Returns [-2, 10, 7, 17, 15, 4] + |> getColumn(column: "_value")// Returns [-2, 10, 7, 17, 15, 4] + ``` + diff --git a/content/flux/v0.x/stdlib/universe/getrecord.md b/content/flux/v0.x/stdlib/universe/getrecord.md index e4d212c29..01e9a3499 100644 --- a/content/flux/v0.x/stdlib/universe/getrecord.md +++ b/content/flux/v0.x/stdlib/universe/getrecord.md @@ -1,55 +1,70 @@ --- title: getRecord() function description: > - The `getRecord()` function extracts a record from a table given its index. - If the index is out of bounds, the function errors. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/stream-table/getrecord/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/ + `getRecord()` extracts a row at a specified index from a table as a record. menu: flux_0_x_ref: name: getRecord parent: universe -weight: 102 + identifier: universe/getRecord +weight: 101 flux/v0.x/tags: [dynamic queries] -related: - - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ introduced: 0.29.0 --- -The `getRecord()` function extracts a record from a table given the record's index. -If the index is out of bounds, the function errors. + + +`getRecord()` extracts a row at a specified index from a table as a record. + +If the specified index is out of bounds, the function returns an error. + +##### Function type signature ```js -getRecord(idx: 0) +(<-table: stream[A], idx: int) => A where A: Record ``` -{{% note %}} -#### Use tableFind() to extract a single table -`getRecord()` requires a single table as input. -Use [`tableFind()`](/flux/v0.x/stdlib/universe/tablefind/) -to extract a single table from a stream of tables. -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### idx {data-type="int"} +### idx +({{< req >}}) Index of the record to extract. -### table {data-type="table"} -Input table. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Example -{{% flux/sample-example-intro %}} + +### table + +Input table. Default is piped-forward data (`<-`). + + + + +## Examples + +### Extract the first row from a table as a record ```js import "sampledata" sampledata.int() |> tableFind(fn: (key) => key.tag == "t1") - |> getRecord(idx: 0) - -// Returns {_time: 2021-01-01T00:00:00.000000000Z, _value: -2, tag: t1} + |> getRecord(idx: 0)// Returns {_time: 2021-01-01T00:00:00.000000000Z, _value: -2, tag: t1} + ``` + diff --git a/content/flux/v0.x/stdlib/universe/group.md b/content/flux/v0.x/stdlib/universe/group.md index ed97ccd94..4e3005ddc 100644 --- a/content/flux/v0.x/stdlib/universe/group.md +++ b/content/flux/v0.x/stdlib/universe/group.md @@ -1,81 +1,79 @@ --- title: group() function -description: The `group()` function groups records based on their values for specific columns. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/group - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/group/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/group/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/group/ +description: > + `group()` regroups input data by modifying group key of input tables. menu: flux_0_x_ref: name: group parent: universe -weight: 102 + identifier: universe/group +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/get-started/data-model/#restructure-tables, Data model - Restructure tables - - /{{< latest "influxdb" >}}/query-data/flux/group-data/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-group-by-clause, InfluxQL – GROUP BY introduced: 0.7.0 --- -The `group()` function groups records based on their values for specific columns. -It produces tables with new group keys based on provided properties. -Specify an empty array of columns to ungroup data or merge all input tables into a single output table. + + +`group()` regroups input data by modifying group key of input tables. + +**Note**: Group does not gaurantee sort order. +To ensure data is sorted correctly, use `sort()` after `group()`. + +##### Function type signature ```js -group(columns: ["host", "_measurement"], mode:"by") - -// OR - -group(columns: ["_time"], mode:"except") - -// OR - -group() +(<-tables: stream[A], ?columns: [string], ?mode: string) => stream[A] where A: Record ``` -_For more information about Flux table grouping, see -[Data model - Restructure tables](/flux/v0.x/get-started/data-model/#restructure-tables)_. - -{{% warn %}} -#### Group does not guarantee sort order -`group()` does not guarantee the sort order of output records. -To ensure data is sorted correctly, use [`sort()`](/flux/v0.x/stdlib/universe/sort/) -after `group()`. - -```js -data - |> group() - |> sort(columns: ["_time"]) -``` -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### columns {data-type="array of strings"} -List of columns to use in the grouping operation. -Defaults to `[]`. +### columns + +List of columns to use in the grouping operation. Default is `[]`. + +**Note**: When `columns` is set to an empty array, `group()` ungroups +all data merges it into a single output table. + +### mode + +Grouping mode. Default is `by`. + +**Avaliable modes**: +- **by**: Group by columns defined in the `columns` parameter. +- **except**: Group by all columns _except_ those in defined in the +`columns` parameter. + +### tables + +Input data. Default is piped-forward data (`<-`). -### mode {data-type="string"} -The mode used to group columns. Default is `"by"`. -The following modes are available: -- `by`: Groups records by columns defined in the [`columns`](#columns) parameter. -- `except`: Groups records by all columns **except** those defined in the [`columns`](#columns) parameter. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Group by specific columns](#group-by-specific-columns) - [Group by everything except time](#group-by-everything-except-time) - [Ungroup data](#ungroup-data) -#### Group by specific columns +### Group by specific columns + ```js import "sampledata" @@ -84,74 +82,84 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{< flux/group-key "[tag]" >}} +#### Input data -{{% flux/sample "int" %}} -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -{{< flux/group-key "[_time, tag]" >}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | +#### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t1 | 10 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | 4 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t1 | 7 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 10 | t1 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t2 | -3 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 4 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:30Z | t1 | 17 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 7 | t1 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:30Z | t2 | 19 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | -3 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:40Z | t1 | 15 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 17 | t1 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:40Z | t2 | 13 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 19 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:50Z | t1 | 4 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:40Z | 15 | t1 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:50Z | t2 | 1 | +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:40Z | 13 | t2 | + +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| *_time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 1 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Group by everything except time +### Group by everything except time + ```js import "sampledata" @@ -160,71 +168,80 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{< flux/group-key "[tag]" >}} +#### Input data -{{% flux/sample "int" %}} -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -{{< flux/group-key "[_value, tag]" >}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| -3 | t2 | 2021-01-01T00:00:20Z | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| -2 | t1 | 2021-01-01T00:00:00Z | +#### Output data -| _value | tag | _time | -| -----: | :-- | :------------------- | -| 1 | t2 | 2021-01-01T00:00:50Z | +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | -3 | t2 | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| 4 | t1 | 2021-01-01T00:00:50Z | +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| 4 | t2 | 2021-01-01T00:00:10Z | +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| 7 | t1 | 2021-01-01T00:00:20Z | +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 4 | t1 | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| 10 | t1 | 2021-01-01T00:00:10Z | +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 4 | t2 | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| 13 | t2 | 2021-01-01T00:00:40Z | +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 7 | t1 | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| 15 | t1 | 2021-01-01T00:00:40Z | +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 10 | t1 | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| 17 | t1 | 2021-01-01T00:00:30Z | +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:40Z | 13 | t2 | -| _value | tag | _time | -| -----: | :-- | :------------------- | -| 19 | t2 | 2021-01-01T00:00:00Z | -| 19 | t2 | 2021-01-01T00:00:30Z | +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:40Z | 15 | t1 | + +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 17 | t1 | + +| _time | *_value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Ungroup data +### Ungroup data ```js import "sampledata" @@ -234,35 +251,46 @@ sampledata.int() |> group() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{< flux/group-key "[tag]" >}} +#### Input data -{{% flux/sample "int" %}} -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -{{< flux/group-key "[]" >}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/highestaverage.md b/content/flux/v0.x/stdlib/universe/highestaverage.md index 7f82b7047..8e4c08dca 100644 --- a/content/flux/v0.x/stdlib/universe/highestaverage.md +++ b/content/flux/v0.x/stdlib/universe/highestaverage.md @@ -1,82 +1,114 @@ --- title: highestAverage() function -description: The `highestAverage()` function calculates the average of each table in the input stream returns the top `n` records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/highestaverage - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/highestaverage/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestaverage/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/highestaverage/ +description: > + `highestAverage()` calculates the average of each input table and returns the + highest `n` averages. menu: flux_0_x_ref: name: highestAverage parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] + identifier: universe/highestAverage +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `highestAverage()` function calculates the average of each table in the input stream returns the top `n` records. -The function outputs a single aggregated table containing `n` records. -_`highestAverage()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`highestAverage()` calculates the average of each input table and returns the +highest `n` averages. + +**Note:** `highestAverage()` drops empty tables. + +##### Function type signature ```js -highestAverage( - n:10, - column: "_value", - groupColumns: [], -) +(<-tables: stream[A], n: int, ?column: string, ?groupColumns: [string]) => stream[B] where A: Record, B: Record ``` -{{% warn %}} -#### Empty tables -`highestAverage()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n +({{< req >}}) Number of records to return. -### column {data-type="string"} -Column by which to sort. -Default is `"_value"`. -### groupColumns {data-type="array of strings"} -The columns on which to group before performing the aggregation. -Default is `[]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### column + +Column to evaluate. Default is `_value`. + + + +### groupColumns + +List of columns to group by. Default is `[]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} + +### Return the highest table average from a stream of tables ```js import "sampledata" sampledata.int() - |> highestAverage(n: 2, groupColumns: ["tag"]) + |> highestAverage(n: 1, groupColumns: ["tag"]) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | ----------------: | -| t2 | 8.833333333333334 | -| t1 | 8.5 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| tag | _value | +| ---- | ----------------- | +| t2 | 8.833333333333334 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/highestcurrent.md b/content/flux/v0.x/stdlib/universe/highestcurrent.md index e66878b1c..03ae43706 100644 --- a/content/flux/v0.x/stdlib/universe/highestcurrent.md +++ b/content/flux/v0.x/stdlib/universe/highestcurrent.md @@ -1,82 +1,114 @@ --- title: highestCurrent() function -description: The `highestCurrent()` function selects the last record of each table in the input stream and returns the top `n` records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/highestcurrent - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/highestcurrent/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestcurrent/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/highestcurrent/ +description: > + `highestCurrent()` selects the last record from each input table and returns the + highest `n` records. menu: flux_0_x_ref: name: highestCurrent parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] + identifier: universe/highestCurrent +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `highestCurrent()` function selects the last record of each table in the input stream and returns the top `n` records. -The function outputs a single aggregated table containing `n` records. -_`highestCurrent()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`highestCurrent()` selects the last record from each input table and returns the +highest `n` records. + +**Note:** `highestCurrent()` drops empty tables. + +##### Function type signature ```js -highestCurrent( - n:10, - column: "_value", - groupColumns: [], -) +(<-tables: stream[A], n: int, ?column: string, ?groupColumns: [string]) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`highestCurrent()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n +({{< req >}}) Number of records to return. -### column {data-type="string"} -Column by which to sort. -Default is `"_value"`. -### groupColumns {data-type="array of strings"} -The columns on which to group before performing the aggregation. -Default is `[]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### column + +Column to evaluate. Default is `_value`. + + + +### groupColumns + +List of columns to group by. Default is `[]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} + +### Return the highest current value from a stream of tables ```js import "sampledata" sampledata.int() - |> highestCurrent(n: 2, groupColumns: ["tag"]) + |> highestCurrent(n: 1, groupColumns: ["tag"]) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:50Z | t1 | 4 | -| 2021-01-01T00:00:50Z | t2 | 1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 4 | t1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/highestmax.md b/content/flux/v0.x/stdlib/universe/highestmax.md index e39278310..d7cbcc620 100644 --- a/content/flux/v0.x/stdlib/universe/highestmax.md +++ b/content/flux/v0.x/stdlib/universe/highestmax.md @@ -1,56 +1,77 @@ --- title: highestMax() function -description: The `highestMax()` function selects the maximum record from each table in the input stream and returns the top `n` records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/highestmax - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/highestmax/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestmax/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/highestmax/ +description: > + `highestMax()` selects the record with the highest value in the specified `column` + from each input table and returns the highest `n` records. menu: flux_0_x_ref: name: highestMax parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] + identifier: universe/highestMax +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `highestMax()` function selects the maximum record from each table in the input stream and returns the top `n` records. -The function outputs a single aggregated table containing `n` records. -_`highestMax()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`highestMax()` selects the record with the highest value in the specified `column` +from each input table and returns the highest `n` records. + +**Note:** `highestMax()` drops empty tables. + +##### Function type signature ```js -highestMax( - n:10, - column: "_value", - groupColumns: [], -) +(<-tables: stream[A], n: int, ?column: string, ?groupColumns: [string]) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`highestMax()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n +({{< req >}}) Number of records to return. -### column {data-type="string"} -Column by which to sort. -Default is `"_value"`. -### groupColumns {data-type="array of strings"} -The columns on which to group before performing the aggregation. -Default is `[]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### column + +Column to evaluate. Default is `_value`. + + + +### groupColumns + +List of columns to group by. Default is `[]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} + +### Return the highest two values from a stream of tables ```js import "sampledata" @@ -60,23 +81,35 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:30Z | t1 | 17 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:30Z | 17 | t1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/histogram.md b/content/flux/v0.x/stdlib/universe/histogram.md index 7e6ba3800..a66aa2134 100644 --- a/content/flux/v0.x/stdlib/universe/histogram.md +++ b/content/flux/v0.x/stdlib/universe/histogram.md @@ -1,85 +1,113 @@ --- title: histogram() function -description: The `histogram()` function approximates the cumulative distribution of a dataset by counting data frequencies for a list of bins. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/histogram - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/histogram/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/histogram/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/histogram/ +description: > + `histogram()` approximates the cumulative distribution of a dataset by counting + data frequencies for a list of bins. menu: flux_0_x_ref: name: histogram parent: universe -weight: 102 + identifier: universe/histogram +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/histograms/ introduced: 0.7.0 --- -The `histogram()` function approximates the cumulative distribution of a dataset by counting data frequencies for a list of bins. -A bin is defined by an upper bound where all data points that are less than or equal to the bound are counted in the bin. -The bin counts are cumulative. + + +`histogram()` approximates the cumulative distribution of a dataset by counting +data frequencies for a list of bins. + +A bin is defined by an upper bound where all data points that are less than +or equal to the bound are counted in the bin. Bin counts are cumulative. Each input table is converted into a single output table representing a single histogram. -The output table has the same group key as the input table. -Columns not part of the group key are removed and an upper bound column and a count column are added. +Each output table has the same group key as the corresponding input table. +Columns not part of the group key are dropped. +Output tables include additional columns for the upper bound and count of bins. + +##### Function type signature ```js -histogram( - column: "_value", - upperBoundColumn: "le", - countColumn: "_value", - bins: [50.0, 75.0, 90.0], - normalize: false, -) +( + <-tables: stream[A], + bins: [float], + ?column: string, + ?countColumn: string, + ?normalize: bool, + ?upperBoundColumn: string, +) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -The name of a column containing input data values. -The column type must be float. -Default is `"_value"`. +### column -### upperBoundColumn {data-type="string"} -The name of the column in which to store the histogram's upper bounds. -Default is `"le"`. +Column containing input values. Column must be of type float. +Default is `_value`. -### countColumn {data-type="string"} -The name of the column in which to store the histogram counts. -Default is `"_value"`. -### bins {data-type="array of floats"} -({{< req >}}) A list of upper bounds to use when computing the histogram frequencies. + +### upperBoundColumn + +Column to store bin upper bounds in. Default is `le`. + + + +### countColumn + +Column to store bin counts in. Default is `_value`. + + + +### bins +({{< req >}}) +List of upper bounds to use when computing the histogram frequencies. + Bins should contain a bin whose bound is the maximum value of the data set. This value can be set to positive infinity if no maximum is known. - #### Bin helper functions The following helper functions can be used to generated bins. +- linearBins() +- logarithmicBins() -[linearBins()](/flux/v0.x/stdlib/universe/linearbins) -[logarithmicBins()](/flux/v0.x/stdlib/universe/logarithmicbins) +### normalize -### normalize {data-type="bool"} -When `true`, will convert the counts into frequency values between 0 and 1. +Convert counts into frequency values between 0 and 1. Default is `false`. -{{% note %}} -Normalized histograms cannot be aggregated by summing their counts. -{{% /note %}} +**Note**: Normalized histograms cannot be aggregated by summing their counts. + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Create a cumulative histogram](#create-a-cumulative-histogram) - [Create a cumulative histogram with dynamically generated bins](#create-a-cumulative-histogram-with-dynamically-generated-bins) -#### Create a cumulative histogram +### Create a cumulative histogram + ```js import "sampledata" @@ -88,37 +116,50 @@ sampledata.float() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "float" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -##### Output data -| tag | le | _value | -| :-- | ---: | -----: | -| t1 | 0.0 | 1.0 | -| t1 | 5.0 | 2.0 | -| t1 | 10.0 | 3.0 | -| t1 | 20.0 | 6.0 | +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | -| tag | le | _value | -| :-- | ---: | -----: | -| t2 | 0.0 | 1.0 | -| t2 | 5.0 | 3.0 | -| t2 | 10.0 | 3.0 | -| t2 | 20.0 | 6.0 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | le | _value | +| ---- | --- | ------- | +| t1 | 0 | 1 | +| t1 | 5 | 2 | +| t1 | 10 | 3 | +| t1 | 20 | 6 | + +| *tag | le | _value | +| ---- | --- | ------- | +| t2 | 0 | 1 | +| t2 | 5 | 3 | +| t2 | 10 | 3 | +| t2 | 20 | 6 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Create a cumulative histogram with dynamically generated bins +### Create a cumulative histogram with dynamically generated bins + ```js import "sampledata" @@ -126,31 +167,45 @@ sampledata.float() |> histogram(bins: linearBins(start: 0.0, width: 4.0, count: 3)) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "float" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -##### Output data -| tag | le | _value | -| :-- | ---: | -----: | -| t1 | 0.0 | 1.0 | -| t1 | 4.0 | 1.0 | -| t1 | 8.0 | 3.0 | -| t1 | +Inf | 6.0 | +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | -| tag | le | _value | -| :-- | ---: | -----: | -| t2 | 0.0 | 1.0 | -| t2 | 4.0 | 2.0 | -| t2 | 8.0 | 3.0 | -| t2 | +Inf | 6.0 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | le | _value | +| ---- | ---- | ------- | +| t1 | 0 | 1 | +| t1 | 4 | 1 | +| t1 | 8 | 3 | +| t1 | +Inf | 6 | + +| *tag | le | _value | +| ---- | ---- | ------- | +| t2 | 0 | 1 | +| t2 | 4 | 2 | +| t2 | 8 | 3 | +| t2 | +Inf | 6 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/histogramquantile.md b/content/flux/v0.x/stdlib/universe/histogramquantile.md index 2e8dc151e..f21e5ed75 100644 --- a/content/flux/v0.x/stdlib/universe/histogramquantile.md +++ b/content/flux/v0.x/stdlib/universe/histogramquantile.md @@ -1,137 +1,150 @@ --- title: histogramQuantile() function description: > - The `histogramQuantile()` function approximates a quantile given a histogram - that approximates the cumulative distribution of the dataset. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/histogramquantile - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/histogramquantile/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/histogramquantile/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/histogramquantile/ + `histogramQuantile()` approximates a quantile given a histogram that approximates + the cumulative distribution of the dataset. menu: flux_0_x_ref: name: histogramQuantile parent: universe -weight: 102 -related: - - /flux/v0.x/stdlib/experimental/histogramquantile/ -flux/v0.x/tags: [aggregates, transformations] -introduced: 0.7.0 + identifier: universe/histogramQuantile +weight: 101 +flux/v0.x/tags: [transformations] --- -The `histogramQuantile()` function approximates a quantile given a histogram that -approximates the cumulative distribution of the dataset. + + +`histogramQuantile()` approximates a quantile given a histogram that approximates +the cumulative distribution of the dataset. + Each input table represents a single histogram. The histogram tables must have two columns – a count column and an upper bound column. The count is the number of values that are less than or equal to the upper bound value. -The table can have any number of records, each representing an entry in the histogram. +The table can have any number of records, each representing a bin in the histogram. The counts must be monotonically increasing when sorted by upper bound. -If any values in the count column or upper bound column are `null`, it returns an error. +If any values in the count column or upper bound column are _null_, it returns an error. +The count and upper bound columns must **not** be part of the group key. -Linear interpolation between the two closest bounds is used to compute the quantile. -If the either of the bounds used in interpolation are infinite, -then the other finite bound is used and no interpolation is performed. +The quantile is computed using linear interpolation between the two closest bounds. +If either of the bounds used in interpolation are infinite, the other finite +bound is used and no interpolation is performed. -The output table has the same group key as the input table. -Columns not part of the group key are removed and a single value column of type float is added. -The count and upper bound columns must not be part of the group key. +### Output tables +Output tables have the same group key as corresponding input tables. +Columns not part of the group key are dropped. +A single value column of type float is added. The value column represents the value of the desired quantile from the histogram. -_**Output data type:** Float_ +##### Function type signature ```js -histogramQuantile( - quantile: 0.5, - countColumn: "_value", - upperBoundColumn: "le", - valueColumn: "_value", - minValue: 0.0, -) +( + <-tables: stream[A], + ?countColumn: string, + ?minValue: float, + ?quantile: float, + ?upperBoundColumn: string, + ?valueColumn: string, +) => stream[B] where A: Record, B: Record ``` -_`histogramQuantile()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### quantile {data-type="float"} -({{< req >}}) -A value between 0 and 1 indicating the desired quantile to compute. +### quantile -### countColumn {data-type="string"} -The name of the column containing the histogram counts. -The count column type must be float. -Default is `"_value"`. +Quantile to compute. Value must be between 0 and 1. -### upperBoundColumn {data-type="string"} -The name of the column containing the histogram upper bounds. -The upper bound column type must be float. -Default is `"le"`. -### valueColumn {data-type="string"} -The name of the output column which will contain the computed quantile. -Default is `"_value"`. -### minValue {data-type="float"} -The assumed minimum value of the dataset. -When the quantile falls below the lowest upper bound, interpolation is performed between `minValue` and the lowest upper bound. +### countColumn + +Column containing histogram bin counts. Default is `_value`. + + + +### upperBoundColumn + +Column containing histogram bin upper bounds. +Default is `le`. + + + +### valueColumn + +Column to store the computed quantile in. Default is `_value. + + + +### minValue + +Assumed minimum value of the dataset. Default is `0.0`. + +If the quantile falls below the lowest upper bound, interpolation is +performed between `minValue` and the lowest upper bound. When `minValue` is equal to negative infinity, the lowest upper bound is used. -Default is `0.0`. -{{% note %}} -When the quantile falls below the lowest upper bound, -interpolation is performed between `minValue` and the lowest upper bound. -When `minValue` is equal to negative infinity, the lowest upper bound is used. -{{% /note %}} +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -##### Compute the 90th quantile of a histogram +### Compute the 90th quantile of a histogram + ```js -import "sampledata" - -data = sampledata.float() - |> histogram(bins: [0.0, 5.0, 10.0, 20.0]) - data |> histogramQuantile(quantile: 0.9) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -| tag | le | _value | -| :-- | ---: | -----: | -| t1 | 0.0 | 1.0 | -| t1 | 5.0 | 2.0 | -| t1 | 10.0 | 3.0 | -| t1 | 20.0 | 6.0 | +#### Input data -| tag | le | _value | -| :-- | ---: | -----: | -| t2 | 0.0 | 1.0 | -| t2 | 5.0 | 3.0 | -| t2 | 10.0 | 3.0 | -| t2 | 20.0 | 6.0 | +| *tag | le | _value | +| ---- | --- | ------- | +| t1 | 0 | 1 | +| t1 | 5 | 2 | +| t1 | 10 | 3 | +| t1 | 20 | 6 | -{{% /flex-content %}} -{{% flex-content %}} +| *tag | le | _value | +| ---- | --- | ------- | +| t2 | 0 | 1 | +| t2 | 5 | 3 | +| t2 | 10 | 3 | +| t2 | 20 | 6 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | 18.0 | -| tag | _value | -| :-- | -----: | -| t2 | 18.0 | +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 18 | + +| *tag | _value | +| ---- | ------- | +| t2 | 18 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/holtwinters.md b/content/flux/v0.x/stdlib/universe/holtwinters.md index 47e5a9864..e29ee8d91 100644 --- a/content/flux/v0.x/stdlib/universe/holtwinters.md +++ b/content/flux/v0.x/stdlib/universe/holtwinters.md @@ -1,120 +1,144 @@ --- title: holtWinters() function description: > - The `holtWinters()` function applies the Holt-Winters forecasting method to input tables. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/holtwinters - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/holtwinters/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/holtwinters/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/holtwinters/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/holtwinters/ + `holtWinters()` applies the Holt-Winters forecasting method to input tables. menu: flux_0_x_ref: name: holtWinters parent: universe -weight: 102 + identifier: universe/holtWinters +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#holt-winters, InfluxQL HOLT_WINTERS() introduced: 0.38.0 --- -The `holtWinters()` function applies the Holt-Winters forecasting method to input tables. + + +`holtWinters()` applies the Holt-Winters forecasting method to input tables. + +The Holt-Winters method predicts `n` seasonally-adjusted values for the +specified column at the specified interval. For example, if interval is six +minutes (`6m`) and `n` is `3`, results include three predicted values six +minutes apart. #### Seasonality -[`seasonality`](#seasonality) delimits the length of a seasonal pattern according to `interval`. -If your `interval` is two minutes (`2m`) and `seasonality` is `4`, then the seasonal pattern occurs every eight minutes or every four data points. Likewise, if your `interval` is two months (`2mo`) and `seasonality` is `4`, then the seasonal pattern occurs every eight months or every four data points. -If data doesn't have a seasonal pattern, set `seasonality` to `0`. +`seasonality` delimits the length of a seasonal pattern according to interval. +If the interval is two minutes (`2m`) and `seasonality` is `4`, then the +seasonal pattern occurs every eight minutes or every four data points. +If your interval is two months (`2mo`) and `seasonality` is `4`, then the +seasonal pattern occurs every eight months or every four data points. +If data doesn’t have a seasonal pattern, set `seasonality` to `0`. -#### Space values evenly in time -`holtWinters()` expects values evenly spaced in time. -To ensure `holtWinters()` values are spaced evenly in time, the following rules apply: +#### Space values at even time intervals +`holtWinters()` expects values to be spaced at even time intervales. +To ensure values are spaced evenly in time, `holtWinters()` applies the +following rules: -- Data is grouped into time-based "buckets" determined by the `interval`. +- Data is grouped into time-based "buckets" determined by the interval. - If a bucket includes many values, the first value is used. - If a bucket includes no values, a missing value (`null`) is added for that bucket. -By default, `holtWinters()` uses the first value in each time bucket to run the Holt-Winters calculation. -To specify other values to use in the calculation, use: - -- [`window()`](/flux/v0.x/stdlib/universe/window/) - with [selectors](/flux/v0.x/function-types/#selectors) - or [aggregates](/flux/v0.x/function-types/#aggregates) -- [`aggregateWindow()`](/flux/v0.x/stdlib/universe/aggregatewindow) - -###### Use aggregateWindow to normalize irregular times -```js -data - |> aggregateWindow(every: 1d, fn: first) - |> holtWinters(n: 10, seasonality: 4, interval: 1d) -``` +By default, `holtWinters()` uses the first value in each time bucket to run +the Holt-Winters calculation. To specify other values to use in the +calculation, use `aggregateWindow` to normalize irregular times and apply +an aggregate or selector transformation. #### Fitted model -The `holtWinters()` function applies the [Nelder-Mead optimization](https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method) -to include "fitted" data points in results when [`withFit`](#withfit) is set to `true`. +`holtWinters()` applies the [Nelder-Mead optimization](https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method) +to include "fitted" data points in results when `withFit` is set to `true`. #### Null timestamps -`holtWinters()` discards rows with `null` timestamps before running the Holt-Winters calculation. +`holtWinters()` discards rows with null timestamps before running the +Holt-Winters calculation. #### Null values -`holtWinters()` treats `null` values as missing data points and includes them in the Holt-Winters calculation. +`holtWinters()` treats `null` values as missing data points and includes them +in the Holt-Winters calculation. + +##### Function type signature + +```js +( + <-tables: stream[A], + interval: duration, + n: int, + ?column: string, + ?seasonality: int, + ?timeColumn: string, + ?withFit: bool, +) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n ({{< req >}}) -The number of values to predict. +Number of values to predict. -### seasonality {data-type="int"} -The number of points in a season. -Default is `0`. -### interval {data-type="duration"} + +### interval ({{< req >}}) -The interval between two data points. +Interval between two data points. -### withFit {data-type="bool"} -Return [fitted data](#fitted-model) in results. -Default is `false`. -### timeColumn {data-type="string"} -The time column to use. -Default is `"_time"`. -### column {data-type="string"} -The column to operate on. -Default is `"_value"`. +### withFit + +Return fitted data in results. Default is `false`. + + + +### column + +Column to operate on. Default is `_value`. + + + +### timeColumn + +Column containing time values to use in the calculating. +Default is `_time`. + + + +### seasonality + +Number of points in a season. Default is `0`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Use holtWinters to predict future values](#use-holtwinters-to-predict-future-values) - [Use holtWinters with seasonality to predict future values](#use-holtwinters-with-seasonality-to-predict-future-values) - [Use the holtWinters fitted model to predict future values](#use-the-holtwinters-fitted-model-to-predict-future-values) -#### Use holtWinters to predict future values +### Use holtWinters to predict future values + ```js import "sampledata" @@ -123,41 +147,54 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:01:00Z | t1 | 10.955834804389518 | -| 2021-01-01T00:01:10Z | t1 | 10.930165921204969 | -| 2021-01-01T00:01:20Z | t1 | 10.914688653595203 | -| 2021-01-01T00:01:30Z | t1 | 10.905759343909201 | -| 2021-01-01T00:01:40Z | t1 | 10.900719277060372 | -| 2021-01-01T00:01:50Z | t1 | 10.897906726242955 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:01:00Z | t2 | 6.781008791726221 | -| 2021-01-01T00:01:10Z | t2 | 6.781069271640753 | -| 2021-01-01T00:01:20Z | t2 | 6.781073869897851 | -| 2021-01-01T00:01:30Z | t2 | 6.7810742195001135 | -| 2021-01-01T00:01:40Z | t2 | 6.781074246080124 | -| 2021-01-01T00:01:50Z | t2 | 6.781074248100982 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | _time | _value | +| ---- | -------------------- | ------------------ | +| t1 | 2021-01-01T00:01:00Z | 10.955834804389518 | +| t1 | 2021-01-01T00:01:10Z | 10.930165921204969 | +| t1 | 2021-01-01T00:01:20Z | 10.914688653595203 | +| t1 | 2021-01-01T00:01:30Z | 10.905759343909201 | +| t1 | 2021-01-01T00:01:40Z | 10.900719277060372 | +| t1 | 2021-01-01T00:01:50Z | 10.897906726242955 | + +| *tag | _time | _value | +| ---- | -------------------- | ------------------ | +| t2 | 2021-01-01T00:01:00Z | 6.781008791726221 | +| t2 | 2021-01-01T00:01:10Z | 6.781069271640753 | +| t2 | 2021-01-01T00:01:20Z | 6.781073869897851 | +| t2 | 2021-01-01T00:01:30Z | 6.7810742195001135 | +| t2 | 2021-01-01T00:01:40Z | 6.781074246080124 | +| t2 | 2021-01-01T00:01:50Z | 6.781074248100982 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Use holtWinters with seasonality to predict future values +### Use holtWinters with seasonality to predict future values + ```js import "sampledata" @@ -166,37 +203,50 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:01:00Z | t1 | 7.179098046049717 | -| 2021-01-01T00:01:10Z | t1 | 17.01106624302682 | -| 2021-01-01T00:01:20Z | t1 | 14.576432091790977 | -| 2021-01-01T00:01:30Z | t1 | 6.968535480723005 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -------------------: | -| 2021-01-01T00:01:00Z | t2 | 0.008498516062705495 | -| 2021-01-01T00:01:10Z | t2 | 4.311588701815885 | -| 2021-01-01T00:01:20Z | t2 | 4.306517319025279 | -| 2021-01-01T00:01:30Z | t2 | 2.473640466434541 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | _time | _value | +| ---- | -------------------- | ------------------ | +| t1 | 2021-01-01T00:01:00Z | 7.179098046049717 | +| t1 | 2021-01-01T00:01:10Z | 17.01106624302682 | +| t1 | 2021-01-01T00:01:20Z | 14.576432091790977 | +| t1 | 2021-01-01T00:01:30Z | 6.968535480723005 | + +| *tag | _time | _value | +| ---- | -------------------- | -------------------- | +| t2 | 2021-01-01T00:01:00Z | 0.008498516062705495 | +| t2 | 2021-01-01T00:01:10Z | 4.311588701815885 | +| t2 | 2021-01-01T00:01:20Z | 4.306517319025279 | +| t2 | 2021-01-01T00:01:30Z | 2.473640466434541 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Use the holtWinters fitted model to predict future values +### Use the holtWinters fitted model to predict future values + ```js import "sampledata" @@ -204,41 +254,55 @@ sampledata.int() |> holtWinters(n: 3, interval: 10s, withFit: true) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:00Z | t1 | -2.0 | -| 2021-01-01T00:00:10Z | t1 | 9.218975712746163 | -| 2021-01-01T00:00:20Z | t1 | 10.724838162080957 | -| 2021-01-01T00:00:30Z | t1 | 11.02931521239947 | -| 2021-01-01T00:00:40Z | t1 | 11.0379002238265 | -| 2021-01-01T00:00:50Z | t1 | 10.994404043609528 | -| 2021-01-01T00:01:00Z | t1 | 10.955834804389518 | -| 2021-01-01T00:01:10Z | t1 | 10.930165921204969 | -| 2021-01-01T00:01:20Z | t1 | 10.914688653595203 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:00Z | t2 | 19.0 | -| 2021-01-01T00:00:10Z | t2 | 8.907308429189435 | -| 2021-01-01T00:00:20Z | t2 | 4.983321898435179 | -| 2021-01-01T00:00:30Z | t2 | 6.633066160485693 | -| 2021-01-01T00:00:40Z | t2 | 6.769755828568384 | -| 2021-01-01T00:00:50Z | t2 | 6.780213338483446 | -| 2021-01-01T00:01:00Z | t2 | 6.781008791726221 | -| 2021-01-01T00:01:10Z | t2 | 6.781069271640753 | -| 2021-01-01T00:01:20Z | t2 | 6.781073869897851 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | _time | _value | +| ---- | -------------------- | ------------------ | +| t1 | 2021-01-01T00:00:00Z | -2 | +| t1 | 2021-01-01T00:00:10Z | 9.218975712746163 | +| t1 | 2021-01-01T00:00:20Z | 10.724838162080957 | +| t1 | 2021-01-01T00:00:30Z | 11.02931521239947 | +| t1 | 2021-01-01T00:00:40Z | 11.0379002238265 | +| t1 | 2021-01-01T00:00:50Z | 10.994404043609528 | +| t1 | 2021-01-01T00:01:00Z | 10.955834804389518 | +| t1 | 2021-01-01T00:01:10Z | 10.930165921204969 | +| t1 | 2021-01-01T00:01:20Z | 10.914688653595203 | + +| *tag | _time | _value | +| ---- | -------------------- | ----------------- | +| t2 | 2021-01-01T00:00:00Z | 19 | +| t2 | 2021-01-01T00:00:10Z | 8.907308429189435 | +| t2 | 2021-01-01T00:00:20Z | 4.983321898435179 | +| t2 | 2021-01-01T00:00:30Z | 6.633066160485693 | +| t2 | 2021-01-01T00:00:40Z | 6.769755828568384 | +| t2 | 2021-01-01T00:00:50Z | 6.780213338483446 | +| t2 | 2021-01-01T00:01:00Z | 6.781008791726221 | +| t2 | 2021-01-01T00:01:10Z | 6.781069271640753 | +| t2 | 2021-01-01T00:01:20Z | 6.781073869897851 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/hourselection.md b/content/flux/v0.x/stdlib/universe/hourselection.md index 99369f50b..03f6ba62e 100644 --- a/content/flux/v0.x/stdlib/universe/hourselection.md +++ b/content/flux/v0.x/stdlib/universe/hourselection.md @@ -1,104 +1,115 @@ --- title: hourSelection() function description: > - The `hourSelection()` function retains all rows with time values in a specified hour range. - Hours are specified in military time. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/hourselection - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/hourselection/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/hourselection/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/hourselection/ + `hourSelection()` filters rows by time values in a specified hour range. menu: flux_0_x_ref: name: hourSelection parent: universe -weight: 102 -flux/v0.x/tags: [transformations, date/time] + identifier: universe/hourSelection +weight: 101 +flux/v0.x/tags: [transformations, date/time, filters] introduced: 0.39.0 --- -The `hourSelection()` function retains all rows with time values in a specified hour range. + + +`hourSelection()` filters rows by time values in a specified hour range. + + + +##### Function type signature ```js -hourSelection( - start: 9, - stop: 17, - location: {offset: 0h, zone: "UTC"}, - timeColumn: "_time", -) +( + <-tables: stream[A], + start: int, + stop: int, + ?location: {zone: string, offset: duration}, + ?timeColumn: string, +) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### start {data-type="int"} +### start ({{< req >}}) -The first hour of the hour range (inclusive). -Hours range from `[0-23]`. +First hour of the hour range (inclusive). Hours range from `[0-23]`. -### stop {data-type="int"} + + +### stop ({{< req >}}) -The last hour of the hour range (inclusive). -Hours range from `[0-23]`. +Last hour of the hour range (inclusive). Hours range from `[0-23]`. + + + +### location + +Location used to determine timezone. Default is the `location` option. + + + +### timeColumn + +Column that contains the time value. Default is `_time`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -### location {data-type="record"} -Location used to determine timezone. -Default is the [`location` option](/flux/v0.x/stdlib/universe/#location). -### timeColumn {data-type="string"} -The column that contains the time value. -Default is `"_time"`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -The following example uses [`generate.from()`](/flux/v0.x/stdlib/generate/from/) -to generate sample data and show how `covariance()` transforms data. -#### Filter by business hours +### Filter by business hours + ```js -import "generate" - -data = generate.from( - count: 8, - fn: (n) => n * n, - start: 2021-01-01T00:00:00Z, - stop: 2021-01-02T00:00:00Z, -) - -data +data |> hourSelection(start: 9, stop: 17) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T00:00:00Z | 0 | -| 2021-01-01T03:00:00Z | 1 | -| 2021-01-01T06:00:00Z | 4 | -| 2021-01-01T09:00:00Z | 9 | -| 2021-01-01T12:00:00Z | 16 | -| 2021-01-01T15:00:00Z | 25 | -| 2021-01-01T18:00:00Z | 36 | -| 2021-01-01T21:00:00Z | 49 | +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T05:00:00Z | t1 | -2 | +| 2022-01-01T09:00:10Z | t1 | 10 | +| 2022-01-01T11:00:20Z | t1 | 7 | +| 2022-01-01T16:00:30Z | t1 | 17 | +| 2022-01-01T19:00:40Z | t1 | 15 | +| 2022-01-01T20:00:50Z | t1 | 4 | -##### Output data -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T09:00:00Z | 9 | -| 2021-01-01T12:00:00Z | 16 | -| 2021-01-01T15:00:00Z | 25 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | tag | _value | +| -------------------- | ---- | ------- | +| 2022-01-01T09:00:10Z | t1 | 10 | +| 2022-01-01T11:00:20Z | t1 | 7 | +| 2022-01-01T16:00:30Z | t1 | 17 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/increase.md b/content/flux/v0.x/stdlib/universe/increase.md index 9ca615339..41ce7b148 100644 --- a/content/flux/v0.x/stdlib/universe/increase.md +++ b/content/flux/v0.x/stdlib/universe/increase.md @@ -1,52 +1,66 @@ --- title: increase() function description: > - The `increase()` function calculates the cumulative sum of **non-negative** differences - between subsequent values. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/increase - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/increase/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/increase/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/increase/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/increase/ + `increase()` returns the cumulative sum of non-negative differences between subsequent values. menu: flux_0_x_ref: name: increase parent: universe -weight: 102 + identifier: universe/increase +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/increase/ introduced: 0.71.0 --- -The `increase()` function calculates the cumulative sum of **non-negative** differences -between subsequent values. -A main use case is tracking changes in counter values which may wrap over time -when they hit a threshold or are reset. -In the case of a wrap/reset, we can assume that the absolute delta between two -points will be at least their non-negative difference. + + +`increase()` returns the cumulative sum of non-negative differences between subsequent values. + +The primary use case for `increase()` is tracking changes in counter values +which may wrap overtime when they hit a threshold or are reset. In the case +of a wrap/reset, `increase()` assumes that the absolute delta between two +points is at least their non-negative difference. + +##### Function type signature ```js -increase(columns: ["_value"]) +(<-tables: stream[A], ?columns: [string]) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### columns {data-type="array of strings"} -Columns to use in the operation. -Default is `["_value"]`. +### columns + +List of columns to operate on. Default is `["_value"]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Output tables -For each input table with `n` rows, `increase()` outputs a table with `n - 1` rows. ## Examples -{{% flux/sample-example-intro %}} +### Normalize resets in counter metrics ```js import "sampledata" @@ -56,37 +70,48 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | 0 | -| 2021-01-01T00:00:10Z | t1 | 12 | -| 2021-01-01T00:00:20Z | t1 | 19 | -| 2021-01-01T00:00:30Z | t1 | 29 | -| 2021-01-01T00:00:40Z | t1 | 44 | -| 2021-01-01T00:00:50Z | t1 | 48 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 0 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | 4 | -| 2021-01-01T00:00:30Z | t2 | 26 | -| 2021-01-01T00:00:40Z | t2 | 39 | -| 2021-01-01T00:00:50Z | t2 | 40 | +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t1 | +| 2021-01-01T00:00:10Z | 12 | t1 | +| 2021-01-01T00:00:20Z | 19 | t1 | +| 2021-01-01T00:00:30Z | 29 | t1 | +| 2021-01-01T00:00:40Z | 44 | t1 | +| 2021-01-01T00:00:50Z | 48 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 4 | t2 | +| 2021-01-01T00:00:30Z | 26 | t2 | +| 2021-01-01T00:00:40Z | 39 | t2 | +| 2021-01-01T00:00:50Z | 40 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/int.md b/content/flux/v0.x/stdlib/universe/int.md index eacf7f2b4..8d66db404 100644 --- a/content/flux/v0.x/stdlib/universe/int.md +++ b/content/flux/v0.x/stdlib/universe/int.md @@ -1,32 +1,34 @@ --- title: int() function -description: The `int()` function converts a single value to an integer. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/int/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/int/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/int/ +description: > + `int()` converts a value to an integer type. menu: flux_0_x_ref: name: int parent: universe -weight: 102 + identifier: universe/int +weight: 101 flux/v0.x/tags: [type-conversions] -related: - - /flux/v0.x/data-types/basic/int/ - - /flux/v0.x/stdlib/universe/toint/ introduced: 0.7.0 --- -The `int()` function converts a single value to an integer. + + +`int()` converts a value to an integer type. `int()` behavior depends on the input data type: @@ -39,111 +41,102 @@ Value to convert. | float | Value truncated at the decimal | | uint | Integer equivalent of the unsigned integer | +##### Function type signature + +```js +(v: A) => int +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### v +({{< req >}}) +Value to convert. + + + + ## Examples -- [Convert a string to an integer value](#convert-a-string-to-an-integer-value) -- [Convert a boolean to an integer value](#convert-a-boolean-to-an-integer-value) -- [Convert a duration to an integer value](#convert-a-duration-to-an-integer-value) -- [Convert a time to an integer value](#convert-a-time-to-an-integer-value) -- [Convert a float to an integer value](#convert-a-float-to-an-integer-value) -- [Convert all values in a column to integer values](#convert-all-values-in-a-column-to-integer-values) +- [Convert basic types to integers](#convert-basic-types-to-integers) +- [Convert all values in a column to integers](#convert-all-values-in-a-column-to-integers) -#### Convert a string to an integer value -```js -int(v: "3") +### Convert basic types to integers -// Returns 3 (int) -``` - -#### Convert a boolean to an integer value -```js -int(v: true) - -// Returns 1 -``` - -#### Convert a duration to an integer value -```js -int(v: 1m) - -// Returns 160000000000 -``` - -#### Convert a time to an integer value -```js -int(v: 2021-01-01T00:00:00Z) - -// Returns 1609459200000000000 -``` - -#### Convert a float to an integer value ```js int(v: 10.12) // Returns 10 +int(v: "3") + +// Returns 3 +int(v: true) + +// Returns 1 +int(v: 1m) + +// Returns 160000000000 +int(v: 2022-01-01T00:00:00Z)// Returns 1640995200000000000 + ``` -#### Convert all values in a column to integer values -If updating values in the `_value` column, use [`toInt()`](/flux/v0.x/stdlib/universe/toint/). -To update values in columns other than `_value`: -1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows. -2. Use `int()` to update the value of a column. +### Convert all values in a column to integers -_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._ +If converting the `_value` column to integer types, use `toInt()`. +If converting columns other than `_value`, use `map()` to iterate over each +row and `int()` to covert a column value to a integer type. ```js -import "sampledata" - -data = sampledata.float() - |> rename(columns: {_value: "foo"}) - data - |> map(fn: (r) => ({r with foo: int(v: r.foo)})) + |> map(fn: (r) => ({r with exampleCol: int(v: r.exampleCol)})) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -| tag | _time | foo | -| :-- | :------------------- | ----: | -| t1 | 2021-01-01T00:00:00Z | -2.18 | -| t1 | 2021-01-01T00:00:10Z | 10.92 | -| t1 | 2021-01-01T00:00:20Z | 7.35 | -| t1 | 2021-01-01T00:00:30Z | 17.53 | -| t1 | 2021-01-01T00:00:40Z | 15.23 | -| t1 | 2021-01-01T00:00:50Z | 4.43 | +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| tag | _time | foo | -| :-- | :------------------- | ----: | -| t2 | 2021-01-01T00:00:00Z | 19.85 | -| t2 | 2021-01-01T00:00:10Z | 4.97 | -| t2 | 2021-01-01T00:00:20Z | -3.75 | -| t2 | 2021-01-01T00:00:30Z | 19.77 | -| t2 | 2021-01-01T00:00:40Z | 13.86 | -| t2 | 2021-01-01T00:00:50Z | 1.86 | +#### Input data -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | tag | foo | -| :------------------- | :-- | ---: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | *tag | exampleCol | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | exampleCol | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | foo | -| :------------------- | :-- | ---: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/integral.md b/content/flux/v0.x/stdlib/universe/integral.md index 9202248c5..204a64f02 100644 --- a/content/flux/v0.x/stdlib/universe/integral.md +++ b/content/flux/v0.x/stdlib/universe/integral.md @@ -1,118 +1,177 @@ --- title: integral() function -description: The `integral()` function computes the area under the curve per unit of time of subsequent non-null records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/integral - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/integral/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/integral/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/integral/ +description: > + `integral()` computes the area under the curve per unit of time of subsequent non-null records. menu: flux_0_x_ref: name: integral parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#integral, InfluxQL – INTEGRAL() - - /flux/v0.x/stdlib/experimental/integral/ + identifier: universe/integral +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `integral()` function computes the area under the curve per [`unit`](#unit) of time of subsequent non-null records. -`integral()` requires `_start` and `_stop` columns that are part of the [group key](/flux/v0.x/get-started/data-model/#group-key). -The curve is defined using `_time` as the domain and record values as the range. -_`integral()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`integral()` computes the area under the curve per unit of time of subsequent non-null records. + +`integral()` requires `_start` and `_stop` columns that are part of the group key. +The curve is defined using `_time` as the domain and record values as the range. + +##### Function type signature ```js -integral( - unit: 10s, - column: "_value", - timeColumn: "_time", - interpolate: "", -) +( + <-tables: stream[A], + ?column: string, + ?interpolate: string, + ?timeColumn: string, + ?unit: duration, +) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### unit {data-type="duration"} -({{< req >}}) -Time duration used when computing the integral. +### unit -### column {data-type="string"} -Column on which to operate. -Defaults to `"_value"`. +Unit of time to use to compute the integral. + + + +### column + +Column to operate on. Default is `_value`. + + + +### timeColumn -### timeColumn {data-type="string"} Column that contains time values to use in the operation. -Defaults to `"_time"`. +Default is `_time`. -### interpolate {data-type="string"} -Type of interpolation to use. -Defaults to `""`. -Use one of the following interpolation options: -- _empty string for no interpolation_ +### interpolate + +Type of interpolation to use. Default is `""`. + +**Available interplation types**: - linear +- _empty string for no interpolation_ + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} -#### Calculate the integral +- [Calculate the integral](#calculate-the-integral) +- [Calculate the integral with linear interpolation](#calculate-the-integral-with-linear-interpolation) + +### Calculate the integral + ```js -import "sampledata" - -sampledata.int() - |> range(start: sampledata.start, stop: sampledata.stop) - |> integral(unit:10s) +data + |> integral(unit: 10s) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" includeRange=true %}} +#### Input data -##### Output data -| _start | _stop | tag | _value | -| :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 50.0 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | -| _start | _stop | tag | _value | -| :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 43 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *_start | *_stop | *tag | _value | +| -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 50 | + +| *_start | *_stop | *tag | _value | +| -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 43 | {{% /expand %}} {{< /expand-wrapper >}} +### Calculate the integral with linear interpolation -#### Calculate the integral with linear interpolation ```js -import "sampledata" - -sampledata.int(includeNull: true) - |> range(start: sampledata.start, stop: sampledata.stop) - |> integral(unit:10s, interpolate: "linear") +data + |> integral(unit: 10s, interpolate: "linear") ``` -{{% expand "View input and output" %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" includeNull=true includeRange=true %}} +#### Input data -##### Output data -| _start | _stop | tag | _value | -| :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 25.0 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | -| _start | _stop | tag | _value | -| :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 32.5 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *_start | *_stop | *tag | _value | +| -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 25 | + +| *_start | *_stop | *tag | _value | +| -------------------- | -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 32.5 | {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/intervals.md b/content/flux/v0.x/stdlib/universe/intervals.md deleted file mode 100644 index df3ee4e5e..000000000 --- a/content/flux/v0.x/stdlib/universe/intervals.md +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: intervals() function -description: The `intervals()` function generates a set of time intervals over a range of time. -aliases: - - /influxdb/v2.0/reference/flux/functions/misc/intervals - - /influxdb/v2.0/reference/flux/functions/built-in/misc/intervals/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/intervals - - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/intervals/ - - /influxdb/cloud/reference/flux/stdlib/built-in/misc/intervals/ -menu: - flux_0_x_ref: - name: intervals - parent: universe -weight: 102 -draft: true ---- - -The `intervals()` function generates a set of time intervals over a range of time. - -An interval is a record with `start` and `stop` properties that correspond to the inclusive start and exclusive stop times of the time interval. -The return value of intervals is another function that accepts start and stop time parameters and returns an interval generator. -The generator is then used to produce the set of intervals. -The set of intervals includes all intervals that intersect with the initial range of time. - -{{% note %}} -The `intervals()` function is designed to be used with the intervals parameter -of the [`window()` function](/flux/v0.x/stdlib/universe/window). -{{% /note %}} - -By default the end boundary of an interval will align with the Unix epoch (zero time) -modified by the offset of the `location` option. - -```js -intervals() -``` - -## Parameters - -### every {data-type="duration"} -The duration between starts of each of the intervals. -The Nth interval start time is the initial start time plus the offset plus an Nth multiple of the every parameter. -Defaults to the value of the `period` duration. - -### period {data-type="duration"} -The length of each interval. -Each interval's stop time is equal to the interval start time plus the period duration. -It can be negative, indicating the start and stop boundaries are reversed. -Defaults to the value of the `every` duration. - -### offset {data-type="duration"} -The duration by which to shift the window boundaries. -It can be negative, indicating that the offset goes backwards in time. -Defaults to `0`, which will align window end boundaries with the `every` duration. - -### filter {data-type="function"} -A function that accepts an interval record and returns a boolean value. -Each potential interval is passed to the filter function. -When the function returns false, that interval is excluded from the set of intervals. -Defaults to include all intervals. - -## Examples - -##### Basic intervals -```js -// 1 hour intervals -intervals(every:1h) - -// 2 hour long intervals every 1 hour -intervals(every:1h, period:2h) - -// 2 hour long intervals every 1 hour starting at 30m past the hour -intervals(every:1h, period:2h, offset:30m) - -// 1 week intervals starting on Monday (by default weeks start on Sunday) -intervals(every:1w, offset:1d) - -// the hour from 11PM - 12AM every night -intervals(every:1d, period:-1h) - -// the last day of each month -intervals(every:1mo, period:-1d) -``` - -##### Using a predicate -```js -// 1 day intervals excluding weekends -intervals( - every: 1d, - filter: (interval) => !(weekday(time: interval.start) in [Sunday, Saturday]), -) - -// Work hours from 9AM - 5PM on work days. -intervals( - every: 1d, - period: 8h, - offset: 9h, - filter: (interval) => !(weekday(time: interval.start) in [Sunday, Saturday]), -) -``` - -##### Using known start and stop dates -```js -// Every hour for six hours on Sep 5th. -intervals(every: 1h)(start: 2018-09-05T00:00:00-07:00, stop: 2018-09-05T06:00:00-07:00) - -// Generates -// [2018-09-05T00:00:00-07:00, 2018-09-05T01:00:00-07:00) -// [2018-09-05T01:00:00-07:00, 2018-09-05T02:00:00-07:00) -// [2018-09-05T02:00:00-07:00, 2018-09-05T03:00:00-07:00) -// [2018-09-05T03:00:00-07:00, 2018-09-05T04:00:00-07:00) -// [2018-09-05T04:00:00-07:00, 2018-09-05T05:00:00-07:00) -// [2018-09-05T05:00:00-07:00, 2018-09-05T06:00:00-07:00) - -// Every hour for six hours with 1h30m periods on Sep 5th -intervals(every: 1h, period: 1h30m)(start: 2018-09-05T00:00:00-07:00, stop: 2018-09-05T06:00:00-07:00) - -// Generates -// [2018-09-05T00:00:00-07:00, 2018-09-05T01:30:00-07:00) -// [2018-09-05T01:00:00-07:00, 2018-09-05T02:30:00-07:00) -// [2018-09-05T02:00:00-07:00, 2018-09-05T03:30:00-07:00) -// [2018-09-05T03:00:00-07:00, 2018-09-05T04:30:00-07:00) -// [2018-09-05T04:00:00-07:00, 2018-09-05T05:30:00-07:00) -// [2018-09-05T05:00:00-07:00, 2018-09-05T06:30:00-07:00) - -// Every hour for six hours using the previous hour on Sep 5th -intervals(every: 1h, period: -1h)(start: 2018-09-05T12:00:00-07:00, stop: 2018-09-05T18:00:00-07:00) - -// Generates -// [2018-09-05T11:00:00-07:00, 2018-09-05T12:00:00-07:00) -// [2018-09-05T12:00:00-07:00, 2018-09-05T13:00:00-07:00) -// [2018-09-05T13:00:00-07:00, 2018-09-05T14:00:00-07:00) -// [2018-09-05T14:00:00-07:00, 2018-09-05T15:00:00-07:00) -// [2018-09-05T15:00:00-07:00, 2018-09-05T16:00:00-07:00) -// [2018-09-05T16:00:00-07:00, 2018-09-05T17:00:00-07:00) -// [2018-09-05T17:00:00-07:00, 2018-09-05T18:00:00-07:00) - -// Every month for 4 months starting on Jan 1st -intervals(every: 1mo)(start: 2018-01-01T00:00:00Z, stop: 2018-05-01T00:00:00Z) - -// Generates -// [2018-01-01, 2018-02-01) -// [2018-02-01, 2018-03-01) -// [2018-03-01, 2018-04-01) -// [2018-04-01, 2018-05-01) - -// Every month for 4 months starting on Jan 15th -intervals(every: 1mo)(start: 2018-01-15T00:00:00Z, stop: 2018-05-15T00:00:00Z) - -// Generates -// [2018-01-15, 2018-02-15) -// [2018-02-15, 2018-03-15) -// [2018-03-15, 2018-04-15) -// [2018-04-15, 2018-05-15) -``` diff --git a/content/flux/v0.x/stdlib/universe/join.md b/content/flux/v0.x/stdlib/universe/join.md index 960bdd14b..9ab3a7822 100644 --- a/content/flux/v0.x/stdlib/universe/join.md +++ b/content/flux/v0.x/stdlib/universe/join.md @@ -1,221 +1,138 @@ --- title: join() function description: > - The `join()` function merges two input streams into a single output stream - based on columns with equal values. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/join - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/join/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/join/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/join/ + `join()` merges two streams of tables into a single output stream based on columns with equal values. + Null values are not considered equal when comparing column values. + The resulting schema is the union of the input schemas. + The resulting group key is the union of the input group keys. menu: flux_0_x_ref: name: join parent: universe -weight: 102 + identifier: universe/join +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/join/ - - /flux/v0.x/stdlib/universe/union/ introduced: 0.7.0 --- -The `join()` function merges two input streams into a single output stream -based on columns with equal values. + + +`join()` merges two streams of tables into a single output stream based on columns with equal values. Null values are not considered equal when comparing column values. The resulting schema is the union of the input schemas. The resulting group key is the union of the input group keys. -```js -join( - tables: {key1: table1, key2: table2}, - on: ["_time", "_field"], - method: "inner", -) -``` +#### Output data +The schema and group keys of the joined output output data is the union of +the input schemas and group keys. +Columns that exist in both input streams that are not part specified as +columns to join on are renamed using the pattern `_` to +prevent ambiguity in joined tables. -#### Output schema -The column schema of the output stream is the union of the input schemas. -It is also the same for the output group key. -Columns are renamed using the pattern `_
` to prevent ambiguity in joined tables. +### Join vs union +`join()` creates new rows based on common values in one or more specified columns. +Output rows also contain the differing values from each of the joined streams. +`union()` does not modify data in rows, but unions separate streams of tables +into a single stream of tables and groups rows of data based on existing group keys. -##### Example: -If you have two streams of data, **data_1** and **data_2**, with the following group keys: - -**data_1**: `[_time, _field]` -**data_2**: `[_time, _field]` - -And join them with: +##### Function type signature ```js -join(tables: {d1: data_1, d2: data_2}, on: ["_time"]) +(<-tables: A, ?method: string, ?on: [string]) => stream[B] where A: Record, B: Record ``` -The resulting group keys for all tables will be: `[_time, _field_d1, _field_d2]` - +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="record"} -({{< req >}}) -Map of two streams to join. +### tables -{{% note %}} -`join()` currently only supports two input streams. -{{% /note %}} +Record containing two input streams to join. + + + +### on -### on {data-type="array of strings"} -({{< req >}}) List of columns to join on. -### method {data-type="string"} -Join method to use to join. Default is `"inner"`. -###### Possible Values: -- `inner` - ## Examples -The following example uses [`generate.from()`](/flux/v0.x/stdlib/generate/from/) -to illustrate how `join()` transforms data. + +- [Join two streams of tables](#join-two-streams-of-tables) +- [Join data from separate data sources](#join-data-from-separate-data-sources) + +### Join two streams of tables ```js import "generate" -t1 = generate.from(count: 4, fn: (n) => n + 1, start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) - |> set(key: "tag", value: "foo") +t1 = + generate.from(count: 4, fn: (n) => n + 1, start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) + |> set(key: "tag", value: "foo") -t2 = generate.from(count: 4, fn: (n) => n * (-1), start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) - |> set(key: "tag", value: "foo") +t2 = + generate.from(count: 4, fn: (n) => n * (-1), start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) + |> set(key: "tag", value: "foo") join(tables: {t1: t1, t2: t2}, on: ["_time", "tag"]) ``` -#### Input data streams +{{< expand-wrapper >}} +{{% expand "View example output" %}} -{{< flex >}} -{{% flex-content %}} +#### Output data -##### t1 +| _time | _value_t1 | _value_t2 | tag | +| -------------------- | ---------- | ---------- | ---- | +| 2021-01-01T00:00:00Z | 1 | 0 | foo | +| 2021-01-02T00:00:00Z | 2 | -1 | foo | +| 2021-01-03T00:00:00Z | 3 | -2 | foo | +| 2021-01-04T00:00:00Z | 4 | -3 | foo | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 1 | -| 2021-01-02T00:00:00Z | foo | 2 | -| 2021-01-03T00:00:00Z | foo | 3 | -| 2021-01-04T00:00:00Z | foo | 4 | -{{% /flex-content %}} -{{% flex-content %}} -##### t2 - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 0 | -| 2021-01-02T00:00:00Z | foo | -1 | -| 2021-01-03T00:00:00Z | foo | -2 | -| 2021-01-04T00:00:00Z | foo | -3 | -{{% /flex-content %}} -{{< /flex >}} - -#### Output data stream - -| _time | tag | _value_t1 | _value_t2 | -| :------------------- | :-- | --------: | --------: | -| 2021-01-01T00:00:00Z | foo | 1 | 0 | -| 2021-01-02T00:00:00Z | foo | 2 | -1 | -| 2021-01-03T00:00:00Z | foo | 3 | -2 | -| 2021-01-04T00:00:00Z | foo | 4 | -3 | - - -### InfluxDB cross-measurement join -The following example shows how data in different InfluxDB measurements can be -joined with Flux. - -```js -data_1 = from(bucket: "example-bucket") - |> range(start: -15m) - |> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_system") - -data_2 = from(bucket: "example-bucket") - |> range(start: -15m) - |> filter(fn: (r) => r._measurement == "mem" and r._field == "used_percent") - -join(tables: {d1: data_1, d2: data_2}, on: ["_time", "host"]) -``` - -## join() versus union() -`join()` creates new rows based on common values in one or more specified columns. -Output rows also contain the differing values from each of the joined streams. -`union()` does not modify data in rows, but unifies separate streams of tables -into a single stream of tables and groups rows of data based on existing -[group keys](/flux/v0.x/get-started/data-model/#group-key). - -{{% expand "View join() vs union() example" %}} -Given two streams of tables, `t1` and `t2`, the results of `join()` and `union()` -are illustrated below: - -#### Input streams - -{{< flex >}} -{{% flex-content %}} - -##### t1 - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 1 | -| 2021-01-02T00:00:00Z | foo | 2 | -| 2021-01-03T00:00:00Z | foo | 3 | -| 2021-01-04T00:00:00Z | foo | 4 | -{{% /flex-content %}} -{{% flex-content %}} -##### t2 - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 0 | -| 2021-01-02T00:00:00Z | foo | -1 | -| 2021-01-03T00:00:00Z | foo | -2 | -| 2021-01-04T00:00:00Z | foo | -3 | -{{% /flex-content %}} -{{< /flex >}} - -#### join() output -```js -join(tables: {t1: t1, t2: t2}, on: ["_time", "tag"]) -``` - -| _time | tag | _value_t1 | _value_t2 | -| :------------------- | :-- | --------: | --------: | -| 2021-01-01T00:00:00Z | foo | 1 | 0 | -| 2021-01-02T00:00:00Z | foo | 2 | -1 | -| 2021-01-03T00:00:00Z | foo | 3 | -2 | -| 2021-01-04T00:00:00Z | foo | 4 | -3 | - -#### union() output -```js -union(tables: [t1, t2]) -``` - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 0 | -| 2021-01-02T00:00:00Z | foo | -1 | -| 2021-01-03T00:00:00Z | foo | -2 | -| 2021-01-04T00:00:00Z | foo | -3 | -| 2021-01-01T00:00:00Z | foo | 1 | -| 2021-01-02T00:00:00Z | foo | 2 | -| 2021-01-03T00:00:00Z | foo | 3 | -| 2021-01-04T00:00:00Z | foo | 4 | {{% /expand %}} +{{< /expand-wrapper >}} + +### Join data from separate data sources + +```js +import "sql" + +sqlData = + sql.from( + driverName: "postgres", + dataSourceName: "postgresql://username:password@localhost:5432", + query: "SELECT * FROM example_table", + ) + +tsData = + from(bucket: "example-bucket") + |> range(start: -1h) + |> filter(fn: (r) => r._measurement == "example-measurement") + |> filter(fn: (r) => exists r.sensorID) + +join(tables: {sql: sqlData, ts: tsData}, on: ["_time", "sensorID"]) +``` diff --git a/content/flux/v0.x/stdlib/universe/kaufmansama.md b/content/flux/v0.x/stdlib/universe/kaufmansama.md index 0b87fa895..1451a3605 100644 --- a/content/flux/v0.x/stdlib/universe/kaufmansama.md +++ b/content/flux/v0.x/stdlib/universe/kaufmansama.md @@ -1,55 +1,72 @@ --- title: kaufmansAMA() function description: > - The `kaufmansAMA()` function calculates the Kaufman's Adaptive Moving Average (KAMA) - using values in an input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/kaufmansama/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmansama/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/kaufmansama/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/kaufmansama/ + `kaufmansAMA()` calculates the Kaufman’s Adaptive Moving Average (KAMA) using + values in input tables. menu: flux_0_x_ref: name: kaufmansAMA parent: universe -weight: 102 + identifier: universe/kaufmansAMA +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/kaufmanser/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#kaufmans-adaptive-moving-average, InfluxQL KAUFMANS_ADAPTIVE_MOVING_AVERAGE() - - /flux/v0.x/stdlib/experimental/kaufmansama/ introduced: 0.40.0 --- -The `kaufmansAMA()` function calculates the Kaufman's Adaptive Moving Average (KAMA) -using values in an input table. + + +`kaufmansAMA()` calculates the Kaufman’s Adaptive Moving Average (KAMA) using +values in input tables. + +Kaufman’s Adaptive Moving Average is a trend-following indicator designed to +account for market noise or volatility. + +##### Function type signature ```js -kaufmansAMA( - n: 10, - column: "_value", -) +(<-tables: stream[A], n: int, ?column: string) => stream[B] where A: Record, B: Record ``` -Kaufman's Adaptive Moving Average is a trend-following indicator designed to account -for market noise or volatility. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n ({{< req >}}) -The period or number of points to use in the calculation. +Period or number of points to use in the calculation. + + + +### column + +Column to operate on. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + -### column {data-type="string"} -The column to operate on. -Defaults to `"_value"`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Caclulate Kaufman's Adaptive Moving Average for input data ```js import "sampledata" @@ -58,29 +75,43 @@ sampledata.int() |> kaufmansAMA(n: 3) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:30Z | t1 | 9.72641183951902 | -| 2021-01-01T00:00:40Z | t1 | 10.097401019601417 | -| 2021-01-01T00:00:50Z | t1 | 9.972614968115325 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | ------------------: | -| 2021-01-01T00:00:30Z | t2 | -2.9084287200832466 | -| 2021-01-01T00:00:40Z | t2 | -2.142970089472789 | -| 2021-01-01T00:00:50Z | t2 | -2.0940721758134693 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:30Z | 9.72641183951902 | t1 | +| 2021-01-01T00:00:40Z | 10.097401019601417 | t1 | +| 2021-01-01T00:00:50Z | 9.972614968115325 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:30Z | -2.9084287200832466 | t2 | +| 2021-01-01T00:00:40Z | -2.142970089472789 | t2 | +| 2021-01-01T00:00:50Z | -2.0940721758134693 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/kaufmanser.md b/content/flux/v0.x/stdlib/universe/kaufmanser.md index 80dcbe629..4b0406b33 100644 --- a/content/flux/v0.x/stdlib/universe/kaufmanser.md +++ b/content/flux/v0.x/stdlib/universe/kaufmanser.md @@ -1,49 +1,67 @@ --- title: kaufmansER() function description: > - The `kaufmansER()` function calculates the Kaufman's Efficiency Ratio (KER) using - values in an input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/kaufmanser/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmanser/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/kaufmanser/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/kaufmanser/ + `kaufmansER()` computes the Kaufman's Efficiency Ratio (KER) of values in the + `_value` column for each input table. menu: flux_0_x_ref: name: kaufmansER parent: universe -weight: 102 + identifier: universe/kaufmansER +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/kaufmansama/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#kaufmans-efficiency-ratio, InfluxQL KAUFMANS_EFFICIENCY_RATIO() introduced: 0.40.0 --- -The `kaufmansER()` function calculates the Kaufman's Efficiency Ratio (KER) using -values in an input table. -The function operates on the `_value` column. + + +`kaufmansER()` computes the Kaufman's Efficiency Ratio (KER) of values in the +`_value` column for each input table. + +Kaufman’s Efficiency Ratio indicator divides the absolute value of the Chande +Momentum Oscillator by 100 to return a value between 0 and 1. +Higher values represent a more efficient or trending market. + +##### Function type signature ```js -kaufmansER(n: 10) +(<-tables: stream[A], n: int) => stream[{B with _value: float, _value: float}] where A: Record ``` -Kaufman's Efficiency Ratio indicator divides the absolute value of the -Chande Momentum Oscillator by 100 to return a value between 0 and 1. -Higher values represent a more efficient or trending market. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n ({{< req >}}) -The period or number of points to use in the calculation. +Period or number of points to use in the calculation. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Compute the Kaufman's Efficiency Ratio ```js import "sampledata" @@ -52,29 +70,43 @@ sampledata.int() |> kaufmansER(n: 3) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | ------------------: | -| 2021-01-01T00:00:30Z | t1 | 0.76 | -| 2021-01-01T00:00:40Z | t1 | 0.33333333333333337 | -| 2021-01-01T00:00:50Z | t1 | 0.13043478260869565 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:30Z | t2 | 0.0 | -| 2021-01-01T00:00:40Z | t2 | 0.2571428571428572 | -| 2021-01-01T00:00:50Z | t2 | 0.1 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------- | ---- | +| 2021-01-01T00:00:30Z | 0.76 | t1 | +| 2021-01-01T00:00:40Z | 0.33333333333333337 | t1 | +| 2021-01-01T00:00:50Z | 0.13043478260869565 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:30Z | 0 | t2 | +| 2021-01-01T00:00:40Z | 0.2571428571428572 | t2 | +| 2021-01-01T00:00:50Z | 0.1 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/keep.md b/content/flux/v0.x/stdlib/universe/keep.md index 89274683a..002f1f112 100644 --- a/content/flux/v0.x/stdlib/universe/keep.md +++ b/content/flux/v0.x/stdlib/universe/keep.md @@ -1,60 +1,76 @@ --- title: keep() function -description: The `keep()` function returns a table containing only the specified columns. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/keep - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/keep/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keep/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/keep/ +description: > + `keep()` returns a stream of tables containing only the specified columns. menu: flux_0_x_ref: name: keep parent: universe -weight: 102 + identifier: universe/keep +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.7.0 --- -The `keep()` function returns a table containing only the specified columns, ignoring all others. -Only columns in the group key that are also specified in the `keep()` function will be kept in the resulting group key. -_It is the inverse of [`drop`](/flux/v0.x/stdlib/universe/drop)._ + + +`keep()` returns a stream of tables containing only the specified columns. + +Columns in the group key that are not specifed in the `columns` parameter or +identified by the `fn` parameter are removed from the group key and dropped +from output tables. `keep()` is the inverse of `drop()`. + +##### Function type signature ```js -keep(columns: ["col1", "col2"]) - -// OR - -keep(fn: (column) => column =~ /inodes*/) +(<-tables: stream[A], ?columns: [string], ?fn: (column: string) => bool) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -{{% note %}} -Make sure `fn` parameter names match each specified parameter. To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} +### columns -### columns {data-type="array of strings"} +Columns to keep in output tables. Cannot be used with `fn`. -Columns that should be included in the resulting table. -Cannot be used with `fn`. -### fn {data-type="function"} -A predicate function which takes a column name as a parameter (`column`) and returns -a boolean indicating whether or not the column should be included in the resulting table. -Cannot be used with `columns`. +### fn + +Predicate function that takes a column name as a parameter (column) and +returns a boolean indicating whether or not the column should be kept in +output tables. Cannot be used with `columns`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Keep a list of columns](#keep-a-list-of-columns) - [Keep columns matching a predicate](#keep-columns-matching-a-predicate) -#### Keep a list of columns +### Keep a list of columns ```js import "sampledata" @@ -64,38 +80,50 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T00:00:00Z | -2 | -| 2021-01-01T00:00:10Z | 10 | -| 2021-01-01T00:00:20Z | 7 | -| 2021-01-01T00:00:30Z | 17 | -| 2021-01-01T00:00:40Z | 15 | -| 2021-01-01T00:00:50Z | 4 | -| 2021-01-01T00:00:00Z | 19 | -| 2021-01-01T00:00:10Z | 4 | -| 2021-01-01T00:00:20Z | -3 | -| 2021-01-01T00:00:30Z | 19 | -| 2021-01-01T00:00:40Z | 13 | -| 2021-01-01T00:00:50Z | 1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | +| -------------------- | ------- | +| 2021-01-01T00:00:00Z | -2 | +| 2021-01-01T00:00:10Z | 10 | +| 2021-01-01T00:00:20Z | 7 | +| 2021-01-01T00:00:30Z | 17 | +| 2021-01-01T00:00:40Z | 15 | +| 2021-01-01T00:00:50Z | 4 | +| 2021-01-01T00:00:00Z | 19 | +| 2021-01-01T00:00:10Z | 4 | +| 2021-01-01T00:00:20Z | -3 | +| 2021-01-01T00:00:30Z | 19 | +| 2021-01-01T00:00:40Z | 13 | +| 2021-01-01T00:00:50Z | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Keep columns matching a predicate +### Keep columns matching a predicate ```js import "sampledata" @@ -105,36 +133,48 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | -| :------------------- | :-- | -| 2021-01-01T00:00:00Z | t1 | -| 2021-01-01T00:00:10Z | t1 | -| 2021-01-01T00:00:20Z | t1 | -| 2021-01-01T00:00:30Z | t1 | -| 2021-01-01T00:00:40Z | t1 | -| 2021-01-01T00:00:50Z | t1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | -| :------------------- | :-- | -| 2021-01-01T00:00:00Z | t2 | -| 2021-01-01T00:00:10Z | t2 | -| 2021-01-01T00:00:20Z | t2 | -| 2021-01-01T00:00:30Z | t2 | -| 2021-01-01T00:00:40Z | t2 | -| 2021-01-01T00:00:50Z | t2 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | *tag | +| -------------------- | ---- | +| 2021-01-01T00:00:00Z | t1 | +| 2021-01-01T00:00:10Z | t1 | +| 2021-01-01T00:00:20Z | t1 | +| 2021-01-01T00:00:30Z | t1 | +| 2021-01-01T00:00:40Z | t1 | +| 2021-01-01T00:00:50Z | t1 | + +| _time | *tag | +| -------------------- | ---- | +| 2021-01-01T00:00:00Z | t2 | +| 2021-01-01T00:00:10Z | t2 | +| 2021-01-01T00:00:20Z | t2 | +| 2021-01-01T00:00:30Z | t2 | +| 2021-01-01T00:00:40Z | t2 | +| 2021-01-01T00:00:50Z | t2 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/keys.md b/content/flux/v0.x/stdlib/universe/keys.md index e18a86223..693bccc96 100644 --- a/content/flux/v0.x/stdlib/universe/keys.md +++ b/content/flux/v0.x/stdlib/universe/keys.md @@ -1,131 +1,128 @@ --- title: keys() function description: > - The `keys()` function outputs the group key of input tables. - For each input table, it outputs a table with the same group key columns, plus a - _value column containing the labels of the input table's group key. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/keys - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/keys/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keys/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/keys/ + `keys()` returns the columns that are in the group key of each input table. menu: flux_0_x_ref: name: keys parent: universe -weight: 102 + identifier: universe/keys +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-measurements, InfluxQL – SHOW MEASUREMENTS - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-field-keys, InfluxQL – SHOW FIELD KEYS - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW TAG KEYS - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW SERIES introduced: 0.13.0 --- -The `keys()` function outputs the column keys in the [group key](/flux/v0.x/get-started/data-model/#group-key) of each input table. -For each input table, the function outputs a table with the same group key columns, -and a `_value` column containing the labels of the input table's group key. -Each row in an output table contains the group key value and the label of one column in the group key of the input table. -Each output table has the same number of rows as the size of the group key of the input table. + + +`keys()` returns the columns that are in the group key of each input table. + +Each output table contains a row for each group key column label. +A single group key column label is stored in the specified `column` for each row. +All columns not in the group key are dropped. + +##### Function type signature ```js -keys(column: "_value") +(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -Name of the output column in to store group key labels in. -Default is "_value"`. +### column + +Column to store group key labels in. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -The following examples use [`sample.data()`](/flux/v0.x/stdlib/influxdata/influxdb/sample/data/) -to simulate data queried from InfluxDB and illustrate how `keys()` transforms data. - [Return group key columns for each input table](#return-group-key-columns-for-each-input-table) - [Return all distinct group key columns in a single table](#return-all-distinct-group-key-columns-in-a-single-table) - [Return group key columns as an array](#return-group-key-columns-as-an-array) -#### Return group key columns for each input table +### Return group key columns for each input table + ```js -import "influxdata/influxdb/sample" - -data = sample.data(set: "airSensor") - |> range(start: -30m) - |> filter(fn: (r) => r.sensor_id == "TLM0100") - data |> keys() ``` {{< expand-wrapper >}} -{{% expand "View example input and output" %}} -##### Example input data +{{% expand "View example input and ouput" %}} -{{< flux/group-key "[_start, _stop, _field, _measurement, sensor_id]" >}} +#### Input data -| _start | _stop | _field | _measurement | sensor_id | _time | _value | -| :------------------- | :------------------- | :----- | :----------- | :-------- | :------------------- | ------------------: | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 0.31069912185103726 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 0.2958765656451926 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 0.3148598993377045 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 0.3138373097388317 | +| *_field | *_measurement | *sensorID | _time | _value | +| ------- | ------------- | --------- | -------------------- | ------- | +| co | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 0.31 | +| co | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 0.295 | +| co | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 0.314 | +| co | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 0.313 | -| _start | _stop | _field | _measurement | sensor_id | _time | _value | -| :------------------- | :------------------- | :------- | :----------- | :-------- | :------------------- | -----------------: | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 36.032121180773785 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 36.078174038253856 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 36.10019403559529 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 36.12069055726357 | +| *_field | *_measurement | *sensorID | _time | _value | +| -------- | ------------- | --------- | -------------------- | ------- | +| humidity | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 36.03 | +| humidity | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 36.07 | +| humidity | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 36.1 | +| humidity | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 36.12 | -| _start | _stop | _field | _measurement | sensor_id | _time | _value | -| :------------------- | :------------------- | :---------- | :----------- | :-------- | :------------------- | ----------------: | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 70.84122391403946 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 70.86036165985708 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 70.89253177998165 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 70.85193833073798 | +| *_field | *_measurement | *sensorID | _time | _value | +| ----------- | ------------- | --------- | -------------------- | ------- | +| temperature | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 70.84 | +| temperature | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 70.86 | +| temperature | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 70.89 | +| temperature | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 70.85 | -##### Example output data -| _start | _stop | _field | _measurement | sensor_id | _value | -| :------------------- | :------------------- | :----- | :----------- | :-------- | -----------: | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | _start | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | _stop | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | _field | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | _measurement | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | sensor_id | +#### Output data -| _start | _stop | _field | _measurement | sensor_id | _value | -| :------------------- | :------------------- | :------- | :----------- | :-------- | -----------: | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | _start | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | _stop | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | _field | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | _measurement | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | sensor_id | +| *_field | *_measurement | *sensorID | _value | +| ------- | ------------- | --------- | ------------ | +| co | airSensors | TLM0100 | _field | +| co | airSensors | TLM0100 | _measurement | +| co | airSensors | TLM0100 | sensorID | + +| *_field | *_measurement | *sensorID | _value | +| -------- | ------------- | --------- | ------------ | +| humidity | airSensors | TLM0100 | _field | +| humidity | airSensors | TLM0100 | _measurement | +| humidity | airSensors | TLM0100 | sensorID | + +| *_field | *_measurement | *sensorID | _value | +| ----------- | ------------- | --------- | ------------ | +| temperature | airSensors | TLM0100 | _field | +| temperature | airSensors | TLM0100 | _measurement | +| temperature | airSensors | TLM0100 | sensorID | -| _start | _stop | _field | _measurement | sensor_id | _value | -| :------------------- | :------------------- | :---------- | :----------- | :-------- | -----------: | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | _start | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | _stop | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | _field | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | _measurement | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | sensor_id | {{% /expand %}} {{< /expand-wrapper >}} -#### Return all distinct group key columns in a single table +### Return all distinct group key columns in a single table + ```js -import "influxdata/influxdb/sample" - -data = sample.data(set: "airSensor") - |> range(start: -30m) - |> filter(fn: (r) => r.sensor_id == "TLM0100") - data |> keys() |> keep(columns: ["_value"]) @@ -133,62 +130,54 @@ data ``` {{< expand-wrapper >}} -{{% expand "View example input and output" %}} -##### Example input data +{{% expand "View example input and ouput" %}} -{{< flux/group-key "[_start, _stop, _field, _measurement, sensor_id]" >}} +#### Input data -| _start | _stop | _field | _measurement | sensor_id | _time | _value | -| :------------------- | :------------------- | :----- | :----------- | :-------- | :------------------- | ------------------: | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 0.31069912185103726 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 0.2958765656451926 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 0.3148598993377045 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | co | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 0.3138373097388317 | +| *_field | *_measurement | *sensorID | _time | _value | +| ------- | ------------- | --------- | -------------------- | ------- | +| co | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 0.31 | +| co | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 0.295 | +| co | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 0.314 | +| co | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 0.313 | -| _start | _stop | _field | _measurement | sensor_id | _time | _value | -| :------------------- | :------------------- | :------- | :----------- | :-------- | :------------------- | -----------------: | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 36.032121180773785 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 36.078174038253856 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 36.10019403559529 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | humidity | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 36.12069055726357 | +| *_field | *_measurement | *sensorID | _time | _value | +| -------- | ------------- | --------- | -------------------- | ------- | +| humidity | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 36.03 | +| humidity | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 36.07 | +| humidity | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 36.1 | +| humidity | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 36.12 | -| _start | _stop | _field | _measurement | sensor_id | _time | _value | -| :------------------- | :------------------- | :---------- | :----------- | :-------- | :------------------- | ----------------: | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 70.84122391403946 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 70.86036165985708 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 70.89253177998165 | -| 2021-09-08T14:21:53Z | 2021-09-08T14:51:53Z | temperature | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 70.85193833073798 | +| *_field | *_measurement | *sensorID | _time | _value | +| ----------- | ------------- | --------- | -------------------- | ------- | +| temperature | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 70.84 | +| temperature | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 70.86 | +| temperature | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 70.89 | +| temperature | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 70.85 | -##### Example output data -| _value | -| -----------: | -| _start | -| _stop | -| _field | +#### Output data + +| _value | +| ------------ | +| _field | | _measurement | -| sensor_id | +| sensorID | {{% /expand %}} {{< /expand-wrapper >}} -#### Return group key columns as an array -To return group key columns as an array: +### Return group key columns as an array 1. Use `keys()` to replace the `_value` column with the group key labels. -2. Use [`findColumn()`](/flux/v0.x/stdlib/universe/findcolumn/) to return the - `_value` column as an array. +2. Use `findColumn()` to return the `_value` column as an array. ```js -import "influxdata/influxdb/sample" +import "sampledata" -data = sample.data(set: "airSensor") - |> range(start: -30m) - |> filter(fn: (r) => r.sensor_id == "TLM0100") - -data +sampledata.int() |> keys() - |> findColumn(fn: (key) => true, column: "_value") + |> findColumn(fn: (key) => true, column: "_value")// Returns [tag] -// Returns [_start, _stop, _field, _measurement, sensor_id] ``` + diff --git a/content/flux/v0.x/stdlib/universe/keyvalues.md b/content/flux/v0.x/stdlib/universe/keyvalues.md index c24698c2d..a59f08122 100644 --- a/content/flux/v0.x/stdlib/universe/keyvalues.md +++ b/content/flux/v0.x/stdlib/universe/keyvalues.md @@ -1,218 +1,117 @@ --- title: keyValues() function -description: The `keyValues()` function returns a table with the input table's group key plus two columns, _key and _value, that correspond to unique column + value pairs from the input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/keyvalues - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/keyvalues/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keyvalues/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/keyvalues/ +description: > + `keyValues()` returns a stream of tables with each input tables' group key and + two columns, _key and _value, that correspond to unique column label and value + pairs for each input table. menu: flux_0_x_ref: name: keyValues parent: universe -weight: 102 + identifier: universe/keyValues +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-measurements, InfluxQL – SHOW MEASUREMENTS - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-field-keys, InfluxQL – SHOW FIELD KEYS - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW TAG KEYS - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-values, InfluxQL – SHOW TAG VALUES - - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-serie, InfluxQL – SHOW SERIES introduced: 0.13.0 --- -The `keyValues()` function returns a table with the input table's group key plus two columns, -`_key` and `_value`, that correspond to unique column and value pairs for specific -columns in each input table. + + +`keyValues()` returns a stream of tables with each input tables' group key and +two columns, _key and _value, that correspond to unique column label and value +pairs for each input table. + + + +##### Function type signature ```js -keyValues(keyColumns: ["usage_idle", "usage_user"]) +(<-tables: stream[A], ?keyColumns: [string]) => stream[{B with _value: C, _key: string}] where A: Record, B: Record ``` - +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters - +### keyColumns -### keyColumns {data-type="array of strings"} +List of columns from which values are extracted. -A list of columns from which values are extracted. -All columns indicated must be of the same type. -Each input table must have all of the columns listed by the `keyColumns` parameter. +All columns must be of the same type. +Each input table must have all of the columns in the `keyColumns` parameter. - - -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -The following examples use [`sample.data()`](/flux/v0.x/stdlib/influxdata/influxdb/sample/data/) -to simulate data queried from InfluxDB and illustrate how `keys()` transforms data. -- [Get key values from explicitly defined columns](#get-key-values-from-explicitly-defined-columns) -- [Get key values from all group key columns](#get-key-values-from-all-group-key-columns) - -#### Get key values from explicitly defined columns +### Get key values from explicitly defined columns ```js -import "influxdata/influxdb/sample" - -data = sample.data(set: "airSensor") - |> filter(fn: (r) => r.sensor_id == "TLM0100") - data - |> keyValues(keyColumns: ["sensor_id", "_field"]) + |> keyValues(keyColumns: ["sensorID", "_field"]) ``` {{< expand-wrapper >}} -{{% expand "View example input and output" %}} -##### Example input data +{{% expand "View example input and ouput" %}} -{{< flux/group-key "[ _field, _measurement, sensor_id]" >}} +#### Input data -| _field | _measurement | sensor_id | _time | _value | -| :----- | :----------- | :-------- | :------------------- | ------------------: | -| co | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 0.31069912185103726 | -| co | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 0.2958765656451926 | -| co | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 0.3148598993377045 | -| co | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 0.3138373097388317 | +| *_field | *_measurement | *sensorID | _time | _value | +| ------- | ------------- | --------- | -------------------- | ------- | +| co | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 0.31 | +| co | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 0.295 | +| co | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 0.314 | +| co | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 0.313 | -| _field | _measurement | sensor_id | _time | _value | -| :------- | :----------- | :-------- | :------------------- | -----------------: | -| humidity | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 36.032121180773785 | -| humidity | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 36.078174038253856 | -| humidity | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 36.10019403559529 | -| humidity | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 36.12069055726357 | +| *_field | *_measurement | *sensorID | _time | _value | +| -------- | ------------- | --------- | -------------------- | ------- | +| humidity | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 36.03 | +| humidity | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 36.07 | +| humidity | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 36.1 | +| humidity | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 36.12 | -| _field | _measurement | sensor_id | _time | _value | -| :---------- | :----------- | :-------- | :------------------- | ----------------: | -| temperature | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 70.84122391403946 | -| temperature | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 70.86036165985708 | -| temperature | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 70.89253177998165 | -| temperature | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 70.85193833073798 | +| *_field | *_measurement | *sensorID | _time | _value | +| ----------- | ------------- | --------- | -------------------- | ------- | +| temperature | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 70.84 | +| temperature | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 70.86 | +| temperature | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 70.89 | +| temperature | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 70.85 | -##### Example output data -| _field | _measurement | sensor_id | _key | _value | -| :----- | :----------- | :-------- | :-------- | ------: | -| co | airSensors | TLM0100 | sensor_id | TLM0100 | -| co | airSensors | TLM0100 | _field | co | +#### Output data -| _field | _measurement | sensor_id | _key | _value | -| :------- | :----------- | :-------- | :-------- | -------: | -| humidity | airSensors | TLM0100 | sensor_id | TLM0100 | -| humidity | airSensors | TLM0100 | _field | humidity | +| *_field | *_measurement | *sensorID | _key | _value | +| ------- | ------------- | --------- | -------- | ------- | +| co | airSensors | TLM0100 | sensorID | TLM0100 | +| co | airSensors | TLM0100 | _field | co | + +| *_field | *_measurement | *sensorID | _key | _value | +| -------- | ------------- | --------- | -------- | -------- | +| humidity | airSensors | TLM0100 | sensorID | TLM0100 | +| humidity | airSensors | TLM0100 | _field | humidity | + +| *_field | *_measurement | *sensorID | _key | _value | +| ----------- | ------------- | --------- | -------- | ----------- | +| temperature | airSensors | TLM0100 | sensorID | TLM0100 | +| temperature | airSensors | TLM0100 | _field | temperature | -| _field | _measurement | sensor_id | _key | _value | -| :---------- | :----------- | :-------- | :-------- | ----------: | -| temperature | airSensors | TLM0100 | sensor_id | TLM0100 | -| temperature | airSensors | TLM0100 | _field | temperature | {{% /expand %}} {{< /expand-wrapper >}} - -#### Get key values from all group key columns - -1. Use [`keys()`](/flux/v0.x/stdlib/universe/keys/) and [`findColumn()`](/flux/v0.x/stdlib/universe/findcolumn/) - to extract an array of group key columns and store it as a variable. -2. Use `keyValues()` and provide the group key column array variable to the `keyColumns` parameter. - -```js -import "influxdata/influxdb/sample" - -data = sample.data(set: "airSensor") - |> filter(fn: (r) => r.sensor_id == "TLM0100") - -keyColumns = data - |> keys() - |> findColumn(fn: (key) => true, column: "_value") -// Returns [_field, _measurement, sensor_id] - -data - |> keyValues(keyColumns: keyColumns) -``` - -{{< expand-wrapper >}} -{{% expand "View example input and output" %}} -##### Example input data - -{{< flux/group-key "[ _field, _measurement, sensor_id]" >}} - -| _field | _measurement | sensor_id | _time | _value | -| :----- | :----------- | :-------- | :------------------- | ------------------: | -| co | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 0.31069912185103726 | -| co | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 0.2958765656451926 | -| co | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 0.3148598993377045 | -| co | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 0.3138373097388317 | - -| _field | _measurement | sensor_id | _time | _value | -| :------- | :----------- | :-------- | :------------------- | -----------------: | -| humidity | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 36.032121180773785 | -| humidity | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 36.078174038253856 | -| humidity | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 36.10019403559529 | -| humidity | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 36.12069055726357 | - -| _field | _measurement | sensor_id | _time | _value | -| :---------- | :----------- | :-------- | :------------------- | ----------------: | -| temperature | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 70.84122391403946 | -| temperature | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 70.86036165985708 | -| temperature | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 70.89253177998165 | -| temperature | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 70.85193833073798 | - -##### Example output data - -| _field | _measurement | sensor_id | _key | _value | -| :----- | :----------- | :-------- | :----------- | ---------: | -| co | airSensors | TLM0100 | _field | co | -| co | airSensors | TLM0100 | _measurement | airSensors | -| co | airSensors | TLM0100 | sensor_id | TLM0100 | - -| _field | _measurement | sensor_id | _key | _value | -| :------- | :----------- | :-------- | :----------- | ---------: | -| humidity | airSensors | TLM0100 | _field | humidity | -| humidity | airSensors | TLM0100 | _measurement | airSensors | -| humidity | airSensors | TLM0100 | sensor_id | TLM0100 | - -| _field | _measurement | sensor_id | _key | _value | -| :---------- | :----------- | :-------- | :----------- | ----------: | -| temperature | airSensors | TLM0100 | _field | temperature | -| temperature | airSensors | TLM0100 | _measurement | airSensors | -| temperature | airSensors | TLM0100 | sensor_id | TLM0100 | -{{% /expand %}} -{{< /expand-wrapper >}} - - diff --git a/content/flux/v0.x/stdlib/universe/last.md b/content/flux/v0.x/stdlib/universe/last.md index 3d3881a31..cca872ce3 100644 --- a/content/flux/v0.x/stdlib/universe/last.md +++ b/content/flux/v0.x/stdlib/universe/last.md @@ -1,49 +1,65 @@ --- title: last() function -description: The `last()` function selects the last non-null record from an input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/last - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/last/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/last/ +description: > + `last()` returns the last row with a non-null value from each input table. menu: flux_0_x_ref: name: last parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/first-last/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#last, InfluxQL – LAST() + identifier: universe/last +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `last()` function selects the last non-null record from an input table. -_`last()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`last()` returns the last row with a non-null value from each input table. + +**Note**: `last()` drops empty tables. + +##### Function type signature ```js -last(column: "_value") +(<-tables: stream[A], ?column: string) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`last()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -Column used to verify the existence of a value. -If this column is _null_ in the last record, `last()` returns the previous -record with a non-null value. -Default is `"_value"`. +### column + +Column to use to verify the existence of a value. +Default is `_value`. + +If this column is `null` in the last record, `last()` returns the previous +record with a non-null value. + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the last row from each input table ```js import "sampledata" @@ -52,25 +68,39 @@ sampledata.int() |> last() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t1 | 2021-01-01T00:00:50Z | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t2 | 2021-01-01T00:00:50Z | 1 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 1 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/length.md b/content/flux/v0.x/stdlib/universe/length.md index 42f77eb7d..710605f39 100644 --- a/content/flux/v0.x/stdlib/universe/length.md +++ b/content/flux/v0.x/stdlib/universe/length.md @@ -1,35 +1,62 @@ --- title: length() function -description: The `length()` function returns the number of items in an array. +description: > + `length()` returns the number of elements in an array. menu: flux_0_x_ref: name: length parent: universe -weight: 102 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/length/ - - /influxdb/cloud/reference/flux/stdlib/built-in/misc/length/ -related: - - /flux/v0.x/data-types/composite/array/ + identifier: universe/length +weight: 101 + introduced: 0.7.0 --- -The `length()` function returns the number of items in an array. + + +`length()` returns the number of elements in an array. + + + +##### Function type signature ```js -length(arr: []) +(<-arr: [A]) => int ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### arr {data-type="array"} -Array to evaluate. +### arr + +Array to evaluate. Default is the piped-forward array (`<-`). + + + ## Examples + +### Return the length of an array + ```js people = ["John", "Jane", "Abed"] -length(arr: people) +people |> length()// Returns 3 -// Returns 3 ``` + diff --git a/content/flux/v0.x/stdlib/universe/limit.md b/content/flux/v0.x/stdlib/universe/limit.md index 5579705ea..d8caa6ae0 100644 --- a/content/flux/v0.x/stdlib/universe/limit.md +++ b/content/flux/v0.x/stdlib/universe/limit.md @@ -1,55 +1,75 @@ --- title: limit() function -description: The `limit()` function limits each output table to the first `n` records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/limit - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/limit/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/limit/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/limit/ +description: > + `limit()` returns the first `n` rows after the specified `offset` from each input table. menu: flux_0_x_ref: name: limit parent: universe -weight: 102 + identifier: universe/limit +weight: 101 flux/v0.x/tags: [transformations, selectors] -related: - - /{{< latest "influxdb" >}}/query-data/flux/sort-limit/ - - /flux/v0.x/stdlib/universe/tail/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-limit-and-slimit-clauses, InfluxQL LIMIT introduced: 0.7.0 --- -The `limit()` function limits each output table to the first [`n`](#n) records. -The function produces one output table for each input table. -Each output table contains the first `n` records after the [`offset`](#offset). -If the input table has less than `offset + n` records, `limit()` outputs all records after the `offset`. -_`limit()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`limit()` returns the first `n` rows after the specified `offset` from each input table. + +If an input table has less than `offset + n` rows, `limit()` returns all rows +after the offset. + +##### Function type signature ```js -limit(n:10, offset: 0) +(<-tables: stream[A], n: int, ?offset: int) => stream[A] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### n {data-type="int"} +### n ({{< req >}}) -Maximum number of records to output. +Maximum number of rows to return. -### offset {data-type="int"} -Number of records to skip per table before limiting to `n`. + + +### offset + +Number of rows to skip per table before limiting to `n`. Default is `0`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro plural=true %}} - [Limit results to the first three rows in each table](#limit-results-to-the-first-three-rows-in-each-table) - [Limit results to the first three rows in each input table after the first two](#limit-results-to-the-first-three-rows-in-each-input-table-after-the-first-two) -#### Limit results to the first three rows in each table +### Limit results to the first three rows in each table + ```js import "sampledata" @@ -58,35 +78,48 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Limit results to the first three rows in each input table after the first two +### Limit results to the first three rows in each input table after the first two + ```js import "sampledata" @@ -94,31 +127,3 @@ sampledata.int() |> limit(n: 3, offset: 2) ``` -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/linearbins.md b/content/flux/v0.x/stdlib/universe/linearbins.md index 18f31984e..73135ed1b 100644 --- a/content/flux/v0.x/stdlib/universe/linearbins.md +++ b/content/flux/v0.x/stdlib/universe/linearbins.md @@ -1,52 +1,78 @@ --- title: linearBins() function -description: The `linearBins()` function generates a list of linearly separated floats. -aliases: - - /influxdb/v2.0/reference/flux/functions/misc/linearbins - - /influxdb/v2.0/reference/flux/functions/built-in/misc/linearbins/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/linearbins/ - - /influxdb/cloud/reference/flux/stdlib/built-in/misc/linearbins/ +description: > + `linearBins()` generates a list of linearly separated float values. menu: flux_0_x_ref: name: linearBins parent: universe -weight: 102 + identifier: universe/linearBins +weight: 101 + +introduced: 0.19.0 --- -The `linearBins()` function generates a list of linearly separated floats. -It is a helper function meant to generate bin bounds for the -[`histogram()` function](/flux/v0.x/stdlib/universe/histogram). + + +`linearBins()` generates a list of linearly separated float values. + +Use `linearBins()` to generate bin bounds for `histogram()`. + +##### Function type signature ```js -linearBins( - start: 0.0, - width: 5.0, - count: 20, - infinity: true, -) +(count: int, start: float, width: float, ?infinity: bool) => [float] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### start {data-type="float"} -The first value in the returned list. +### start +({{< req >}}) +First value to return in the list. + + + +### width +({{< req >}}) +Distance between subsequent values. + + + +### count +({{< req >}}) +Number of values to return. + + + +### infinity + +Include an infinite value at the end of the list. Default is `true`. -### width {data-type="float"} -The distance between subsequent bin values. -### count {data-type="int"} -The number of bins to create. -### infinity {data-type="bool"} -When `true`, adds an additional bin with a value of positive infinity. -Defaults to `true`. ## Examples -```js -linearBins(start: 0.0, width: 10.0, count: 10) +### Generate a list of linearly increasing values + +```js +linearBins(start: 0.0, width: 10.0, count: 10)// Returns [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, +Inf] -// Generated list: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, +Inf] ``` + diff --git a/content/flux/v0.x/stdlib/universe/logarithmicbins.md b/content/flux/v0.x/stdlib/universe/logarithmicbins.md index b22722ff4..a35523faa 100644 --- a/content/flux/v0.x/stdlib/universe/logarithmicbins.md +++ b/content/flux/v0.x/stdlib/universe/logarithmicbins.md @@ -1,51 +1,83 @@ --- title: logarithmicBins() function -description: The `logarithmicBins()` function generates a list of exponentially separated floats. -aliases: - - /influxdb/v2.0/reference/flux/functions/misc/logarithmicbins - - /influxdb/v2.0/reference/flux/functions/built-in/misc/logarithmicbins/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/logarithmicbins/ - - /influxdb/cloud/reference/flux/stdlib/built-in/misc/logarithmicbins/ +description: > + `logarithmicBins()` generates a list of exponentially separated float values. menu: flux_0_x_ref: name: logarithmicBins parent: universe -weight: 102 + identifier: universe/logarithmicBins +weight: 101 + +introduced: 0.19.0 --- -The `logarithmicBins()` function generates a list of exponentially separated floats. -It is a helper function meant to generate bin bounds for the -[`histogram()` function](/flux/v0.x/stdlib/universe/histogram). + + +`logarithmicBins()` generates a list of exponentially separated float values. + +Use `linearBins()` to generate bin bounds for `histogram()`. + +##### Function type signature ```js -logarithmicBins( - start:1.0, - factor: 2.0, - count: 10, - infinity: true, -) +(count: int, factor: float, start: float, ?infinity: bool) => [float] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### start {data-type="float"} -The first value in the returned bin list. +### start +({{< req >}}) +First value to return in the list. + + + +### factor +({{< req >}}) +Multiplier to apply to subsequent values. + + + +### count +({{< req >}}) +Number of values to return. + + + +### infinity + +Include an infinite value at the end of the list. Default is `true`. -### factor {data-type="float"} -The multiplier applied to each subsequent bin. -### count {data-type="int"} -The number of bins to create. -### infinity {data-type="bool"} -When `true`, adds an additional bin with a value of positive infinity. -Defaults to `true`. ## Examples -```js -logarithmicBins(start: 1.0, factor: 2.0, count: 10, infinity: true) -// Generated list: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, +Inf] +### Generate a list of exponentially increasing values + +```js +logarithmicBins( + start: 1.0, + factor: 2.0, + count: 10, + infinity: true, +)// Returns [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, +Inf] + ``` + diff --git a/content/flux/v0.x/stdlib/universe/lowestaverage.md b/content/flux/v0.x/stdlib/universe/lowestaverage.md index cfbd9d0ae..1d1093899 100644 --- a/content/flux/v0.x/stdlib/universe/lowestaverage.md +++ b/content/flux/v0.x/stdlib/universe/lowestaverage.md @@ -1,82 +1,114 @@ --- title: lowestAverage() function -description: The `lowestAverage()` function calculates the average of each table in the input stream returns the lowest `n` records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/lowestaverage - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/lowestaverage/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestaverage/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/lowestaverage/ +description: > + `lowestAverage()` calculates the average of each input table and returns the lowest + `n` averages. menu: flux_0_x_ref: name: lowestAverage parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] + identifier: universe/lowestAverage +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `lowestAverage()` function calculates the average of each table in the input stream returns the lowest `n` records. -The function outputs a single aggregated table containing `n` records. -_`lowestAverage()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`lowestAverage()` calculates the average of each input table and returns the lowest +`n` averages. + +**Note:** `lowestAverage()` drops empty tables. + +##### Function type signature ```js -lowestAverage( - n:10, - column: "_value", - groupColumns: [], -) +(<-tables: stream[A], n: int, ?column: string, ?groupColumns: [string]) => stream[B] where A: Record, B: Record ``` -{{% warn %}} -#### Empty tables -`lowestAverage()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n +({{< req >}}) Number of records to return. -### column {data-type="string"} -Column by which to sort. -Default is `"_value"`. -### groupColumns {data-type="array of strings"} -The columns on which to group before performing the aggregation. -Default is `[]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### column + +Column to evaluate. Default is `_value`. + + + +### groupColumns + +List of columns to group by. Default is `[]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} + +### Return the lowest table average from a stream of tables ```js import "sampledata" sampledata.int() - |> lowestAverage(n: 2, groupColumns: ["tag"]) + |> lowestAverage(n: 1, groupColumns: ["tag"]) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | ----------------: | -| t1 | 8.5 | -| t2 | 8.833333333333334 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| tag | _value | +| ---- | ------- | +| t1 | 8.5 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/lowestcurrent.md b/content/flux/v0.x/stdlib/universe/lowestcurrent.md index 4c34d5114..a67931637 100644 --- a/content/flux/v0.x/stdlib/universe/lowestcurrent.md +++ b/content/flux/v0.x/stdlib/universe/lowestcurrent.md @@ -1,82 +1,114 @@ --- title: lowestCurrent() function -description: The `lowestCurrent()` function selects the last record of each table in the input stream and returns the lowest `n` records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/lowestcurrent - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/lowestcurrent/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestcurrent/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/lowestcurrent/ +description: > + `lowestCurrent()` selects the last record from each input table and returns the + lowest `n` records. menu: flux_0_x_ref: name: lowestCurrent parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] + identifier: universe/lowestCurrent +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `lowestCurrent()` function selects the last record of each table in the input stream and returns the lowest `n` records. -The function outputs a single aggregated table containing `n` records. -_`lowestCurrent()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`lowestCurrent()` selects the last record from each input table and returns the +lowest `n` records. + +**Note:** `lowestCurrent()` drops empty tables. + +##### Function type signature ```js -lowestCurrent( - n:10, - column: "_value", - groupColumns: [], -) +(<-tables: stream[A], n: int, ?column: string, ?groupColumns: [string]) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`lowestCurrent()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n +({{< req >}}) Number of records to return. -### column {data-type="column"} -Column by which to sort. -Default is `"_value"`. -### groupColumns {data-type="array of strings"} -The columns on which to group before performing the aggregation. -Default is `[]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### column + +Column to evaluate. Default is `_value`. + + + +### groupColumns + +List of columns to group by. Default is `[]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} + +### Return the lowest current value from a stream of tables ```js import "sampledata" sampledata.int() - |> lowestCurrent(n: 2, groupColumns: ["tag"]) + |> lowestCurrent(n: 1, groupColumns: ["tag"]) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:50Z | t2 | 1 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:50Z | 1 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/lowestmin.md b/content/flux/v0.x/stdlib/universe/lowestmin.md index fdfbaa540..7e3bc899f 100644 --- a/content/flux/v0.x/stdlib/universe/lowestmin.md +++ b/content/flux/v0.x/stdlib/universe/lowestmin.md @@ -1,56 +1,77 @@ --- title: lowestMin() function -description: The `lowestMin()` function selects the minimum record from each table in the input stream and returns the lowest `n` records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/lowestmin - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/lowestmin/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestmin/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/lowestmin/ +description: > + `lowestMin()` selects the record with the lowest value in the specified `column` + from each input table and returns the bottom `n` records. menu: flux_0_x_ref: name: lowestMin parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] + identifier: universe/lowestMin +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `lowestMin()` function selects the minimum record from each table in the input stream and returns the lowest `n` records. -The function outputs a single aggregated table containing `n` records. -_`lowestMin()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`lowestMin()` selects the record with the lowest value in the specified `column` +from each input table and returns the bottom `n` records. + +**Note:** `lowestMin()` drops empty tables. + +##### Function type signature ```js -lowestMin( - n:10, - column: "_value", - groupColumns: [], -) +(<-tables: stream[A], n: int, ?column: string, ?groupColumns: [string]) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`lowestMin()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n +({{< req >}}) Number of records to return. -### column {data-type="string"} -Column by which to sort. -Default is `"_value"`. -### groupColumns {data-type="array of strings"} -The columns on which to group before performing the aggregation. -Default is `[]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### column + +Column to evaluate. Default is `_value`. + + + +### groupColumns + +List of columns to group by. Default is `[]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} + +### Return the lowest two values from a stream of tables ```js import "sampledata" @@ -60,23 +81,35 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:00Z | t1 | -2 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | -2 | t1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/map.md b/content/flux/v0.x/stdlib/universe/map.md index cdc390665..1fb654766 100644 --- a/content/flux/v0.x/stdlib/universe/map.md +++ b/content/flux/v0.x/stdlib/universe/map.md @@ -1,229 +1,38 @@ --- title: map() function -description: The `map()` function applies a function to each record in the input tables. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/map - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/map/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/map/ +description: > + `map()` iterates over and applies a function to input rows. menu: flux_0_x_ref: name: map parent: universe -weight: 102 + identifier: universe/map +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/conditional-logic/ - - /{{< latest "influxdb" >}}/query-data/flux/mathematic-operations/ - - /flux/v0.x/stdlib/contrib/jsternberg/rows/map/ introduced: 0.7.0 --- -The `map()` function applies a function to each record in the input tables. -The modified records are assigned to new tables based on the group key of the input table. -The output tables are the result of applying the map function to each record of the input tables. + -A single argument function to apply to each record. -The return value must be a record. +`map()` iterates over and applies a function to input rows. -{{% note %}} -Records evaluated in `fn` functions are represented by `r`, short for "record" or "row". -{{% /note %}} - -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). - -## Important notes - -#### Preserve columns - -By default, `map()` drops any columns that: - -1. Are not part of the input table's group key. -2. Are not explicitly mapped in the `map()` function. - -This often results in the `_time` column being dropped. -To preserve the `_time` column and other columns that do not meet the criteria above, -use the `with` operator to map values in the `r` record. -The `with` operator updates a column if it already exists, -creates a new column if it doesn't exist, and includes all existing columns in -the output table. - -```js -map(fn: (r) => ({ r with newColumn: r._value * 2 })) -``` - -## Examples -{{% flux/sample-example-intro plural=true %}} - -- [Square the value in each row](#square-the-value-in-each-row) -- [Create a new table with new columns](#create-a-new-table-with-new-columns) -- [Add new columns and preserve existing columns](#add-new-columns-and-preserve-existing-columns) - -#### Square the value in each row - -```js -import "sampledata" - -sampledata.int() - |> map(fn: (r) => ({ r with _value: r._value * r._value })) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | 4 | -| 2021-01-01T00:00:10Z | t1 | 100 | -| 2021-01-01T00:00:20Z | t1 | 49 | -| 2021-01-01T00:00:30Z | t1 | 289 | -| 2021-01-01T00:00:40Z | t1 | 225 | -| 2021-01-01T00:00:50Z | t1 | 16 | - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 361 | -| 2021-01-01T00:00:10Z | t2 | 16 | -| 2021-01-01T00:00:20Z | t2 | 9 | -| 2021-01-01T00:00:30Z | t2 | 361 | -| 2021-01-01T00:00:40Z | t2 | 169 | -| 2021-01-01T00:00:50Z | t2 | 1 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} - -#### Create a new table with new columns - -```js -import "sampledata" - -sampledata.int() - |> map( - fn: (r) => ({ - time: r._time, - source: r.tag, - alert: if r._value > 10 then true else false - }) - ) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| time | source | alert | -| :------------------- | :----- | ----: | -| 2021-01-01T00:00:00Z | t1 | false | -| 2021-01-01T00:00:10Z | t1 | false | -| 2021-01-01T00:00:20Z | t1 | false | -| 2021-01-01T00:00:30Z | t1 | true | -| 2021-01-01T00:00:40Z | t1 | true | -| 2021-01-01T00:00:50Z | t1 | false | -| 2021-01-01T00:00:00Z | t2 | true | -| 2021-01-01T00:00:10Z | t2 | false | -| 2021-01-01T00:00:20Z | t2 | false | -| 2021-01-01T00:00:30Z | t2 | true | -| 2021-01-01T00:00:40Z | t2 | true | -| 2021-01-01T00:00:50Z | t2 | false | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} - -#### Add new columns and preserve existing columns -Use the `with` operator on the `r` record to preserve columns not directly -operated on by the map operation. - -```js -import "sampledata" - -sampledata.int() - |> map( - fn: (r) => ({ - r with - server: "server-${r.tag}", - valueFloat: float(v: r._value) - }) - ) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| _time | tag | _value | server | valueFloat | -| :------------------- | :-- | -----: | :-------- | ---------: | -| 2021-01-01T00:00:00Z | t1 | -2 | server-t1 | -2.0 | -| 2021-01-01T00:00:10Z | t1 | 10 | server-t1 | 10.0 | -| 2021-01-01T00:00:20Z | t1 | 7 | server-t1 | 7.0 | -| 2021-01-01T00:00:30Z | t1 | 17 | server-t1 | 17.0 | -| 2021-01-01T00:00:40Z | t1 | 15 | server-t1 | 15.0 | -| 2021-01-01T00:00:50Z | t1 | 4 | server-t1 | 4.0 | - -| _time | tag | _value | server | valueFloat | -| :------------------- | :-- | -----: | :-------- | ---------: | -| 2021-01-01T00:00:00Z | t2 | 19 | server-t2 | 19.0 | -| 2021-01-01T00:00:10Z | t2 | 4 | server-t2 | 4.0 | -| 2021-01-01T00:00:20Z | t2 | -3 | server-t2 | -3.0 | -| 2021-01-01T00:00:30Z | t2 | 19 | server-t2 | 19.0 | -| 2021-01-01T00:00:40Z | t2 | 13 | server-t2 | 13.0 | -| 2021-01-01T00:00:50Z | t2 | 1 | server-t2 | 1.0 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} - -## Troubleshooting - -### Map object property is not supported in a Flux table - -Flux tables only support the following value types: +Each input row is passed to the `fn` as a record, `r`. +Each `r` property represents a column key-value pair. +Output values must be of the following supported column types: - float - integer @@ -232,18 +41,227 @@ Flux tables only support the following value types: - boolean - time -If `map()` returns a record with an unsupported type, Flux returns an error with -the name of the column that attempted to use the unsupported type. +### Output data +Output tables are the result of applying the map function (`fn`) to each +record of the input tables. Output records are assigned to new tables based +on the group key of the input stream. +If the output record contains a different value for a group key column, the +record is regrouped into the appropriate table. +If the output record drops a group key column, that column is removed from +the group key. -If mapping a **duration** value, use [`time()`](/flux/v0.x/stdlib/universe/time/) -to convert it to a time value or [`int()`](/flux/v0.x/stdlib/universe/int/) -to convert it to an integer. -For the **bytes** type, use [`string()`](/flux/v0.x/stdlib/universe/string/) to convert the value to a string. +#### Preserve columns +`map()` drops any columns that are not mapped explictly by column label or +implicitly using the `with` operator in the `fn` function. +The `with` operator updates a record property if it already exists, creates +a new record property if it doesn’t exist, and includes all existing +properties in the output record. -{{% note %}} -For information about supporting other data types in Flux tables, see the -following Github issues: +```no_run +data + |> map(fn: (r) => ({ r with newColumn: r._value * 2 })) +``` -- [Add support for duration column value](https://github.com/influxdata/flux/issues/1803) -- [Add support for bytes column value](https://github.com/influxdata/flux/issues/1804) -{{% /note %}} +##### Function type signature + +```js +(<-tables: stream[A], fn: (r: A) => B, ?mergeKey: bool) => stream[B] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### fn +({{< req >}}) +Single argument function to apply to each record. +The return value must be a record. + + + +### mergeKey + +_(Deprecated)_ Merge group keys of mapped records. Default is `false`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +- [Square the value in each row](#square-the-value-in-each-row) +- [Create a new table with new columns](#create-a-new-table-with-new-columns) +- [Add new columns and preserve existing columns](#add-new-columns-and-preserve-existing-columns) + +### Square the value in each row + +```js +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with _value: r._value * r._value})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 4 | t1 | +| 2021-01-01T00:00:10Z | 100 | t1 | +| 2021-01-01T00:00:20Z | 49 | t1 | +| 2021-01-01T00:00:30Z | 289 | t1 | +| 2021-01-01T00:00:40Z | 225 | t1 | +| 2021-01-01T00:00:50Z | 16 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 361 | t2 | +| 2021-01-01T00:00:10Z | 16 | t2 | +| 2021-01-01T00:00:20Z | 9 | t2 | +| 2021-01-01T00:00:30Z | 361 | t2 | +| 2021-01-01T00:00:40Z | 169 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Create a new table with new columns + +```js +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({time: r._time, source: r.tag, alert: if r._value > 10 then true else false})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| alert | source | time | +| ------ | ------- | -------------------- | +| false | t1 | 2021-01-01T00:00:00Z | +| false | t1 | 2021-01-01T00:00:10Z | +| false | t1 | 2021-01-01T00:00:20Z | +| true | t1 | 2021-01-01T00:00:30Z | +| true | t1 | 2021-01-01T00:00:40Z | +| false | t1 | 2021-01-01T00:00:50Z | +| true | t2 | 2021-01-01T00:00:00Z | +| false | t2 | 2021-01-01T00:00:10Z | +| false | t2 | 2021-01-01T00:00:20Z | +| true | t2 | 2021-01-01T00:00:30Z | +| true | t2 | 2021-01-01T00:00:40Z | +| false | t2 | 2021-01-01T00:00:50Z | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Add new columns and preserve existing columns + +Use the `with` operator on the `r` record to preserve columns not directly +operated on by the map operation. + +```js +import "sampledata" + +sampledata.int() + |> map(fn: (r) => ({r with server: "server-${r.tag}", valueFloat: float(v: r._value)})) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | server | *tag | valueFloat | +| -------------------- | ------- | --------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | -2 | server-t1 | t1 | -2 | +| 2021-01-01T00:00:10Z | 10 | server-t1 | t1 | 10 | +| 2021-01-01T00:00:20Z | 7 | server-t1 | t1 | 7 | +| 2021-01-01T00:00:30Z | 17 | server-t1 | t1 | 17 | +| 2021-01-01T00:00:40Z | 15 | server-t1 | t1 | 15 | +| 2021-01-01T00:00:50Z | 4 | server-t1 | t1 | 4 | + +| _time | _value | server | *tag | valueFloat | +| -------------------- | ------- | --------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | 19 | server-t2 | t2 | 19 | +| 2021-01-01T00:00:10Z | 4 | server-t2 | t2 | 4 | +| 2021-01-01T00:00:20Z | -3 | server-t2 | t2 | -3 | +| 2021-01-01T00:00:30Z | 19 | server-t2 | t2 | 19 | +| 2021-01-01T00:00:40Z | 13 | server-t2 | t2 | 13 | +| 2021-01-01T00:00:50Z | 1 | server-t2 | t2 | 1 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/max.md b/content/flux/v0.x/stdlib/universe/max.md index d8c994fe5..71d8dd547 100644 --- a/content/flux/v0.x/stdlib/universe/max.md +++ b/content/flux/v0.x/stdlib/universe/max.md @@ -1,46 +1,65 @@ --- title: max() function -description: The `max()` function selects record with the highest _value from the input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/max - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/max/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/max/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/max/ +description: > + `max()` returns the row with the maximum value in a specified column from each + input table. menu: flux_0_x_ref: name: max parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#max, InfluxQL – MAX() + identifier: universe/max +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `max()` function selects record with the highest `_value` from the input table. -_`max()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`max()` returns the row with the maximum value in a specified column from each +input table. + +**Note:** `max()` drops empty tables. + +##### Function type signature ```js -max(column: "_value") +(<-tables: stream[A], ?column: string) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`max()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -The column to use to calculate the maximum value. -Default is `"_value"`. +### column + +Column to return maximum values from. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the row with the maximum value ```js import "sampledata" @@ -49,25 +68,39 @@ sampledata.int() |> max() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:30Z | t1 | 17 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 17 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/mean.md b/content/flux/v0.x/stdlib/universe/mean.md index 9bd016886..17c68259d 100644 --- a/content/flux/v0.x/stdlib/universe/mean.md +++ b/content/flux/v0.x/stdlib/universe/mean.md @@ -1,44 +1,65 @@ --- title: mean() function -description: The `mean()` function computes the mean or average of non-null records in the input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/mean - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/mean/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mean/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/mean/ +description: > + `mean()` returns the average of non-null values in a specified column from each + input table. menu: flux_0_x_ref: name: mean parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#mean, InfluxQL – MEAN() - - /flux/v0.x/stdlib/experimental/mean/ + identifier: universe/mean +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `mean()` function computes the mean or average of non-null records in the input table. -_`mean()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`mean()` returns the average of non-null values in a specified column from each +input table. + + + +##### Function type signature ```js -mean(column: "_value") +(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -Column to use to compute the mean. -Default is `"_value"`. +### column + +Column to use to compute means. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the average of values in each input table ```js import "sampledata" @@ -47,25 +68,39 @@ sampledata.int() |> mean() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | 8.5 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | _value | -| :-- | ----------------: | -| t2 | 8.833333333333334 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 8.5 | + +| *tag | _value | +| ---- | ----------------- | +| t2 | 8.833333333333334 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/median.md b/content/flux/v0.x/stdlib/universe/median.md index 6387e5d3f..f20f78c42 100644 --- a/content/flux/v0.x/stdlib/universe/median.md +++ b/content/flux/v0.x/stdlib/universe/median.md @@ -1,92 +1,99 @@ --- title: median() function description: > - The `median()` function returns the median `_value` of an input table or all non-null records - in the input table with values that fall within the `0.5` quantile or 50th percentile. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/median - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/median/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/median/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/median/ + `median()` returns the median `_value` of an input table or all non-null records + in the input table with values that fall within the 0.5 quantile (50th percentile). menu: flux_0_x_ref: name: median parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, selectors, transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/median/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#median, InfluxQL – MEDIAN() + identifier: universe/median +weight: 101 +flux/v0.x/tags: [transformations, aggregates, selectors] introduced: 0.7.0 --- -The `median()` function is a special application of the [`quantile()` function](/flux/v0.x/stdlib/universe/quantile) -that returns the median `_value` of an input table or all non-null records in the input table -with values that fall within the `0.5` quantile (50th percentile) depending on the [method](#method) used. + + +`median()` returns the median `_value` of an input table or all non-null records +in the input table with values that fall within the 0.5 quantile (50th percentile). + +### Function behavior +`median()` acts as an aggregate or selector transformation depending on the +specified `method`. + +- **Aggregate**: When using the `estimate_tdigest` or `exact_mean` methods, + `median()` acts as an aggregate transformation and outputs the average of + non-null records with values that fall within the 0.5 quantile (50th percentile). +- **Selector**: When using the `exact_selector` method, `meidan()` acts as + a selector selector transformation and outputs the non-null record with the + value that represents the 0.5 quantile (50th percentile). + +##### Function type signature ```js -median( - column: "_value", - method: "estimate_tdigest", - compression: 0.0, -) +(<-tables: stream[A], ?column: string, ?compression: float, ?method: string) => stream[A] where A: Record ``` -When using the `estimate_tdigest` or `exact_mean` methods, it outputs non-null -records with values that fall within the `0.5` quantile. - -When using the `exact_selector` method, it outputs the non-null record with the -value that represents the `0.5` quantile. - -{{% note %}} -The `median()` function can only be used with float value types. -It is a special application of the [`quantile()` function](/flux/v0.x/stdlib/universe/quantile) -which uses an approximation implementation that requires floats. -You can convert your value column to a float column using the [`toFloat()` function](/flux/v0.x/stdlib/universe/tofloat). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -Column to use to compute the median. -Default is `"_value"`. +### column -### method {data-type="string"} -Computation method. -Default is `"estimate_tdigest"`. +Column to use to compute the median. Default is `_value`. -The available options are: -##### estimate_tdigest -An aggregate method that uses a [t-digest data structure](https://github.com/tdunning/t-digest) -to compute an accurate quantile estimate on large data sources. -##### exact_mean -An aggregate method that takes the average of the two points closest to the quantile value. +### method -##### exact_selector -A selector method that returns the data point for which at least `q` points are less than. +Computation method. Default is `estimate_tdigest`. + +**Avaialable methods**: +- **estimate_tdigest**: Aggregate method that uses a +[t-digest data structure](https://github.com/tdunning/t-digest) to +compute an accurate median estimate on large data sources. +- **exact_mean**: Aggregate method that takes the average of the two +points closest to the median value. +- **exact_selector**: Selector method that returns the row with the value +for which at least 50% of points are less than. + +### compression -### compression {data-type="float"} Number of centroids to use when compressing the dataset. -A larger number produces a more accurate result at the cost of increased memory requirements. -Default is `1000.0`. +Default is `0.0`. + +A larger number produces a more accurate result at the cost of increased +memory requirements. + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} -- [Median as an aggregate](#median-as-an-aggregate) -- [Median as a selector](#median-as-a-selector) +- [Use median as an aggregate transformation](#use-median-as-an-aggregate-transformation) +- [Use median as a selector transformation](#use-median-as-a-selector-transformation) + +### Use median as an aggregate transformation -#### Median as an aggregate ```js import "sampledata" @@ -95,31 +102,44 @@ sampledata.float() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | 9.135 | +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | -| tag | _value | -| :-- | -----: | -| t2 | 9.415 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 9.135 | + +| *tag | _value | +| ---- | ------- | +| t2 | 9.415 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Median as a selector +### Use median as a selector transformation + ```js import "sampledata" @@ -128,26 +148,38 @@ sampledata.float() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -##### Output data -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t1 | 2021-01-01T00:00:20Z | 7.35 | +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t2 | 2021-01-01T00:00:10Z | 4.97 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:20Z | t1 | 7.35 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:10Z | t2 | 4.97 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/min.md b/content/flux/v0.x/stdlib/universe/min.md index 93ac6495e..52c75e07b 100644 --- a/content/flux/v0.x/stdlib/universe/min.md +++ b/content/flux/v0.x/stdlib/universe/min.md @@ -1,46 +1,65 @@ --- title: min() function -description: The `min()` function selects record with the lowest _value from the input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/min - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/min/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/min/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/min/ +description: > + `min()` returns the row with the minimum value in a specified column from each + input table. menu: flux_0_x_ref: name: min parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#min, InfluxQL – MIN() + identifier: universe/min +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `min()` function selects record with the lowest `_value` from the input table. -_`min()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`min()` returns the row with the minimum value in a specified column from each +input table. + +**Note:** `min()` drops empty tables. + +##### Function type signature ```js -min(column: "_value") +(<-tables: stream[A], ?column: string) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`min()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -The column to use to calculate the minimum value. -Default is `"_value"`. +### column + +Column to return minimum values from. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the row with the minimum value ```js import "sampledata" @@ -49,25 +68,39 @@ sampledata.int() |> min() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t2 | -3 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | -3 | t2 | + {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/mode.md b/content/flux/v0.x/stdlib/universe/mode.md index c63db4e41..ae566f1c8 100644 --- a/content/flux/v0.x/stdlib/universe/mode.md +++ b/content/flux/v0.x/stdlib/universe/mode.md @@ -1,62 +1,68 @@ --- title: mode() function description: > - The `mode()` function computes the mode or value that occurs most often in a - specified column in the input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/mode/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mode/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/mode/ + `mode()` returns the non-null value or values that occur most often in a + specified column in each input table. menu: flux_0_x_ref: name: mode parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#mode, InfluxQL – MODE() - - /flux/v0.x/stdlib/experimental/mode/ + identifier: universe/mode +weight: 101 +flux/v0.x/tags: [transformtions, aggregates] introduced: 0.36.0 --- -The `mode()` function computes the mode or value that occurs most often in a -specified column in the input table. -_`mode()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`mode()` returns the non-null value or values that occur most often in a +specified column in each input table. + +If there are multiple modes, `mode()` returns all mode values in a sorted table. If there is no mode, `mode()` returns `null`. -{{% warn %}} -#### Empty tables -`mode()` drops empty tables. -{{% /warn %}} +**Note**: `mode()` drops empty tables. -##### Supported data types +##### Function type signature -- String -- Float -- Integer -- UInteger -- Boolean -- Time +```js +(<-tables: stream[A], ?column: string) => stream[{B with _value: C}] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -The column to use to compute the mode. -Default is `"_value"`. +### column + +Column to return the mode from. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the mode of each input table ```js import "sampledata" @@ -65,25 +71,39 @@ sampledata.int() |> mode() ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | _value | -| :-- | -----: | -| t2 | 19 | -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} \ No newline at end of file +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | | + +| *tag | _value | +| ---- | ------- | +| t2 | 19 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/movingaverage.md b/content/flux/v0.x/stdlib/universe/movingaverage.md index f4b3dbfd6..5273afbb5 100644 --- a/content/flux/v0.x/stdlib/universe/movingaverage.md +++ b/content/flux/v0.x/stdlib/universe/movingaverage.md @@ -1,59 +1,74 @@ --- title: movingAverage() function description: > - The `movingAverage()` function calculates the mean of values grouped into `n` number of points. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage/ - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/movingaverage/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/movingaverage/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/movingaverage/ + `movingAverage()` calculates the mean of non-null values using the current value + and `n - 1` previous values in the `_values` column. menu: flux_0_x_ref: name: movingAverage parent: universe -weight: 102 + identifier: universe/movingAverage +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/moving-average/ - - /flux/v0.x/stdlib/universe/timedmovingaverage/ - - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ - - /flux/v0.x/stdlib/universe/doubleema/ - - /flux/v0.x/stdlib/universe/tripleema/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE() introduced: 0.35.0 --- -The `movingAverage()` function calculates the mean of values in the `_values` column -grouped into `n` number of points. + + +`movingAverage()` calculates the mean of non-null values using the current value +and `n - 1` previous values in the `_values` column. + +### Moving average rules - The average over a period populated by `n` values is equal to their algebraic mean. - The average over a period populated by only `null` values is `null`. - Moving averages skip `null` values. -- If `n` is less than the number of records in a table, `movingAverage` returns - the average of the available values. +- If `n` is less than the number of records in a table, `movingAverage()` + returns the average of the available values. + +##### Function type signature + +```js +(<-tables: stream[{A with _value: B}], n: int) => stream[{A with _value: float}] where B: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n ({{< req >}}) -The number of points to average. +Number of values to average. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Calculate a three point moving average](#calculate-a-three-point-moving-average) - [Calculate a three point moving average with null values](#calculate-a-three-point-moving-average-with-null-values) -#### Calculate a three point moving average +### Calculate a three point moving average + ```js import "sampledata" @@ -61,38 +76,51 @@ sampledata.int() |> movingAverage(n: 3) ``` -{{% expand-wrapper %}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:20Z | t1 | 5.0 | -| 2021-01-01T00:00:30Z | t1 | 11.333333333333334 | -| 2021-01-01T00:00:40Z | t1 | 13.0 | -| 2021-01-01T00:00:50Z | t1 | 12.0 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:20Z | t2 | 6.666666666666667 | -| 2021-01-01T00:00:30Z | t2 | 6.666666666666667 | -| 2021-01-01T00:00:40Z | t2 | 9.666666666666666 | -| 2021-01-01T00:00:50Z | t2 | 11.0 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:20Z | 5 | t1 | +| 2021-01-01T00:00:30Z | 11.333333333333334 | t1 | +| 2021-01-01T00:00:40Z | 13 | t1 | +| 2021-01-01T00:00:50Z | 12 | t1 | + +| _time | _value | *tag | +| -------------------- | ----------------- | ---- | +| 2021-01-01T00:00:20Z | 6.666666666666667 | t2 | +| 2021-01-01T00:00:30Z | 6.666666666666667 | t2 | +| 2021-01-01T00:00:40Z | 9.666666666666666 | t2 | +| 2021-01-01T00:00:50Z | 11 | t2 | + {{% /expand %}} -{{% /expand-wrapper %}} +{{< /expand-wrapper >}} + +### Calculate a three point moving average with null values -#### Calculate a three point moving average with null values ```js import "sampledata" @@ -100,33 +128,45 @@ sampledata.int(includeNull: true) |> movingAverage(n: 3) ``` -{{% expand-wrapper %}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" true %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | | t1 | +| 2021-01-01T00:00:40Z | | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t1 | 2.5 | -| 2021-01-01T00:00:30Z | t1 | 7.0 | -| 2021-01-01T00:00:40Z | t1 | 7.0 | -| 2021-01-01T00:00:50Z | t1 | 4.0 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:20Z | t2 | 0.5 | -| 2021-01-01T00:00:30Z | t2 | 6.666666666666667 | -| 2021-01-01T00:00:40Z | t2 | 8.0 | -| 2021-01-01T00:00:50Z | t2 | 10.0 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 2.5 | t1 | +| 2021-01-01T00:00:30Z | 7 | t1 | +| 2021-01-01T00:00:40Z | 7 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ----------------- | ---- | +| 2021-01-01T00:00:20Z | 0.5 | t2 | +| 2021-01-01T00:00:30Z | 6.666666666666667 | t2 | +| 2021-01-01T00:00:40Z | 8 | t2 | +| 2021-01-01T00:00:50Z | 10 | t2 | + {{% /expand %}} -{{% /expand-wrapper %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/now.md b/content/flux/v0.x/stdlib/universe/now.md index cf05b8d3c..aba942b48 100644 --- a/content/flux/v0.x/stdlib/universe/now.md +++ b/content/flux/v0.x/stdlib/universe/now.md @@ -1,51 +1,66 @@ --- title: now() function -description: The `now()` function returns the current time (UTC). -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/misc/now/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/now/ - - /influxdb/cloud/reference/flux/stdlib/built-in/misc/now/ +description: > + `now()` is a function option that, by default, returns the current system time. menu: flux_0_x_ref: name: now parent: universe -weight: 102 -flux/v0.x/tags: [data/time] -related: - - /flux/v0.x/stdlib/universe/today/ - - /flux/v0.x/stdlib/system/time/ + identifier: universe/now +weight: 101 +flux/v0.x/tags: [date/time] introduced: 0.7.0 --- -The `now()` function returns the current time (UTC) or the time defined in the `now` option. + + +`now()` is a function option that, by default, returns the current system time. + +#### now() vs system.time() +`now()` returns the current system time (UTC). `now()` is cached at runtime, +so all executions of `now()` in a Flux script return the same time value. +`system.time()` returns the system time (UTC) at which `system.time()` is executed. +Each instance of `system.time()` in a Flux script returns a unique value. + +##### Function type signature ```js -now() +() => time ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + + ## Examples -##### Use the current UTC time as a query boundary +- [Use the current UTC time as a query boundary](#use-the-current-utc-time-as-a-query-boundary) +- [Define a custom now time](#define-a-custom-now-time) + +### Use the current UTC time as a query boundary + ```js data - |> range(start: -10h, stop: now()) + |> range(start: -10h, stop: now) ``` -##### Return the now option time + +### Define a custom now time + ```js -option now = () => 2020-01-01T00:00:00Z - -now() -// Returns 2020-01-01T00:00:00.000000000Z +option now = () => 2022-01-01T00:00:00Z ``` -{{% note %}} -#### now() vs system.time() -`now()` returns the current system time (UTC). -`now()` is cached at runtime, so all instances of `now()` in a Flux script -return the same value. - -[`system.time()`](/flux/v0.x/stdlib/system/time/) returns the system time (UTC) -at which `system.time()` is executed. -Each instance of `system.time()` in a Flux script returns a unique value. -{{% /note %}} diff --git a/content/flux/v0.x/stdlib/universe/pearsonr.md b/content/flux/v0.x/stdlib/universe/pearsonr.md index 542699fa6..e30744f6a 100644 --- a/content/flux/v0.x/stdlib/universe/pearsonr.md +++ b/content/flux/v0.x/stdlib/universe/pearsonr.md @@ -1,97 +1,93 @@ --- title: pearsonr() function -description: The `pearsonr()` function computes the Pearson R correlation coefficient between two streams by first joining the streams, then performing the covariance operation normalized to compute R. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/pearsonr - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/pearsonr/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/pearsonr/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/pearsonr/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/pearsonr/ +description: > + `pearsonr()` returns the covariance of two streams of tables normalized to the + Pearson R coefficient. menu: flux_0_x_ref: name: pearsonr parent: universe -weight: 102 -flux/v0.x/tags: [transformations] + identifier: universe/pearsonr +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `pearsonr()` function computes the Pearson R correlation coefficient between two streams -by first joining the streams, then performing the covariance operation normalized to compute R. + + +`pearsonr()` returns the covariance of two streams of tables normalized to the +Pearson R coefficient. + + + +##### Function type signature ```js -pearsonr(x: stream1, y: stream2, on: ["_time", "_field"]) +(on: [string], x: A, y: B) => stream[C] where C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### x {data-type="stream of tables"} -First input stream used in the operation. +### x +({{< req >}}) +First input stream. -### y {data-type="stream of tables"} -Second input stream used in the operation. -### on {data-type="array of strings"} + +### y +({{< req >}}) +Second input stream. + + + +### on +({{< req >}}) List of columns to join on. + + + ## Examples -The following example uses [`generate.from()`](/flux/v0.x/stdlib/generate/from/) -to generate sample data and show how `pearsonr()` transforms data. + +### Return the covariance between two streams of tables ```js import "generate" -stream1 = generate.from( - count: 5, - fn: (n) => n * n, - start: 2021-01-01T00:00:00Z, - stop: 2021-01-01T00:01:00Z, -) - |> toFloat() +stream1 = + generate.from(count: 5, fn: (n) => n * n, start: 2021-01-01T00:00:00Z, stop: 2021-01-01T00:01:00Z) + |> toFloat() -stream2 = generate.from( - count: 5, - fn: (n) => n * n * n / 2, - start: 2021-01-01T00:00:00Z, - stop: 2021-01-01T00:01:00Z, -) - |> toFloat() +stream2 = + generate.from(count: 5, fn: (n) => n * n * n / 2, start: 2021-01-01T00:00:00Z, stop: 2021-01-01T00:01:00Z) + |> toFloat() pearsonr(x: stream1, y: stream2, on: ["_time"]) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} - -#### Input data -{{< flex >}} -{{% flex-content %}} -##### stream1 -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T00:00:00Z | 0.0 | -| 2021-01-01T00:00:12Z | 1.0 | -| 2021-01-01T00:00:24Z | 4.0 | -| 2021-01-01T00:00:36Z | 9.0 | -| 2021-01-01T00:00:48Z | 16.0 | -{{% /flex-content %}} -{{% flex-content %}} -##### stream2 -| _time | _value | -| :------------------- | -----: | -| 2021-01-01T00:00:00Z | 0.0 | -| 2021-01-01T00:00:12Z | 0.0 | -| 2021-01-01T00:00:24Z | 4.0 | -| 2021-01-01T00:00:36Z | 13.0 | -| 2021-01-01T00:00:48Z | 32.0 | -{{% /flex-content %}} -{{< /flex >}} +{{% expand "View example output" %}} #### Output data -| _value | -| -----------------: | + +| _value | +| ------------------ | | 0.9856626734271221 | {{% /expand %}} diff --git a/content/flux/v0.x/stdlib/universe/pivot.md b/content/flux/v0.x/stdlib/universe/pivot.md index 68ee84331..ad3784734 100644 --- a/content/flux/v0.x/stdlib/universe/pivot.md +++ b/content/flux/v0.x/stdlib/universe/pivot.md @@ -1,72 +1,107 @@ --- title: pivot() function -description: The `pivot()` function collects values stored vertically (column-wise) in a table and aligns them horizontally (row-wise) into logical sets. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/pivot - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/pivot/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/pivot/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/pivot/ +description: > + `pivot()` collects unique values stored vertically (column-wise) and aligns them + horizontally (row-wise) into logical sets. menu: flux_0_x_ref: name: pivot parent: universe -weight: 102 + identifier: universe/pivot +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.7.0 --- -The `pivot()` function collects values stored vertically (column-wise) in a table -and aligns them horizontally (row-wise) into logical sets. + + +`pivot()` collects unique values stored vertically (column-wise) and aligns them +horizontally (row-wise) into logical sets. + +### Output data +The group key of the resulting table is the same as the input tables, +excluding columns found in the `columnKey` and `valueColumn` parameters. +These columns are not part of the resulting output table and are dropped from +the group key. + +Every input row should have a 1:1 mapping to a particular row and column +combination in the output table. Row and column combinations are determined +by the `rowKey` and `columnKey` parameters. In cases where more than one +value is identified for the same row and column pair, the last value encountered in the set of table rows is used as the result. The output is constructed as follows: - The set of columns for the new table is the `rowKey` unioned with the group key, but excluding the columns indicated by the `columnKey` and the `valueColumn`. -- A new column is added to the set of columns for each unique value identified - in the input by the `columnKey` parameter. -- The label of a new column is the concatenation of the values of `columnKey` using `_` as a separator. - If the value is `null`, `"null"` is used. -- A new row is created for each unique value identified in the input by the `rowKey` parameter. -- For each new row, values for group key columns stay the same, while values for new columns are - determined from the input tables by the value in `valueColumn` at the row identified by the - `rowKey` values and the new column's label. - If no value is found, the value is set to `null`. -- Any column that is not part of the group key or not specified in the `rowKey`, - `columnKey` and `valueColumn` parameters is dropped. +- A new column is added to the set of columns for each unique value + identified by the `columnKey` parameter. +- The label of a new column is the concatenation of the values of `columnKey` + using `_` as a separator. If the value is null, "null" is used. +- A new row is created for each unique value identified by the + `rowKey` parameter. +- For each new row, values for group key columns stay the same, while values + for new columns are determined from the input tables by the value in + `valueColumn` at the row identified by the `rowKey` values and the new + column’s label. If no value is found, the value is set to `null`. +- Any column that is not part of the group key or not specified in the + `rowKey`, `columnKey`, and `valueColumn` parameters is dropped. + +##### Function type signature + +```js +(<-tables: stream[A], columnKey: [string], rowKey: [string], valueColumn: string) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### rowKey {data-type="array of strings"} -List of columns used to uniquely identify a row for the output. +### rowKey +({{< req >}}) +Columns to use to uniquely identify an output row. + + + +### columnKey +({{< req >}}) +Columns to use to identify new output columns. + + + +### valueColumn +({{< req >}}) +Column to use to populate the value of pivoted `columnKey` columns. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -### columnKey {data-type="array of strings"} -List of columns used to pivot values onto each row identified by the rowKey. -### valueColumn {data-type="string"} -Column that contains the value to be moved around the pivot. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -- [Align fields within each measurement that have the same timestamp](#align-fields-within-each-measurement-that-have-the-same-timestamp) -- [Align fields and measurements that have the same timestamp ](#align-fields-and-measurements-that-have-the-same-timestamp ) -- [Align values for each tag](#align-values-for-each-tag) +- [Align fields into rows based on time](#align-fields-into-rows-based-on-time) +- [Associate values to tags by time](#associate-values-to-tags-by-time) -#### Align fields within each measurement that have the same timestamp +### Align fields into rows based on time ```js data @@ -74,80 +109,36 @@ data ``` {{< expand-wrapper >}} -{{% expand "View example input and output" %}} -##### Input data -| _time | _measurement | _field | _value | -| :------------------- | :----------: | :----: | :----: | -| 1970-01-01T00:00:01Z | m1 | f1 | 1.0 | -| 1970-01-01T00:00:01Z | m1 | f2 | 2.0 | -| 1970-01-01T00:00:01Z | m1 | f3 | | -| 1970-01-01T00:00:01Z | m1 | | 3.0 | -| 1970-01-01T00:00:02Z | m1 | f1 | 4.0 | -| 1970-01-01T00:00:02Z | m1 | f2 | 5.0 | -| | m1 | f2 | 6.0 | -| 1970-01-01T00:00:02Z | m1 | f3 | | -| 1970-01-01T00:00:03Z | m1 | f1 | | -| 1970-01-01T00:00:03Z | m1 | | 7.0 | -| 1970-01-01T00:00:04Z | m1 | f3 | 8.0 | +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | *_measurement | *_field | _value | +| -------------------- | ------------- | ------- | ------- | +| 1970-01-01T00:00:01Z | m1 | f1 | 1 | +| 1970-01-01T00:00:01Z | m1 | f2 | 2 | +| 1970-01-01T00:00:01Z | m1 | f3 | | +| 1970-01-01T00:00:02Z | m1 | f1 | 4 | +| 1970-01-01T00:00:02Z | m1 | f2 | 5 | +| 1970-01-01T00:00:02Z | m1 | f3 | 6 | +| 1970-01-01T00:00:03Z | m1 | f1 | | +| 1970-01-01T00:00:03Z | m1 | f2 | 7 | +| 1970-01-01T00:00:04Z | m1 | f3 | 8 | + + +#### Output data + +| _time | *_measurement | f1 | f2 | f3 | +| -------------------- | ------------- | --- | --- | --- | +| 1970-01-01T00:00:01Z | m1 | 1 | 2 | | +| 1970-01-01T00:00:02Z | m1 | 4 | 5 | 6 | +| 1970-01-01T00:00:03Z | m1 | | 7 | | +| 1970-01-01T00:00:04Z | m1 | | | 8 | -##### Output data -| _time | _measurement | f1 | f2 | f3 | null | -| :------------------- | :----------: | --: | --: | --: | ---: | -| 1970-01-01T00:00:01Z | m1 | 1.0 | 2.0 | | 3.0 | -| 1970-01-01T00:00:02Z | m1 | 4.0 | 5.0 | | | -| | m1 | | 6.0 | | | -| 1970-01-01T00:00:03Z | m1 | | | | 7.0 | -| 1970-01-01T00:00:04Z | m1 | | | 8.0 | | {{% /expand %}} {{< /expand-wrapper >}} -#### Align fields and measurements that have the same timestamp - -{{% note %}} -###### Note the effects of: -- Having _null_ values in some `columnKey` values. -- Having more values for the same `rowKey` and `columnKey` value - (the 11th row overrides the 10th, and so does the 15th with the 14th). -{{% /note %}} - -```js -data - |> pivot(rowKey: ["_time"], columnKey: ["_measurement", "_field"], valueColumn: "_value") -``` - -{{< expand-wrapper >}} -{{% expand "View example input and output" %}} -##### Input data -| _time | _measurement | _field | _value | -| :------------------- | :----------: | :----: | -----: | -| 1970-01-01T00:00:01Z | m1 | f1 | 1.0 | -| 1970-01-01T00:00:01Z | m1 | f2 | 2.0 | -| 1970-01-01T00:00:01Z | | f3 | 3.0 | -| 1970-01-01T00:00:01Z | | | 4.0 | -| 1970-01-01T00:00:02Z | m1 | f1 | 5.0 | -| 1970-01-01T00:00:02Z | m1 | f2 | 6.0 | -| 1970-01-01T00:00:02Z | m1 | f3 | 7.0 | -| 1970-01-01T00:00:02Z | | | 8.0 | -| | m1 | f3 | 9.0 | -| 1970-01-01T00:00:03Z | m1 | | 10.0 | -| 1970-01-01T00:00:03Z | m1 | | 11.0 | -| 1970-01-01T00:00:03Z | m1 | f3 | 12.0 | -| 1970-01-01T00:00:03Z | | | 13.0 | -| | m1 | | 14.0 | -| | m1 | | 15.0 | - -##### Output data -| _time | m1_f1 | m1_f2 | null_f3 | null_null | m1_f3 | m1_null | -| :------------------- | ----: | ----: | ------: | --------: | ----: | ------: | -| 1970-01-01T00:00:01Z | 1.0 | 2.0 | 3.0 | 4.0 | | | -| 1970-01-01T00:00:02Z | 5.0 | 6.0 | | 8.0 | 7.0 | | -| | | | | | 9.0 | 15.0 | -| 1970-01-01T00:00:03Z | | | | 13.0 | 12.0 | 11.0 | -{{% /expand %}} -{{< /expand-wrapper >}} - -#### Align values for each tag -{{% flux/sample-example-intro %}} +### Associate values to tags by time ```js import "sampledata" @@ -157,28 +148,39 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | t1 | t2 | -| :------------------- | --: | --: | -| 2021-01-01T00:00:00Z | -2 | 19 | -| 2021-01-01T00:00:10Z | 10 | 4 | -| 2021-01-01T00:00:20Z | 7 | -3 | -| 2021-01-01T00:00:30Z | 17 | 19 | -| 2021-01-01T00:00:40Z | 15 | 13 | -| 2021-01-01T00:00:50Z | 4 | 1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | t1 | t2 | +| -------------------- | --- | --- | +| 2021-01-01T00:00:00Z | -2 | 19 | +| 2021-01-01T00:00:10Z | 10 | 4 | +| 2021-01-01T00:00:20Z | 7 | -3 | +| 2021-01-01T00:00:30Z | 17 | 19 | +| 2021-01-01T00:00:40Z | 15 | 13 | +| 2021-01-01T00:00:50Z | 4 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} - diff --git a/content/flux/v0.x/stdlib/universe/quantile.md b/content/flux/v0.x/stdlib/universe/quantile.md index 1b7ddf75f..a730e90e9 100644 --- a/content/flux/v0.x/stdlib/universe/quantile.md +++ b/content/flux/v0.x/stdlib/universe/quantile.md @@ -1,124 +1,161 @@ --- title: quantile() function -description: The `quantile()` function outputs non-null records with values that fall within the specified quantile or the non-null record with the value that represents the specified quantile. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/percentile - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/percentile - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/quantile/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/quantile/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/quantile/ +description: > + `quantile()` returns rows from each input table with values that fall within a + specified quantile or returns the row with the value that represents the + specified quantile. menu: flux_0_x_ref: name: quantile parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, selectors, transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/percentile-quantile/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#percentile, InfluxQL – PERCENTILE() - - /flux/v0.x/stdlib/experimental/quantile/ + identifier: universe/quantile +weight: 101 +flux/v0.x/tags: [transformations, aggregates, selectors] introduced: 0.24.0 --- -The `quantile()` function returns records from an input table with `_value`s that fall within -a specified quantile or it returns the record with the `_value` that represents the specified quantile. -Which it returns depends on the [method](#method) used. + + +`quantile()` returns rows from each input table with values that fall within a +specified quantile or returns the row with the value that represents the +specified quantile. + `quantile()` supports columns with float values. -_`quantile()` behaves like an [aggregate function](/flux/v0.x/function-types/#aggregates) -or a [selector function](/flux/v0.x/function-types/#selectors) depending on -the [`method`](#method) used._ +### Function behavior +`quantile()` acts as an aggregate or selector transformation depending on the +specified `method`. + +- **Aggregate**: When using the `estimate_tdigest` or `exact_mean` methods, + `quantile()` acts as an aggregate transformation and outputs the average of + non-null records with values that fall within the specified quantile. +- **Selector**: When using the `exact_selector` method, `quantile()` acts as + a selector selector transformation and outputs the non-null record with the + value that represents the specified quantile. + +##### Function type signature ```js -quantile( - column: "_value", - q: 0.99, - method: "estimate_tdigest", - compression: 1000.0, -) +( + <-tables: stream[A], + q: float, + ?column: string, + ?compression: float, + ?method: string, +) => stream[A] where A: Record ``` -When using the `estimate_tdigest` or `exact_mean` methods, it outputs non-null -records with values that fall within the specified quantile. - -When using the `exact_selector` method, it outputs the non-null record with the -value that represents the specified quantile. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -Column to use to compute the quantile. -Default is `"_value"`. +### column -### q {data-type="float"} +Column to use to compute the quantile. Default is `_value`. + + + +### q ({{< req >}}) -Value between 0 and 1 indicating the desired quantile. +Quantile to compute. Must be between `0.0` and `1.0`. -### method {data-type="string"} -Computation method. -Default is `estimate_tdigest`. -The available options are: -##### estimate_tdigest -An aggregate method that uses a [t-digest data structure](https://github.com/tdunning/t-digest) -to compute an accurate quantile estimate on large data sources. +### method -##### exact_mean -An aggregate method that takes the average of the two points closest to the quantile value. +Computation method. Default is `estimate_tdigest`. -##### exact_selector -A selector method that returns the data point for which at least `q` points are less than. +**Avaialable methods**: +- **estimate_tdigest**: Aggregate method that uses a +[t-digest data structure](https://github.com/tdunning/t-digest) to +compute an accurate quantile estimate on large data sources. +- **exact_mean**: Aggregate method that takes the average of the two +points closest to the quantile value. +- **exact_selector**: Selector method that returns the row with the value +for which at least `q` points are less than. + +### compression -### compression {data-type="float"} Number of centroids to use when compressing the dataset. -A larger number produces a more accurate result at the cost of increased memory requirements. Default is `1000.0`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +A larger number produces a more accurate result at the cost of increased +memory requirements. + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro plural=true %}} - [Quantile as an aggregate](#quantile-as-an-aggregate) - [Quantile as a selector](#quantile-as-a-selector) -#### Quantile as an aggregate +### Quantile as an aggregate + ```js import "sampledata" sampledata.float() - |> quantile(q: 0.99, method: "estimate_tdigest", compression: 1000.0) + |> quantile(q: 0.99, method: "estimate_tdigest") ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | 17.53 | +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | -| tag | _value | -| :-- | -----: | -| t2 | 19.85 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 17.53 | + +| *tag | _value | +| ---- | ------- | +| t2 | 19.85 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Quantile as a selector +### Quantile as a selector + ```js import "sampledata" @@ -127,26 +164,38 @@ sampledata.float() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -##### Output data -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t1 | 2021-01-01T00:00:20Z | 7.35 | +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t2 | 2021-01-01T00:00:10Z | 4.97 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:20Z | t1 | 7.35 | + +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:10Z | t2 | 4.97 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/range.md b/content/flux/v0.x/stdlib/universe/range.md index c42c74545..cacfc683b 100644 --- a/content/flux/v0.x/stdlib/universe/range.md +++ b/content/flux/v0.x/stdlib/universe/range.md @@ -1,96 +1,104 @@ --- title: range() function -description: The `range()` function filters records based on time bounds. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/range - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/range/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/range/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/range/ +description: > + `range()` filters rows based on time bounds. menu: flux_0_x_ref: name: range parent: universe -weight: 102 + identifier: universe/range +weight: 101 flux/v0.x/tags: [transformations, filters] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-where-clause, InfluxQL – WHERE introduced: 0.7.0 --- -The `range()` function filters records based on time bounds. -Each input table's records are filtered to contain only records that exist within the time bounds. -Records with a `null` value for their time are filtered. -Each input table's group key value is modified to fit within the time bounds. -Tables where all records exists outside the time bounds are filtered entirely. + + +`range()` filters rows based on time bounds. + +Input data must have a `_time` column of type time. +Rows with a null value in the `_time` are filtered. +`range()` adds a `_start` column with the value of `start` and a `_stop` +column with the value of `stop`. +`_start` and `_stop` columns are added to the group key. +Each input table’s group key value is modified to fit within the time bounds. +Tables with all rows outside the time bounds are filtered entirely. + +##### Function type signature ```js -range(start: -15m, stop: now()) +(<-tables: stream[{C with _time: time}], start: A, ?stop: B) => stream[{C with _time: time, _stop: time, _start: time}] ``` -#### Behavior of start and stop times -Results include records with `_time` values greater than or equal to the specified `start` -time and less than the specified `stop` time. - -``` -start <= _time < stop -``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### start {data-type="duration, time, int"} -The earliest time to include in results. -Results **include** points that match the specified start time. +### start +({{< req >}}) +Earliest time to include in results. + +Results _include_ rows with `_time` values that match the specified start time. Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -### stop {data-type="duration, time, int"} -The latest time to include in results. -Results **exclude** points that match the specified stop time. +### stop + +Latest time to include in results. Default is `now()`. + +Results _exclude_ rows with `_time` values that match the specified start time. Use a relative duration, absolute time, or integer (Unix timestamp in seconds). For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. Durations are relative to `now()`. -Defaults to `now()`. -{{% note %}} -Time values in Flux must be in [RFC3339 format](/flux/v0.x/spec/types#timestamp-format). -{{% /note %}} +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -- [Time range relative to now](#time-range-relative-to-now) -- [Relative time range](#relative-time-range) -- [Absolute time range](#absolute-time-range) -- [Absolute time range with Unix timestamps](#absolute-time-range-with-unix-timestamps) +- [Query a time range relative to now](#query-a-time-range-relative-to-now) +- [Query an absolute time range](#query-an-absolute-time-range) +- [Query an absolute time range using Unix timestamps](#query-an-absolute-time-range-using-unix-timestamps) + +### Query a time range relative to now -#### Time range relative to now ```js from(bucket: "example-bucket") |> range(start: -12h) - // ... ``` -#### Relative time range + +### Query an absolute time range + ```js from(bucket: "example-bucket") - |> range(start: -12h, stop: -15m) - // ... + |> range(start: 2021-05-22T23:30:00Z, stop: 2021-05-23T00:00:00Z) ``` -#### Absolute time range + +### Query an absolute time range using Unix timestamps + ```js from(bucket: "example-bucket") - |> range(start: 2018-05-22T23:30:00Z, stop: 2018-05-23T00:00:00Z) - // ... + |> range(start: 1621726200000000000, stop: 1621728000000000000) ``` -#### Absolute time range with Unix timestamps -```js -from(bucket: "example-bucket") - |> range(start: 1527031800, stop: 1527033600) - // ... -``` diff --git a/content/flux/v0.x/stdlib/universe/reduce.md b/content/flux/v0.x/stdlib/universe/reduce.md index 26a5d1d2b..ab37d355f 100644 --- a/content/flux/v0.x/stdlib/universe/reduce.md +++ b/content/flux/v0.x/stdlib/universe/reduce.md @@ -1,183 +1,187 @@ --- title: reduce() function description: > - The `reduce()` function aggregates records in each table according to the reducer, - `fn`, providing a way to create custom table aggregations. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/reduce/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/reduce/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/reduce/ + `reduce()` aggregates rows in each input table using a reducer function (`fn`). menu: flux_0_x_ref: name: reduce parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/custom-functions/custom-aggregate/ - - /{{< latest "influxdb" >}}/query-data/flux/conditional-logic/ + identifier: universe/reduce +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.23.0 --- -The `reduce()` function aggregates records in each table according to the reducer, -`fn`, providing a way to create custom aggregations. -The output for each table is the group key of the table with columns corresponding -to each field in the reducer record. -_`reduce()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`reduce()` aggregates rows in each input table using a reducer function (`fn`). + +The output for each table is the group key of the table with columns +corresponding to each field in the reducer record. +If the reducer record contains a column with the same name as a group key column, +the group key column’s value is overwritten, and the outgoing group key is changed. +However, if two reduced tables write to the same destination group key, the +function returns an error. + +### Dropped columns +`reduce()` drops any columns that: + +- Are not part of the input table’s group key. +- Are not explicitly mapped in the `identity` record or the reducer function (`fn`). + +##### Function type signature ```js -reduce( - fn: (r, accumulator) => ({ sum: r._value + accumulator.sum }), - identity: {sum: 0.0}, -) +(<-tables: stream[B], fn: (accumulator: A, r: B) => A, identity: A) => stream[C] where A: Record, B: Record, C: Record ``` -If the reducer record contains a column with the same name as a group key column, -the group key column's value is overwritten, and the outgoing group key is changed. -However, if two reduced tables write to the same destination group key, the function will error. +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -{{% note %}} -Make sure `fn` parameter names match each specified parameter. To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} +### fn +({{< req >}}) +Reducer function to apply to each row record (`r`). -### fn {data-type="function"} -Function to apply to each record with a reducer record ([`identity`](#identity)). +The reducer function accepts two parameters: +- **r**: Record representing the current row. +- **accumulator**: Record returned from the reducer function's operation on +the previous row. -###### fn syntax -```js -// Pattern -fn: (r, accumulator) => ({ identityKey: r.column + accumulator.identityKey }) +### identity +({{< req >}}) +Record that defines the reducer record and provides initial values +for the reducer operation on the first row. -// Example -fn: (r, accumulator) => ({ sum: r._value + accumulator.sum }) -``` - -{{% note %}} -#### Matching output record keys and types -The output record from `fn` must have the same key names and value types as the [`identity`](#identity). -After operating on a record, the output record is given back to `fn` as the input accumulator. -If the output record keys and value types do not match the `identity` keys and value types, -it will return a type error. -{{% /note %}} - -#### r {data-type=record} -Record representing each row or record. - -#### accumulator {data-type=record} -Reducer record defined by [`identity`](#identity). - -### identity {data-type="record"} -Defines the reducer record and provides initial values to use when creating a reducer. May be used more than once in asynchronous processing use cases. -_The data type of values in the `identity` record determine the data type of output values._ +The data type of values in the identity record determine the data type of +output values. -###### identity record syntax -```js -// Pattern -identity: {identityKey1: value1, identityKey2: value2} +### tables -// Example -identity: {sum: 0.0, count: 0.0} -``` +Input data. Default is piped-forward data (`<-`). -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Important notes -#### Dropped columns -By default, `reduce()` drops any columns that: - -1. Are not part of the input table's [group key](/flux/v0.x/get-started/data-model/#group-key). -2. Are not explicitly mapped in the `reduce()` function. ## Examples -{{% flux/sample-example-intro plural=true %}} - [Compute the sum of the value column](#compute-the-sum-of-the-value-column) - [Compute the sum and count in a single reducer](#compute-the-sum-and-count-in-a-single-reducer) - [Compute the product of all values](#compute-the-product-of-all-values) - [Calculate the average of all values](#calculate-the-average-of-all-values) -#### Compute the sum of the value column +### Compute the sum of the value column + +```js +import "sampledata" + +sampledata.int() + |> reduce(fn: (r, accumulator) => ({sum: r._value + accumulator.sum}), identity: {sum: 0}) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | sum | +| ---- | ---- | +| t1 | 51 | + +| *tag | sum | +| ---- | ---- | +| t2 | 53 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Compute the sum and count in a single reducer + ```js import "sampledata" sampledata.int() |> reduce( - fn: (r, accumulator) => ({sum: r._value + accumulator.sum}), - identity: {sum: 0}, + fn: (r, accumulator) => ({sum: r._value + accumulator.sum, count: accumulator.count + 1}), + identity: {sum: 0, count: 0}, ) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | sum | -| :-- | --: | -| t1 | 51 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | sum | -| :-- | --: | -| t2 | 53 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | count | sum | +| ---- | ------ | ---- | +| t1 | 6 | 51 | + +| *tag | count | sum | +| ---- | ------ | ---- | +| t2 | 6 | 53 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Compute the sum and count in a single reducer -```js -import "sampledata" +### Compute the product of all values -sampledata.int() - |> reduce( - fn: (r, accumulator) => ({ - sum: r._value + accumulator.sum, - count: accumulator.count + 1, - }), - identity: {sum: 0, count: 0} - ) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| tag | count | sum | -| :-- | ----: | --: | -| t1 | 6 | 51 | - -| tag | count | sum | -| :-- | ----: | --: | -| t2 | 6 | 53 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} - -#### Compute the product of all values ```js import "sampledata" @@ -186,66 +190,92 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | prod | -| :-- | ------: | -| t1 | -142800 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | prod | -| :-- | -----: | -| t2 | -56316 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | prod | +| ---- | ------- | +| t1 | -142800 | + +| *tag | prod | +| ---- | ------ | +| t2 | -56316 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Calculate the average of all values +### Calculate the average of all values + ```js import "sampledata" sampledata.int() |> reduce( - fn: (r, accumulator) => ({ - count: accumulator.count + 1, - total: accumulator.total + r._value, - avg: float(v: (accumulator.total + r._value)) / float(v: accumulator.count + 1) - }), + fn: (r, accumulator) => + ({ + count: accumulator.count + 1, + total: accumulator.total + r._value, + avg: float(v: accumulator.total + r._value) / float(v: accumulator.count + 1), + }), identity: {count: 0, total: 0, avg: 0.0}, ) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | avg | count | total | -| :-- | --: | ----: | ----: | -| t1 | 8.5 | 6 | 51 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | avg | count | total | -| :-- | ----: | ----: | ----: | -| t2 | 8.834 | 6 | 53 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| *tag | avg | count | total | +| ---- | ---- | ------ | ------ | +| t1 | 8.5 | 6 | 51 | + +| *tag | avg | count | total | +| ---- | ----------------- | ------ | ------ | +| t2 | 8.833333333333334 | 6 | 53 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/relativestrengthindex.md b/content/flux/v0.x/stdlib/universe/relativestrengthindex.md index 33fbcfc1d..24cbbb824 100644 --- a/content/flux/v0.x/stdlib/universe/relativestrengthindex.md +++ b/content/flux/v0.x/stdlib/universe/relativestrengthindex.md @@ -1,38 +1,36 @@ --- title: relativeStrengthIndex() function description: > - The `relativeStrengthIndex()` function measures the relative speed and change of - values in an input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/relativestrengthindex/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/relativestrengthindex/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/relativestrengthindex/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/relativestrengthindex/ + `relativeStrengthIndex()` measures the relative speed and change of values in input tables. menu: flux_0_x_ref: name: relativeStrengthIndex parent: universe -weight: 102 + identifier: universe/relativeStrengthIndex +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/movingaverage/ - - /flux/v0.x/stdlib/universe/timedmovingaverage/ - - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#relative-strength-index, InfluxQL RELATIVE_STRENGTH_INDEX() introduced: 0.38.0 --- -The `relativeStrengthIndex()` function measures the relative speed and change of -values in an input table. + + +`relativeStrengthIndex()` measures the relative speed and change of values in input tables. + +### Relative strength index (RSI) rules - The general equation for calculating a relative strength index (RSI) is `RSI = 100 - (100 / (1 + (AVG GAIN / AVG LOSS)))`. - For the first value of the RSI, `AVG GAIN` and `AVG LOSS` are averages of the `n` period. @@ -41,28 +39,43 @@ relativeStrengthIndex( - `AVG LOSS` = `((PREVIOUS AVG LOSS) * (n - 1)) / n` - `relativeStrengthIndex()` ignores `null` values. -## Parameters - -### n {data-type="int"} -({{< req >}}) -The number of values to use to calculate the RSI. - -### columns {data-type="array of strings"} -Columns to operate on. -Default is `["_value"]`. - -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). - -## Output tables +### Output tables For each input table with `x` rows, `relativeStrengthIndex()` outputs a table with `x - n` rows. -## Examples -{{% flux/sample-example-intro %}} +##### Function type signature + +```js +(<-tables: stream[A], n: int, ?columns: [string]) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### n +({{< req >}}) +Number of values to use to calculate the RSI. + + + +### columns + +Columns to operate on. Default is `["_value"]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +### Calculate a three point relative strength index -#### Calculate a three point relative strength index ```js import "sampledata" @@ -71,29 +84,42 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:30Z | t1 | 84.375 | -| 2021-01-01T00:00:40Z | t1 | 73.97260273972603 | -| 2021-01-01T00:00:50Z | t1 | 36.672325976230894 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:30Z | 84.375 | t1 | +| 2021-01-01T00:00:40Z | 73.97260273972603 | t1 | +| 2021-01-01T00:00:50Z | 36.672325976230894 | t1 | + +| _time | _value | *tag | +| -------------------- | ----------------- | ---- | +| 2021-01-01T00:00:30Z | 70.27027027027026 | t2 | +| 2021-01-01T00:00:40Z | 59.42857142857142 | t2 | +| 2021-01-01T00:00:50Z | 40.625 | t2 | -| _time | tag | _value | -| :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:30Z | t2 | 70.27027027027026 | -| 2021-01-01T00:00:40Z | t2 | 59.42857142857142 | -| 2021-01-01T00:00:50Z | t2 | 40.625 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/rename.md b/content/flux/v0.x/stdlib/universe/rename.md index a25a56ae5..35eef0209 100644 --- a/content/flux/v0.x/stdlib/universe/rename.md +++ b/content/flux/v0.x/stdlib/universe/rename.md @@ -1,63 +1,73 @@ --- title: rename() function -description: The `rename()` function renames specified columns in a table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/rename - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/rename/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/rename/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/rename/ +description: > + `rename()` renames columns in a table. menu: flux_0_x_ref: name: rename parent: universe -weight: 102 + identifier: universe/rename +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.7.0 --- -The `rename()` function renames specified columns in a table. -If a column is renamed and is part of the group key, the column name in the group key will be updated. + + +`rename()` renames columns in a table. + +If a column in group key is renamed, the column name in the group key is updated. + +##### Function type signature ```js -rename(columns: {host: "server", facility: "datacenter"}) - -// OR - -rename(fn: (column) => "{column}_new") +(<-tables: stream[B], ?columns: A, ?fn: (column: string) => string) => stream[C] where A: Record, B: Record, C: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -{{% note %}} -Make sure `fn` parameter names match each specified parameter. To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} +### columns -### columns {data-type="record"} +Record that maps old column names to new column names. -A map of columns to rename and their corresponding new names. -Cannot be used with `fn`. -### fn {data-type="function"} -A function mapping between old and new column names. -Cannot be used with `columns`. +### fn + +Function that takes the current column name (`column`) and returns a +new column name. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} -- [Rename specific columns](#rename-specific-columns) -- [Rename all columns using a function](#rename-all-columns-using-a-function) +- [Map column names to new column names](#map-column-names-to-new-column-names) +- [Rename columns using a function](#rename-columns-using-a-function) -#### Rename specific columns +### Map column names to new column names ```js import "sampledata" @@ -67,41 +77,53 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | uid | val | -| :------------------- | :-- | --: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | val | *uid | +| -------------------- | ---- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | val | *uid | +| -------------------- | ---- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | uid | val | -| :------------------- | :-- | --: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} - -#### Rename all columns using a function +### Rename columns using a function ```js import "sampledata" @@ -111,35 +133,48 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time_new | tag_new | _value_new | -| :------------------- | :------ | ---------: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time_new | _value_new | *tag_new | +| -------------------- | ----------- | -------- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time_new | _value_new | *tag_new | +| -------------------- | ----------- | -------- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time_new | tag_new | _value_new | -| :------------------- | :------ | ---------: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/sample.md b/content/flux/v0.x/stdlib/universe/sample.md index 2e9b4bd51..c3561abc7 100644 --- a/content/flux/v0.x/stdlib/universe/sample.md +++ b/content/flux/v0.x/stdlib/universe/sample.md @@ -1,52 +1,76 @@ --- title: sample() function -description: The `sample()` function selects a subset of the records from the input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/sample - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/sample/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/sample/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/sample/ +description: > + `sample()` selects a subset of the rows from each input table. menu: flux_0_x_ref: name: sample parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#sample, InfluxQL – SAMPLE() + identifier: universe/sample +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `sample()` function selects a subset of the records from the input table. -_`sample()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`sample()` selects a subset of the rows from each input table. + +**Note:** `sample()` drops empty tables. + +##### Function type signature ```js -sample(n:5, pos: -1) +(<-tables: stream[A], n: int, ?column: string, ?pos: int) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`sample()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n ({{< req >}}) Sample every Nth element. -### pos {data-type="int"} -Position offset from the start of results where sampling begins. -`pos` must be less than `n`. -If `pos` is less than 0, a random offset is used. -Default is `-1` (random offset). -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + +### pos + +Position offset from the start of results where sampling begins. +Default is -1 (random offset). + +`pos` must be less than `n`. If pos is less than 0, a random offset is used. + +### column + +Column to operate on. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} + +### Sample every other result ```js import "sampledata" @@ -56,29 +80,42 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/set.md b/content/flux/v0.x/stdlib/universe/set.md index 2cfe24b27..72b4fb6f7 100644 --- a/content/flux/v0.x/stdlib/universe/set.md +++ b/content/flux/v0.x/stdlib/universe/set.md @@ -1,44 +1,71 @@ --- title: set() function -description: The `set()` function assigns a static value to each record in the input table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/set - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/set/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/set/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/set/ +description: > + `set()` assigns a static column value to each row in the input tables. menu: flux_0_x_ref: name: set parent: universe -weight: 102 + identifier: universe/set +weight: 101 flux/v0.x/tags: [transformations] introduced: 0.7.0 --- -The `set()` function assigns a static value to each record in the input table. -The key may modify an existing column or add a new column to the tables. -If the modified column is part of the group key, the output tables are regrouped as needed. + + +`set()` assigns a static column value to each row in the input tables. + +`set()` may modify an existing column or add a new column. +If the modified column is part of the group key, output tables are regrouped as needed. +`set()` can only set string values. + +##### Function type signature ```js -set(key: "myKey",value: "myValue") +(<-tables: stream[A], key: string, value: string) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### key {data-type="string"} +### key ({{< req >}}) -The label of the column to modify or set. +Label of the column to modify or set. -### value {data-type="string"} + + +### value ({{< req >}}) -The string value to set. +String value to set. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Set a column to a specific string value ```js import "sampledata" @@ -48,35 +75,48 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | host | -| :------------------- | :-- | -----: | :---- | -| 2021-01-01T00:00:00Z | t1 | -2 | prod1 | -| 2021-01-01T00:00:10Z | t1 | 10 | prod1 | -| 2021-01-01T00:00:20Z | t1 | 7 | prod1 | -| 2021-01-01T00:00:30Z | t1 | 17 | prod1 | -| 2021-01-01T00:00:40Z | t1 | 15 | prod1 | -| 2021-01-01T00:00:50Z | t1 | 4 | prod1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | host | +| -------------------- | ------- | ---- | ----- | +| 2021-01-01T00:00:00Z | -2 | t1 | prod1 | +| 2021-01-01T00:00:10Z | 10 | t1 | prod1 | +| 2021-01-01T00:00:20Z | 7 | t1 | prod1 | +| 2021-01-01T00:00:30Z | 17 | t1 | prod1 | +| 2021-01-01T00:00:40Z | 15 | t1 | prod1 | +| 2021-01-01T00:00:50Z | 4 | t1 | prod1 | + +| _time | _value | *tag | host | +| -------------------- | ------- | ---- | ----- | +| 2021-01-01T00:00:00Z | 19 | t2 | prod1 | +| 2021-01-01T00:00:10Z | 4 | t2 | prod1 | +| 2021-01-01T00:00:20Z | -3 | t2 | prod1 | +| 2021-01-01T00:00:30Z | 19 | t2 | prod1 | +| 2021-01-01T00:00:40Z | 13 | t2 | prod1 | +| 2021-01-01T00:00:50Z | 1 | t2 | prod1 | -| _time | tag | _value | host | -| :------------------- | :-- | -----: | :---- | -| 2021-01-01T00:00:00Z | t2 | 19 | prod1 | -| 2021-01-01T00:00:10Z | t2 | 4 | prod1 | -| 2021-01-01T00:00:20Z | t2 | -3 | prod1 | -| 2021-01-01T00:00:30Z | t2 | 19 | prod1 | -| 2021-01-01T00:00:40Z | t2 | 13 | prod1 | -| 2021-01-01T00:00:50Z | t2 | 1 | prod1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/skew.md b/content/flux/v0.x/stdlib/universe/skew.md index c6247f9a3..6024df625 100644 --- a/content/flux/v0.x/stdlib/universe/skew.md +++ b/content/flux/v0.x/stdlib/universe/skew.md @@ -1,43 +1,63 @@ --- title: skew() function -description: The `skew()` function outputs the skew of non-null records as a float. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/skew - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/skew/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/skew/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/skew/ +description: > + `skew()` returns the skew of non-null records in each input table as a float. menu: flux_0_x_ref: name: skew parent: universe -weight: 102 -related: - - /flux/v0.x/stdlib/experimental/skew/ -flux/v0.x/tags: [aggregates, transformations] + identifier: universe/skew +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `skew()` function outputs the skew of non-null records as a float. -_`skew()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`skew()` returns the skew of non-null records in each input table as a float. + + + +##### Function type signature ```js -skew(column: "_value") +(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -The column on which to operate. -Default is `"_value"`. +### column + +Column to operate on. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the skew of values ```js import "sampledata" @@ -47,25 +67,38 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | -------------------: | -| t1 | -0.22375476930534782 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | _value | +| ---- | -------------------- | +| t1 | -0.22375476930534782 | + +| *tag | _value | +| ---- | -------------------- | +| t2 | -0.01972080701262574 | -| tag | _value | -| :-- | -------------------: | -| t2 | -0.01972080701262574 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/sleep.md b/content/flux/v0.x/stdlib/universe/sleep.md deleted file mode 100644 index 0f94c3c42..000000000 --- a/content/flux/v0.x/stdlib/universe/sleep.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: sleep() function -description: The `sleep()` function delays execution by a specified duration. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/misc/sleep/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/sleep/ - - /influxdb/cloud/reference/flux/stdlib/built-in/misc/sleep/ -weight: 102 -introduced: 0.36.0 -removed: 0.123.0 ---- - -{{% warn %}} -The `sleep()` function was removed in **Flux 0.123.0**. -{{% /warn %}} - -The `sleep()` function delays execution by a specified duration. - -```js -sleep(v: x, duration: 10s) -``` - -## Parameters - -### v {data-type="stream of tables"} -Input tables. -`sleep()` accepts piped-forward data and passes it on unmodified after the -specified [duration](#duration). -If data is not piped-forward into `sleep()`, set `v` to specify a stream of tables. -The examples [below](#examples) illustrate how. - -### duration {data-type="duration"} -Length of time to delay execution. - -## Examples - -### Delay execution in a chained query -```js -from(bucket: "example-bucket") - |> range(start: -1h) - |> sleep(duration: 10s) -``` - -### Delay execution using a stream variable -```js -x = from(bucket: "example-bucket") - |> range(start: -1h) - -sleep(v: x, duration: 10s) -``` diff --git a/content/flux/v0.x/stdlib/universe/sort.md b/content/flux/v0.x/stdlib/universe/sort.md index c02402d2c..fe52f4d84 100644 --- a/content/flux/v0.x/stdlib/universe/sort.md +++ b/content/flux/v0.x/stdlib/universe/sort.md @@ -1,58 +1,76 @@ --- title: sort() function -description: The `sort()` function orders the records within each table. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/sort - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/sort/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/sort/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/sort/ +description: > + `sort()` orders rows in each intput table based on values in specified columns. menu: flux_0_x_ref: name: sort parent: universe -weight: 102 + identifier: universe/sort +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/sort-limit/ introduced: 0.7.0 --- -The `sort()` function orders the records within each table. + + +`sort()` orders rows in each intput table based on values in specified columns. + +#### Output data One output table is produced for each input table. -The output tables will have the same schema as their corresponding input tables. +Output tables have the same schema as their corresponding input tables. #### Sorting with null values -When sorting, `null` values will always be first. -When `desc: false`, nulls are less than every other value. -When `desc: true`, nulls are greater than every value. +When `desc: false`, null values are last in the sort order. +When `desc: true`, null values are first in the sort order. + +##### Function type signature ```js -sort(columns: ["_value"], desc: false) +(<-tables: stream[A], ?columns: [string], ?desc: bool) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### columns {data-type="array of strings"} -List of columns by which to sort. +### columns + +List of columns to sort by. Default is ["_value"]. + Sort precedence is determined by list order (left to right). -Default is `["_value"]`. -### desc {data-type="bool"} -Sort results in descending order. -Default is `false`. +### desc + +Sort results in descending order. Default is `false`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} -- [Sort values in ascending order](#sort-values-in-ascending-order) -- [Sort values in descending order](#sort-values-in-descending-order) -- [Sort by multiple columns](#sort-by-multiple-columns) +### Sort values in ascending order -#### Sort values in ascending order ```js import "sampledata" @@ -61,119 +79,48 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:50Z | t1 | 4 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:30Z | t1 | 17 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:50Z | t2 | 1 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:30Z | t2 | 19 | -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} - -#### Sort values in descending order -```js -import "sampledata" - -sampledata.int() - |> sort(desc: true) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:50Z | t1 | 4 | -| 2021-01-01T00:00:00Z | t1 | -2 | - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:50Z | t2 | 1 | -| 2021-01-01T00:00:20Z | t2 | -3 | -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} - -#### Sort by multiple columns -```js -import "sampledata" - -sampledata.int() - |> sort(columns: ["tag", "_value"]) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:50Z | t1 | 4 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:30Z | t1 | 17 | - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:50Z | t2 | 1 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:30Z | t2 | 19 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/spread.md b/content/flux/v0.x/stdlib/universe/spread.md index 777f3baad..28111b3fc 100644 --- a/content/flux/v0.x/stdlib/universe/spread.md +++ b/content/flux/v0.x/stdlib/universe/spread.md @@ -1,48 +1,65 @@ --- title: spread() function -description: The `spread()` function outputs the difference between the minimum and maximum values in a specified column. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/spread - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/spread/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/spread/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/spread/ +description: > + `spread()` returns the difference between the minimum and maximum values in a + specified column. menu: flux_0_x_ref: name: spread parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#spread, InfluxQL – SPREAD() - - /flux/v0.x/stdlib/experimental/spread + identifier: universe/spread +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `spread()` function outputs the difference between the minimum and maximum values in a specified column. -_`spread()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`spread()` returns the difference between the minimum and maximum values in a +specified column. + + + +##### Function type signature ```js -spread(column: "_value") +(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -The column on which to operate. -Default is `"_value"`. +### column + +Column to operate on. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the spread of values ```js import "sampledata" @@ -52,25 +69,38 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | 19 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | _value | +| ---- | ------- | +| t1 | 19 | + +| *tag | _value | +| ---- | ------- | +| t2 | 22 | -| tag | _value | -| :-- | -----: | -| t2 | 22 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/statecount.md b/content/flux/v0.x/stdlib/universe/statecount.md index 65f418cc1..97d58e661 100644 --- a/content/flux/v0.x/stdlib/universe/statecount.md +++ b/content/flux/v0.x/stdlib/universe/statecount.md @@ -1,97 +1,125 @@ --- title: stateCount() function -description: The `stateCount()` function computes the number of consecutive records in a given state. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/statecount - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/statecount/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/statecount/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/statecount/ +description: > + `stateCount()` returns the number of consecutive rows in a given state. menu: flux_0_x_ref: name: stateCount parent: universe -weight: 102 + identifier: universe/stateCount +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/monitor-states/ introduced: 0.7.0 --- -The `stateCount()` function computes the number of consecutive records in a given state. -The state is defined via the function `fn`. -For each consecutive point that evaluates as `true`, the state count is incremented. -When a point evaluates as `false`, the state count is reset. + + +`stateCount()` returns the number of consecutive rows in a given state. + +The state is defined by the `fn` predicate function. For each consecutive +record that evaluates to `true`, the state count is incremented. When a record +evaluates to `false`, the value is set to `-1` and the state count is reset. +If the record generates an error during evaluation, the point is discarded, +and does not affect the state count. The state count is added as an additional column to each record. +##### Function type signature + ```js -stateCount(fn: (r) => r._field == "state", column: "stateCount") +(<-tables: stream[A], fn: (r: A) => bool, ?column: string) => stream[B] where A: Record, B: Record ``` -_If the expression generates an error during evaluation, the point is discarded -and does not affect the state count._ +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -{{% note %}} -Make sure `fn` parameter names match each specified parameter. -To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} - -### fn {data-type="function"} +### fn ({{< req >}}) -A single argument function that evaluates true or false to identify the state of the record. -Records are passed to the function. -Those that evaluate to `true` increment the state count. -Those that evaluate to `false` reset the state count. +Predicate function that identifies the state of a record. + + + +### column + +Column to store the state count in. Default is `stateCount`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + -### column {data-type="string"} -Name of the column added to each record that contains the incremented state count. -Default is `stateCount`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Count the number rows in a specific state ```js import "sampledata" sampledata.int() - |> stateCount(fn: (r) => r._value > 10) + |> stateCount(fn: (r) => r._value < 10) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | stateCount | -| :------------------- | :-- | -----: | ---------: | -| 2021-01-01T00:00:00Z | t1 | -2 | -1 | -| 2021-01-01T00:00:10Z | t1 | 10 | -1 | -| 2021-01-01T00:00:20Z | t1 | 7 | -1 | -| 2021-01-01T00:00:30Z | t1 | 17 | 1 | -| 2021-01-01T00:00:40Z | t1 | 15 | 2 | -| 2021-01-01T00:00:50Z | t1 | 4 | -1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | stateCount | +| -------------------- | ------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | -2 | t1 | 1 | +| 2021-01-01T00:00:10Z | 10 | t1 | -1 | +| 2021-01-01T00:00:20Z | 7 | t1 | 1 | +| 2021-01-01T00:00:30Z | 17 | t1 | -1 | +| 2021-01-01T00:00:40Z | 15 | t1 | -1 | +| 2021-01-01T00:00:50Z | 4 | t1 | 1 | + +| _time | _value | *tag | stateCount | +| -------------------- | ------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | 19 | t2 | -1 | +| 2021-01-01T00:00:10Z | 4 | t2 | 1 | +| 2021-01-01T00:00:20Z | -3 | t2 | 2 | +| 2021-01-01T00:00:30Z | 19 | t2 | -1 | +| 2021-01-01T00:00:40Z | 13 | t2 | -1 | +| 2021-01-01T00:00:50Z | 1 | t2 | 1 | -| _time | tag | _value | stateCount | -| :------------------- | :-- | -----: | ---------: | -| 2021-01-01T00:00:00Z | t2 | 19 | 1 | -| 2021-01-01T00:00:10Z | t2 | 4 | -1 | -| 2021-01-01T00:00:20Z | t2 | -3 | -1 | -| 2021-01-01T00:00:30Z | t2 | 19 | 1 | -| 2021-01-01T00:00:40Z | t2 | 13 | 2 | -| 2021-01-01T00:00:50Z | t2 | 1 | -1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/stateduration.md b/content/flux/v0.x/stdlib/universe/stateduration.md index fa544e4e8..2624be5d8 100644 --- a/content/flux/v0.x/stdlib/universe/stateduration.md +++ b/content/flux/v0.x/stdlib/universe/stateduration.md @@ -1,23 +1,33 @@ --- title: stateDuration() function -description: The `stateDuration()` function computes the duration of a given state. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/stateduration - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/stateduration/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stateduration/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stateduration/ +description: > + `stateDuration()` returns the cumulative duration of a given state. menu: flux_0_x_ref: name: stateDuration parent: universe -weight: 102 + identifier: universe/stateDuration +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/monitor-states/ - - /flux/v0.x/stdlib/contrib/tomhollingworth/events/duration/ introduced: 0.7.0 --- + + `stateDuration()` returns the cumulative duration of a given state. The state is defined by the `fn` predicate function. For each consecutive @@ -30,85 +40,118 @@ and does not affect the state duration. The state duration is added as an additional column to each record. The duration is represented as an integer in the units specified. -{{% note %}} -As the first point in the given state has no previous point, its +**Note:** As the first point in the given state has no previous point, its state duration will be 0. -{{% /note %}} + +##### Function type signature ```js -stateDuration(fn: (r) => r._measurement == "state", column: "stateDuration", unit: 1s) +( + <-tables: stream[A], + fn: (r: A) => bool, + ?column: string, + ?timeColumn: string, + ?unit: duration, +) => stream[B] where A: Record, B: Record ``` -_If the expression generates an error during evaluation, the point is discarded, -and does not affect the state duration._ +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -{{% note %}} -Make sure `fn` parameter names match each specified parameter. To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} - -### fn {data-type="function"} +### fn ({{< req >}}) -A single argument function that evaluates true or false to identify the state of the record. -Records are passed to the function. -Those that evaluate to `true` increment the state duration. -Those that evaluate to `false` reset the state duration. +Predicate function that identifies the state of a record. -### column {data-type="string"} -Name of the column added to each record that contains the state duration. -Default is `stateDuration`. -### unit {data-type="duration"} -Unit of time to increment state duration with. -For example: `1s`, `1m`, `1h`, etc. -Default is one second (`1s`). +### column + +Column to store the state duration in. Default is `stateDuration`. + + + +### timeColumn + +Time column to use to calculate elapsed time between rows. +Default is `_time`. + + + +### unit + +Unit of time to use to increment state duration. Default is `1s` (seconds). + +**Example units:** +- 1ns (nanoseconds) +- 1us (microseconds) +- 1ms (milliseconds) +- 1s (seconds) +- 1m (minutes) +- 1h (hours) +- 1d (days) + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the time spent in a specified state ```js import "sampledata" sampledata.int() - |> stateDuration(fn: (r) => r._value > 10) + |> stateDuration(fn: (r) => r._value < 15) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | stateDuration | -| :------------------- | :-- | -----: | ------------: | -| 2021-01-01T00:00:00Z | t1 | -2 | -1 | -| 2021-01-01T00:00:10Z | t1 | 10 | -1 | -| 2021-01-01T00:00:20Z | t1 | 7 | -1 | -| 2021-01-01T00:00:30Z | t1 | 17 | 0 | -| 2021-01-01T00:00:40Z | t1 | 15 | 10 | -| 2021-01-01T00:00:50Z | t1 | 4 | -1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | stateDuration | +| -------------------- | ------- | ---- | -------------- | +| 2021-01-01T00:00:00Z | -2 | t1 | 0 | +| 2021-01-01T00:00:10Z | 10 | t1 | 10 | +| 2021-01-01T00:00:20Z | 7 | t1 | 20 | +| 2021-01-01T00:00:30Z | 17 | t1 | -1 | +| 2021-01-01T00:00:40Z | 15 | t1 | -1 | +| 2021-01-01T00:00:50Z | 4 | t1 | 0 | + +| _time | _value | *tag | stateDuration | +| -------------------- | ------- | ---- | -------------- | +| 2021-01-01T00:00:00Z | 19 | t2 | -1 | +| 2021-01-01T00:00:10Z | 4 | t2 | 0 | +| 2021-01-01T00:00:20Z | -3 | t2 | 10 | +| 2021-01-01T00:00:30Z | 19 | t2 | -1 | +| 2021-01-01T00:00:40Z | 13 | t2 | 0 | +| 2021-01-01T00:00:50Z | 1 | t2 | 10 | -| _time | tag | _value | stateDuration | -| :------------------- | :-- | -----: | ------------: | -| 2021-01-01T00:00:00Z | t2 | 19 | 0 | -| 2021-01-01T00:00:10Z | t2 | 4 | -1 | -| 2021-01-01T00:00:20Z | t2 | -3 | -1 | -| 2021-01-01T00:00:30Z | t2 | 19 | 0 | -| 2021-01-01T00:00:40Z | t2 | 13 | 10 | -| 2021-01-01T00:00:50Z | t2 | 1 | -1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/statetracking.md b/content/flux/v0.x/stdlib/universe/statetracking.md new file mode 100644 index 000000000..7778b0935 --- /dev/null +++ b/content/flux/v0.x/stdlib/universe/statetracking.md @@ -0,0 +1,263 @@ +--- +title: stateTracking() function +description: > + `stateTracking()` returns the cumulative count and duration of consecutive + rows that match a predicate function that defines a state. +menu: + flux_0_x_ref: + name: stateTracking + parent: universe + identifier: universe/stateTracking +weight: 101 +flux/v0.x/tags: [transformations] +introduced: 0.7.0 +--- + + + +`stateTracking()` returns the cumulative count and duration of consecutive +rows that match a predicate function that defines a state. + +To return the cumulative count of consecutive rows that match the predicate, +include the `countColumn` parameter. +To return the cumulative duration of consecutive rows that match the predicate, +include the `durationColumn` parameter. +Rows that do not match the predicate function `fn` return `-1` in the count +and duration columns. + +##### Function type signature + +```js +( + <-tables: stream[A], + fn: (r: A) => bool, + ?countColumn: string, + ?durationColumn: string, + ?durationUnit: duration, + ?timeColumn: string, +) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### fn +({{< req >}}) +Predicate function to determine state. + + + +### countColumn + +Column to store state count in. + +If not defined, `stateTracking()` does not return the state count. + +### durationColumn + +Column to store state duration in. + +If not defined, `stateTracking()` does not return the state duration. + +### durationUnit + +Unit of time to report state duration in. Default is `1s`. + + + +### timeColumn + +Column with time values used to calculate state duration. +Default is `_time`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +- [Return a cumulative state count](#return-a-cumulative-state-count) +- [Return a cumulative state duration in milliseconds](#return-a-cumulative-state-duration-in-milliseconds) +- [Return a cumulative state count and duration](#return-a-cumulative-state-count-and-duration) + +### Return a cumulative state count + +```js +data + |> stateTracking(fn: (r) => r.state == "crit", countColumn: "count") +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | state | *tag | +| -------------------- | ------- | ------ | ---- | +| 2021-01-01T00:00:00Z | -2 | ok | t1 | +| 2021-01-01T00:00:10Z | 10 | crit | t1 | +| 2021-01-01T00:00:20Z | 7 | crit | t1 | +| 2021-01-01T00:00:30Z | 17 | crit | t1 | +| 2021-01-01T00:00:40Z | 15 | crit | t1 | +| 2021-01-01T00:00:50Z | 4 | ok | t1 | + +| _time | _value | state | *tag | +| -------------------- | ------- | ------ | ---- | +| 2021-01-01T00:00:00Z | 19 | crit | t2 | +| 2021-01-01T00:00:10Z | 4 | ok | t2 | +| 2021-01-01T00:00:20Z | -3 | ok | t2 | +| 2021-01-01T00:00:30Z | 19 | crit | t2 | +| 2021-01-01T00:00:40Z | 13 | crit | t2 | +| 2021-01-01T00:00:50Z | 1 | ok | t2 | + + +#### Output data + +| _time | _value | state | *tag | count | +| -------------------- | ------- | ------ | ---- | ------ | +| 2021-01-01T00:00:00Z | -2 | ok | t1 | -1 | +| 2021-01-01T00:00:10Z | 10 | crit | t1 | 1 | +| 2021-01-01T00:00:20Z | 7 | crit | t1 | 2 | +| 2021-01-01T00:00:30Z | 17 | crit | t1 | 3 | +| 2021-01-01T00:00:40Z | 15 | crit | t1 | 4 | +| 2021-01-01T00:00:50Z | 4 | ok | t1 | -1 | + +| _time | _value | state | *tag | count | +| -------------------- | ------- | ------ | ---- | ------ | +| 2021-01-01T00:00:00Z | 19 | crit | t2 | 1 | +| 2021-01-01T00:00:10Z | 4 | ok | t2 | -1 | +| 2021-01-01T00:00:20Z | -3 | ok | t2 | -1 | +| 2021-01-01T00:00:30Z | 19 | crit | t2 | 1 | +| 2021-01-01T00:00:40Z | 13 | crit | t2 | 2 | +| 2021-01-01T00:00:50Z | 1 | ok | t2 | -1 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Return a cumulative state duration in milliseconds + +```js +data + |> stateTracking(fn: (r) => r.state == "crit", durationColumn: "duration", durationUnit: 1ms) +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | state | *tag | +| -------------------- | ------- | ------ | ---- | +| 2021-01-01T00:00:00Z | -2 | ok | t1 | +| 2021-01-01T00:00:10Z | 10 | crit | t1 | +| 2021-01-01T00:00:20Z | 7 | crit | t1 | +| 2021-01-01T00:00:30Z | 17 | crit | t1 | +| 2021-01-01T00:00:40Z | 15 | crit | t1 | +| 2021-01-01T00:00:50Z | 4 | ok | t1 | + +| _time | _value | state | *tag | +| -------------------- | ------- | ------ | ---- | +| 2021-01-01T00:00:00Z | 19 | crit | t2 | +| 2021-01-01T00:00:10Z | 4 | ok | t2 | +| 2021-01-01T00:00:20Z | -3 | ok | t2 | +| 2021-01-01T00:00:30Z | 19 | crit | t2 | +| 2021-01-01T00:00:40Z | 13 | crit | t2 | +| 2021-01-01T00:00:50Z | 1 | ok | t2 | + + +#### Output data + +| _time | _value | state | *tag | duration | +| -------------------- | ------- | ------ | ---- | --------- | +| 2021-01-01T00:00:00Z | -2 | ok | t1 | -1 | +| 2021-01-01T00:00:10Z | 10 | crit | t1 | 0 | +| 2021-01-01T00:00:20Z | 7 | crit | t1 | 10000 | +| 2021-01-01T00:00:30Z | 17 | crit | t1 | 20000 | +| 2021-01-01T00:00:40Z | 15 | crit | t1 | 30000 | +| 2021-01-01T00:00:50Z | 4 | ok | t1 | -1 | + +| _time | _value | state | *tag | duration | +| -------------------- | ------- | ------ | ---- | --------- | +| 2021-01-01T00:00:00Z | 19 | crit | t2 | 0 | +| 2021-01-01T00:00:10Z | 4 | ok | t2 | -1 | +| 2021-01-01T00:00:20Z | -3 | ok | t2 | -1 | +| 2021-01-01T00:00:30Z | 19 | crit | t2 | 0 | +| 2021-01-01T00:00:40Z | 13 | crit | t2 | 10000 | +| 2021-01-01T00:00:50Z | 1 | ok | t2 | -1 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Return a cumulative state count and duration + +```js +data + |> stateTracking(fn: (r) => r.state == "crit", countColumn: "count", durationColumn: "duration") +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | state | *tag | +| -------------------- | ------- | ------ | ---- | +| 2021-01-01T00:00:00Z | -2 | ok | t1 | +| 2021-01-01T00:00:10Z | 10 | crit | t1 | +| 2021-01-01T00:00:20Z | 7 | crit | t1 | +| 2021-01-01T00:00:30Z | 17 | crit | t1 | +| 2021-01-01T00:00:40Z | 15 | crit | t1 | +| 2021-01-01T00:00:50Z | 4 | ok | t1 | + +| _time | _value | state | *tag | +| -------------------- | ------- | ------ | ---- | +| 2021-01-01T00:00:00Z | 19 | crit | t2 | +| 2021-01-01T00:00:10Z | 4 | ok | t2 | +| 2021-01-01T00:00:20Z | -3 | ok | t2 | +| 2021-01-01T00:00:30Z | 19 | crit | t2 | +| 2021-01-01T00:00:40Z | 13 | crit | t2 | +| 2021-01-01T00:00:50Z | 1 | ok | t2 | + + +#### Output data + +| _time | _value | state | *tag | count | duration | +| -------------------- | ------- | ------ | ---- | ------ | --------- | +| 2021-01-01T00:00:00Z | -2 | ok | t1 | -1 | -1 | +| 2021-01-01T00:00:10Z | 10 | crit | t1 | 1 | 0 | +| 2021-01-01T00:00:20Z | 7 | crit | t1 | 2 | 10 | +| 2021-01-01T00:00:30Z | 17 | crit | t1 | 3 | 20 | +| 2021-01-01T00:00:40Z | 15 | crit | t1 | 4 | 30 | +| 2021-01-01T00:00:50Z | 4 | ok | t1 | -1 | -1 | + +| _time | _value | state | *tag | count | duration | +| -------------------- | ------- | ------ | ---- | ------ | --------- | +| 2021-01-01T00:00:00Z | 19 | crit | t2 | 1 | 0 | +| 2021-01-01T00:00:10Z | 4 | ok | t2 | -1 | -1 | +| 2021-01-01T00:00:20Z | -3 | ok | t2 | -1 | -1 | +| 2021-01-01T00:00:30Z | 19 | crit | t2 | 1 | 0 | +| 2021-01-01T00:00:40Z | 13 | crit | t2 | 2 | 10 | +| 2021-01-01T00:00:50Z | 1 | ok | t2 | -1 | -1 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/stddev.md b/content/flux/v0.x/stdlib/universe/stddev.md index 1c8df9fb9..5dffb8f8d 100644 --- a/content/flux/v0.x/stdlib/universe/stddev.md +++ b/content/flux/v0.x/stdlib/universe/stddev.md @@ -1,56 +1,74 @@ --- title: stddev() function -description: The `stddev()` function computes the standard deviation of non-null records in a specified column. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/stddev - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/stddev/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/stddev/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/stddev/ +description: > + `stddev()` returns the standard deviation of non-null values in a specified column. menu: flux_0_x_ref: name: stddev parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#stddev, InfluxQL – STDDEV() - - /flux/v0.x/stdlib/experimental/stddev/ + identifier: universe/stddev +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `stddev()` function computes the standard deviation of non-null records in a specified column. -_`stddev()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`stddev()` returns the standard deviation of non-null values in a specified column. + + + +##### Function type signature ```js -stddev(column: "_value", mode: "sample") +(<-tables: stream[A], ?column: string, ?mode: string) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -Column to operate on. -Default is `"_value"`. +### column + +Column to operate on. Default is `_value`. + + + +### mode -### mode {data-type="string"} Standard deviation mode or type of standard deviation to calculate. -Defaults to `"sample"`. +Default is `sample`. -The available options are: +**Availble modes:** +- **sample**: Calculate the sample standard deviation where the data is +considered part of a larger population. +- **population**: Calculate the population standard deviation where the +data is considered a population of its own. + +### tables + +Input data. Default is piped-forward data (`<-`). -##### sample -Calculates the sample standard deviation where the data is considered to be part of a larger population. -##### population -Calculates the population standard deviation where the data is considered a population of its own. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the standard deviation of values in each table ```js import "sampledata" @@ -60,25 +78,38 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | ----------------: | -| t1 | 7.063993204979744 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | _value | +| ---- | ----------------- | +| t1 | 7.063993204979744 | + +| *tag | _value | +| ---- | ----------------- | +| t2 | 9.474527252938094 | -| tag | _value | -| :-- | ----------------: | -| t2 | 9.474527252938094 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/string.md b/content/flux/v0.x/stdlib/universe/string.md index 7fa3466ec..c7f82e567 100644 --- a/content/flux/v0.x/stdlib/universe/string.md +++ b/content/flux/v0.x/stdlib/universe/string.md @@ -1,129 +1,130 @@ --- title: string() function -description: The `string()` function converts a single value to a string. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/string/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/string/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/string/ +description: > + `string()` converts a value to a string type. menu: flux_0_x_ref: name: string parent: universe -weight: 102 -related: - - /flux/v0.x/stdlib/universe/tostring/ + identifier: universe/string +weight: 101 flux/v0.x/tags: [type-conversions] introduced: 0.7.0 --- -The `string()` function converts a single value to a string. + + +`string()` converts a value to a string type. + + + +##### Function type signature ```js -string(v: 123456789) +(v: A) => string ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="bool, int, uint, float, duration, time, bytes"} +### v +({{< req >}}) Value to convert. + + + ## Examples -- [Convert a boolean to a string value](#convert-a-boolean-to-a-string-value) -- [Convert a duration to a string value](#convert-a-duration-to-a-string-value) -- [Convert a time to a string value](#convert-a-time-to-a-string-value) -- [Convert a float to a string value](#convert-a-float-to-a-string-value) -- [Convert all values in a column to string values](#convert-all-values-in-a-column-to-string-values) +- [Convert basic types to strings](#convert-basic-types-to-strings) +- [Convert all values in a column to strings](#convert-all-values-in-a-column-to-strings) + +### Convert basic types to strings -#### Convert a boolean to a string value ```js string(v: true) // Returns "true" -``` - -#### Convert a duration to a string value -```js string(v: 1m) // Returns "1m" -``` - -#### Convert a time to a string value -```js string(v: 2021-01-01T00:00:00Z) // Returns "2021-01-01T00:00:00Z" +string(v: 10.12)// Returns "10.12" + ``` -#### Convert a float to a string value -```js -string(v: 10.12) -// Returns "10.12" -``` +### Convert all values in a column to strings -#### Convert all values in a column to string values -If updating values in the `_value` column, use [`toString()`](/flux/v0.x/stdlib/universe/tostring/). -To update values in columns other than `_value`: - -1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows. -2. Use `string()` to update the value of a column. - -_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._ +If converting the `_value` column to string types, use `toString()`. +If converting columns other than `_value`, use `map()` to iterate over each +row and `string()` to covert a column value to a string type. ```js -import "sampledata" - -data = sampledata.int() - |> rename(columns: {_value: "foo"}) - data - |> map(fn: (r) => ({r with foo: string(v: r.foo)})) + |> map(fn: (r) => ({r with exampleCol: string(v: r.exampleCol)})) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -| tag | _time | foo _(int)_ | -| :-- | :------------------- | -------------------------------------------: | -| t1 | 2021-01-01T00:00:00Z | -2 | -| t1 | 2021-01-01T00:00:10Z | 10 | -| t1 | 2021-01-01T00:00:20Z | 7 | -| t1 | 2021-01-01T00:00:30Z | 17 | -| t1 | 2021-01-01T00:00:40Z | 15 | -| t1 | 2021-01-01T00:00:50Z | 4 | +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| tag | _time | foo _(int)_ | -| :-- | :------------------- | -------------------------------------------: | -| t2 | 2021-01-01T00:00:00Z | 19 | -| t2 | 2021-01-01T00:00:10Z | 4 | -| t2 | 2021-01-01T00:00:20Z | -3 | -| t2 | 2021-01-01T00:00:30Z | 19 | -| t2 | 2021-01-01T00:00:40Z | 13 | -| t2 | 2021-01-01T00:00:50Z | 1 | +#### Input data -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | tag | foo _(string)_ | -| :------------------- | :-- | ----------------------------------------------: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | *tag | exampleCol | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | + +| _time | *tag | exampleCol | +| -------------------- | ---- | ----------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | -2.18 | t1 | +| 2021-01-01T00:00:10Z | 10.92 | t1 | +| 2021-01-01T00:00:20Z | 7.35 | t1 | +| 2021-01-01T00:00:30Z | 17.53 | t1 | +| 2021-01-01T00:00:40Z | 15.23 | t1 | +| 2021-01-01T00:00:50Z | 4.43 | t1 | + +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | 19.85 | t2 | +| 2021-01-01T00:00:10Z | 4.97 | t2 | +| 2021-01-01T00:00:20Z | -3.75 | t2 | +| 2021-01-01T00:00:30Z | 19.77 | t2 | +| 2021-01-01T00:00:40Z | 13.86 | t2 | +| 2021-01-01T00:00:50Z | 1.86 | t2 | -| _time | tag | foo _(string)_ | -| :------------------- | :-- | ----------------------------------------------: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/sum.md b/content/flux/v0.x/stdlib/universe/sum.md index 2b8023c4a..6603e3d5b 100644 --- a/content/flux/v0.x/stdlib/universe/sum.md +++ b/content/flux/v0.x/stdlib/universe/sum.md @@ -1,70 +1,104 @@ --- title: sum() function -description: The `sum()` function computes the sum of non-null records in a specified column. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/sum - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/sum/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/sum/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/sum/ +description: > + `sum()` returns the sum of non-null values in a specified column. menu: flux_0_x_ref: name: sum parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, transformations] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#sum, InfluxQL – SUM() - - /flux/v0.x/stdlib/experimental/sum + identifier: universe/sum +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.7.0 --- -The `sum()` function computes the sum of non-null records in a specified column. -_`sum()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`sum()` returns the sum of non-null values in a specified column. + + + +##### Function type signature ```js -sum(column: "_value") +(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### column {data-type="string"} -The column on which to operate. -Default is `"_value"`. +### column + +Column to operate on. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return the sum of values in each table ```js import "sampledata" sampledata.int() - |> sum() + |> stddev() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _value | -| :-- | -----: | -| t1 | 51 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *tag | _value | +| ---- | ----------------- | +| t1 | 7.063993204979744 | + +| *tag | _value | +| ---- | ----------------- | +| t2 | 9.474527252938094 | -| tag | _value | -| :-- | -----: | -| t2 | 53 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/tablefind.md b/content/flux/v0.x/stdlib/universe/tablefind.md index 8ee6ba215..5fa9fab61 100644 --- a/content/flux/v0.x/stdlib/universe/tablefind.md +++ b/content/flux/v0.x/stdlib/universe/tablefind.md @@ -1,67 +1,75 @@ --- title: tableFind() function description: > - The `tableFind()` function extracts the first table in a stream of tables whose - group key values match a predicate. If no table is found, the function errors. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/ + `tableFind()` extracts the first table in a stream with group key values that + match a specified predicate. menu: flux_0_x_ref: name: tableFind parent: universe -weight: 102 + identifier: universe/tableFind +weight: 101 flux/v0.x/tags: [dynamic queries] -related: - - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ introduced: 0.29.0 --- -The `tableFind()` function extracts the first table in a stream of tables whose -group key values match a predicate. If no table is found, the function errors. + + +`tableFind()` extracts the first table in a stream with group key values that +match a specified predicate. + + + +##### Function type signature ```js -tableFind(fn: (key) => key._field == "fieldName") +(<-tables: stream[B], fn: (key: A) => bool) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -{{% note %}} -Make sure `fn` parameter names match each specified parameter. -To learn why, see [Match parameter names](/flux/v0.x/spec/data-model/#match-parameter-names). -{{% /note %}} +### fn +({{< req >}}) +Predicate function to evaluate input table group keys. -### fn {data-type="function"} +`tableFind()` returns the first table that resolves as `true`. +The predicate function requires a `key` argument that represents each input +table's group key as a record. -A predicate function for matching keys in a table's group key. -`tableFind` returns the first table that resolves as `true`. -Expects a `key` argument that represents a group key in the input stream. +### tables -##### Example fn function +Input data. Default is piped-forward data (`<-`). -```js -(key) => key._field == "fieldName" -``` -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). -## Example -{{% flux/sample-example-intro %}} + +## Examples + +### Extract a table from a stream of tables ```js import "sampledata" -t = sampledata.int() - |> tableFind(fn: (key) => key.tag == "t2") - -// t represents the first table in a stream whose group key +t = + sampledata.int() + |> tableFind(fn: (key) => key.tag == "t2")// t represents the first table in a stream whose group key // contains "tag" with a value of "t2". + ``` -{{% note %}} -You can use `t` from the example above as input for [`getColumn()`](/flux/v0.x/stdlib/universe/getcolumn/) -and [`getRecord()`](/flux/v0.x/stdlib/universe/getrecord/). -{{% /note %}} diff --git a/content/flux/v0.x/stdlib/universe/tail.md b/content/flux/v0.x/stdlib/universe/tail.md index a27622aa2..925b5cbe9 100644 --- a/content/flux/v0.x/stdlib/universe/tail.md +++ b/content/flux/v0.x/stdlib/universe/tail.md @@ -1,51 +1,77 @@ --- title: tail() function -description: The `tail()` function limits each output table to the last `n` records. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/tail/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/tail/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/tail/ +description: > + `tail()` limits each output table to the last `n` rows. menu: flux_0_x_ref: name: tail parent: universe -weight: 102 + identifier: universe/tail +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/limit/ introduced: 0.39.0 --- -The `tail()` function limits each output table to the last [`n`](#n) records. -The function produces one output table for each input table. -Each output table contains the last `n` records before the [`offset`](#offset). -If the input table has less than `offset + n` records, `tail()` outputs all records before the `offset`. + + +`tail()` limits each output table to the last `n` rows. + +`tail()` produces one output table for each input table. +Each output table contains the last `n` records before the `offset`. +If the input table has less than `offset + n` records, `tail()` outputs all +records before the `offset`. + +##### Function type signature ```js -tail(n: 10, offset: 0) +(<-tables: stream[A], n: int, ?offset: int) => stream[A] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### n {data-type="int"} +### n ({{< req >}}) -The maximum number of records to output. +Maximum number of rows to output. + + + +### offset + +Number of records to skip at the end of a table table before +limiting to `n`. Default is 0. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + -### offset {data-type="int"} -The number of records to skip at the end of a table table before limiting to `n`. -Default is `0`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} - [Output the last three rows in each input table](#output-the-last-three-rows-in-each-input-table) - [Output the last three rows before the last row in each input table](#output-the-last-three-rows-before-the-last-row-in-each-input-table) -#### Output the last three rows in each input table +### Output the last three rows in each input table + ```js import "sampledata" @@ -54,34 +80,48 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Output the last three rows before the last row in each input table +### Output the last three rows before the last row in each input table + ```js import "sampledata" @@ -90,29 +130,42 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/time.md b/content/flux/v0.x/stdlib/universe/time.md index 65a6a94d8..2deebbfeb 100644 --- a/content/flux/v0.x/stdlib/universe/time.md +++ b/content/flux/v0.x/stdlib/universe/time.md @@ -1,120 +1,131 @@ --- title: time() function -description: The `time()` function converts a single value to a time. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/time/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/time/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/time/ +description: > + `time()` converts a value to a time type. menu: flux_0_x_ref: name: time parent: universe -weight: 102 + identifier: universe/time +weight: 101 flux/v0.x/tags: [type-conversions] -related: - - /flux/v0.x/data-types/basic/time/ - - /flux/v0.x/stdlib/universe/totime/ introduced: 0.7.0 --- -The `time()` function converts a value to a [time value](/flux/v0.x/data-types/basic/time/). + + +`time()` converts a value to a time type. + + + +##### Function type signature ```js -time(v: "2016-06-13T17:43:50.1004002Z") +(v: A) => time ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### v {data-type="string, int, uint"} -The value to convert. -String values must be formatted as [RFC3339 timestamps](/influxdb/cloud/reference/glossary/#rfc3339-timestamp). +### v +({{< req >}}) +Value to convert. + +Strings must be valid [RFC3339 timestamps](https://docs.influxdata.com/influxdb/cloud/reference/glossary/#rfc3339-timestamp). +Integer and unsigned integer values are parsed as nanosecond epoch timestamps. -{{% note %}} -`time()` assumes all numeric input values are nanosecond epoch timestamps. -{{% /note %}} ## Examples - [Convert a string to a time value](#convert-a-string-to-a-time-value) - [Convert an integer to a time value](#convert-an-integer-to-a-time-value) -- [Convert all values in a column to time values](#convert-all-values-in-a-column-to-time-values) +- [Convert all values in a column to time](#convert-all-values-in-a-column-to-time) + +### Convert a string to a time value -#### Convert a string to a time value ```js -time(v: "2021-01-01T00:00:00Z") +time(v: "2021-01-01T00:00:00Z")// Returns 2021-01-01T00:00:00Z (time) -// Returns 2021-01-01T00:00:00Z (time) ``` -#### Convert an integer to a time value -```js -time(v: 609459200000000000) -// Returns 2021-01-01T00:00:00Z +### Convert an integer to a time value + +```js +time(v: 1640995200000000000)// Returns 2022-01-01T00:00:00Z + ``` -#### Convert all values in a column to time values -If updating values in the `_value` column, use [`toTime()`](/flux/v0.x/stdlib/universe/totime/). -To update values in columns other than `_value`: -1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows. -2. Use `time()` to update the value of a column. +### Convert all values in a column to time -{{% flux/sample-example-intro %}} +If converting the `_value` column to time types, use `toTime()`. +If converting columns other than `_value`, use `map()` to iterate over each +row and `time()` to covert a column value to a time type. ```js -import "sampledata" - -data = sampledata.int() - |> map(fn: (r) => ({r with _value: r._value * 1000000000})) - |> rename(columns: {_value: "foo"}) - data - |> map(fn: (r) => ({r with foo: time(v: r.foo)})) + |> map(fn: (r) => ({r with exampleCol: time(v: r.exampleCol)})) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | tag | foo | -| :------------------- | :-- | ----------: | -| 2021-01-01T00:00:00Z | t1 | -2000000000 | -| 2021-01-01T00:00:10Z | t1 | 10000000000 | -| 2021-01-01T00:00:20Z | t1 | 7000000000 | -| 2021-01-01T00:00:30Z | t1 | 17000000000 | -| 2021-01-01T00:00:40Z | t1 | 15000000000 | -| 2021-01-01T00:00:50Z | t1 | 4000000000 | +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| _time | tag | foo | -| :------------------- | :-- | ----------: | -| 2021-01-01T00:00:00Z | t2 | 19000000000 | -| 2021-01-01T00:00:10Z | t2 | 4000000000 | -| 2021-01-01T00:00:20Z | t2 | -3000000000 | -| 2021-01-01T00:00:30Z | t2 | 19000000000 | -| 2021-01-01T00:00:40Z | t2 | 13000000000 | -| 2021-01-01T00:00:50Z | t2 | 1000000000 | +#### Input data -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | tag | foo | -| :------------------- | :-- | :------------------- | -| 2021-01-01T00:00:00Z | t1 | 1969-12-31T23:59:58Z | -| 2021-01-01T00:00:10Z | t1 | 1970-01-01T00:00:10Z | -| 2021-01-01T00:00:20Z | t1 | 1970-01-01T00:00:07Z | -| 2021-01-01T00:00:30Z | t1 | 1970-01-01T00:00:17Z | -| 2021-01-01T00:00:40Z | t1 | 1970-01-01T00:00:15Z | -| 2021-01-01T00:00:50Z | t1 | 1970-01-01T00:00:04Z | +| _time | _value | exampleCol | *tag | +| -------------------- | ------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | -2 | -2000000000 | t1 | +| 2021-01-01T00:00:10Z | 10 | 10000000000 | t1 | +| 2021-01-01T00:00:20Z | 7 | 7000000000 | t1 | +| 2021-01-01T00:00:30Z | 17 | 17000000000 | t1 | +| 2021-01-01T00:00:40Z | 15 | 15000000000 | t1 | +| 2021-01-01T00:00:50Z | 4 | 4000000000 | t1 | + +| _time | _value | exampleCol | *tag | +| -------------------- | ------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | 19 | 19000000000 | t2 | +| 2021-01-01T00:00:10Z | 4 | 4000000000 | t2 | +| 2021-01-01T00:00:20Z | -3 | -3000000000 | t2 | +| 2021-01-01T00:00:30Z | 19 | 19000000000 | t2 | +| 2021-01-01T00:00:40Z | 13 | 13000000000 | t2 | +| 2021-01-01T00:00:50Z | 1 | 1000000000 | t2 | + + +#### Output data + +| _time | _value | exampleCol | *tag | +| -------------------- | ------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | -2 | 1969-12-31T23:59:58Z | t1 | +| 2021-01-01T00:00:10Z | 10 | 1970-01-01T00:00:10Z | t1 | +| 2021-01-01T00:00:20Z | 7 | 1970-01-01T00:00:07Z | t1 | +| 2021-01-01T00:00:30Z | 17 | 1970-01-01T00:00:17Z | t1 | +| 2021-01-01T00:00:40Z | 15 | 1970-01-01T00:00:15Z | t1 | +| 2021-01-01T00:00:50Z | 4 | 1970-01-01T00:00:04Z | t1 | + +| _time | _value | exampleCol | *tag | +| -------------------- | ------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | 1970-01-01T00:00:19Z | t2 | +| 2021-01-01T00:00:10Z | 4 | 1970-01-01T00:00:04Z | t2 | +| 2021-01-01T00:00:20Z | -3 | 1969-12-31T23:59:57Z | t2 | +| 2021-01-01T00:00:30Z | 19 | 1970-01-01T00:00:19Z | t2 | +| 2021-01-01T00:00:40Z | 13 | 1970-01-01T00:00:13Z | t2 | +| 2021-01-01T00:00:50Z | 1 | 1970-01-01T00:00:01Z | t2 | -| _time | tag | foo | -| :------------------- | :-- | :------------------- | -| 2021-01-01T00:00:00Z | t2 | 1970-01-01T00:00:19Z | -| 2021-01-01T00:00:10Z | t2 | 1970-01-01T00:00:04Z | -| 2021-01-01T00:00:20Z | t2 | 1969-12-31T23:59:57Z | -| 2021-01-01T00:00:30Z | t2 | 1970-01-01T00:00:19Z | -| 2021-01-01T00:00:40Z | t2 | 1970-01-01T00:00:13Z | -| 2021-01-01T00:00:50Z | t2 | 1970-01-01T00:00:01Z | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/timedmovingaverage.md b/content/flux/v0.x/stdlib/universe/timedmovingaverage.md index 17330bec9..afe0a54dd 100644 --- a/content/flux/v0.x/stdlib/universe/timedmovingaverage.md +++ b/content/flux/v0.x/stdlib/universe/timedmovingaverage.md @@ -1,166 +1,123 @@ --- title: timedMovingAverage() function description: > - The `timedMovingAverage()` function calculates the mean of values in a defined time - range at a specified frequency. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/timedmovingaverage/ + `timedMovingAverage()` returns the mean of values in a defined time range at a + specified frequency. menu: flux_0_x_ref: name: timedMovingAverage parent: universe -weight: 102 + identifier: universe/timedMovingAverage +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/movingaverage/ - - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ - - /flux/v0.x/stdlib/universe/doubleema/ - - /flux/v0.x/stdlib/universe/tripleema/ - - /{{< latest "influxdb" >}}/query-data/flux/moving-average/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE() introduced: 0.36.0 --- -The `timedMovingAverage()` function calculates the mean of values in a defined time -range at a specified frequency. + + +`timedMovingAverage()` returns the mean of values in a defined time range at a +specified frequency. For each row in a table, `timedMovingAverage()` returns the average of the -current value and all row values in the **previous** `period` (duration). +current value and all row values in the previous `period` (duration). It returns moving averages at a frequency defined by the `every` parameter. -Each color in the diagram below represents a period of time used to calculate an -average and the time a point representing the average is returned. -If `every = 30m` and `period = 1h`: +#### Aggregate by calendar months and years +`every` and `period` parameters support all valid duration units, including +calendar months (`1mo`) and years (`1y`). -{{< svg "/static/svgs/timed-moving-avg.svg" >}} +#### Aggregate by week +When aggregating by week (`1w`), weeks are determined using the Unix epoch +(1970-01-01T00:00:00Z UTC). The Unix epoch was on a Thursday, so all +calculated weeks begin on Thursday. + +##### Function type signature + +```js +(<-tables: stream[A], every: duration, period: duration, ?column: string) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### every {data-type="duration"} +### every ({{< req >}}) -Frequency of time windows. +Frequency of time window. -{{% note %}} -#### Calendar months and years -`every` supports all [valid duration units](/flux/v0.x/spec/types/#duration-types), -including **calendar months (`1mo`)** and **years (`1y`)**. -#### Aggregate by week -When aggregating by week (`1w`), weeks are determined using the -**Unix epoch (1970-01-01T00:00:00Z UTC)**. The Unix epoch was on a Thursday, so -all calculated weeks begin on Thursday. -{{% /note %}} -### period {data-type="duration"} +### period ({{< req >}}) Length of each averaged time window. -_A negative duration indicates start and stop boundaries are reversed._ -### column {data-type="string"} -Column used to compute the moving average. -Defaults to `"_value"`. +A negative duration indicates start and stop boundaries are reversed. + +### column + +Column to operate on. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -The following examples use [`generate.from()`](/flux/v0.x/stdlib/generate/from/) -to generate sample data and illustrate how `timedMovingAverage()` transforms data. -#### Calculate a five year moving average every year +### Calculate a five year moving average every year + ```js -timeRange = {start: 2015-01-01T00:00:00Z, stop: 2021-01-01T00:00:00Z} - -data = generate.from(count: 6, fn: (n) => n * n, start: timeRange.start, stop: timeRange.stop) - |> range(start: timeRange.start, stop: timeRange.stop) - data |> timedMovingAverage(every: 1y, period: 5y) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -##### Input data -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2015-01-01T00:00:00Z | 0 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2016-01-01T08:00:00Z | 1 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2016-12-31T16:00:00Z | 4 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2018-01-01T00:00:00Z | 9 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2019-01-01T08:00:00Z | 16 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2020-01-01T16:00:00Z | 25 | +{{% expand "View example input and ouput" %}} -##### Output data -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2016-01-01T00:00:00Z | 0.0 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2017-01-01T00:00:00Z | 1.6667 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2018-01-01T00:00:00Z | 1.6667 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2019-01-01T00:00:00Z | 3.5 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2020-01-01T00:00:00Z | 6.0 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 11.0 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 16.668 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 16.668 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 20.5 | -| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 25.0 | - -{{% /expand %}} -{{< /expand-wrapper >}} - -#### Calculate a seven day moving average every day -```js -import "generate" - -timeRange = {start: 2021-01-01T00:00:00Z, stop: 2021-01-08T00:00:00Z} - -data = generate.from(count: 7, fn: (n) => n + n, start: timeRange.start, stop: timeRange.stop) - |> range(start: timeRange.start, stop: timeRange.stop) - -data - |> timedMovingAverage(every: 1d, period: 7d) -``` - -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -##### Input data -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-01T00:00:00Z | 0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-02T00:00:00Z | 2 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-03T00:00:00Z | 4 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-04T00:00:00Z | 6 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-05T00:00:00Z | 8 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-06T00:00:00Z | 10 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-07T00:00:00Z | 12 | - -##### Output data -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-02T00:00:00Z | 0.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-03T00:00:00Z | 1.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-04T00:00:00Z | 2.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-05T00:00:00Z | 3.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-06T00:00:00Z | 4.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-07T00:00:00Z | 5.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-08T00:00:00Z | 6.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-08T00:00:00Z | 7.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-08T00:00:00Z | 8.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-08T00:00:00Z | 9.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-08T00:00:00Z | 10.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-08T00:00:00Z | 11.0 | -| 2021-01-01T00:00:00Z | 2021-01-08T00:00:00Z | 2021-01-08T00:00:00Z | 12.0 | +#### Input data + +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2015-01-01T00:00:00Z | 0 | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2016-01-01T08:00:00Z | 1 | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2016-12-31T16:00:00Z | 4 | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2018-01-01T00:00:00Z | 9 | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2019-01-01T08:00:00Z | 16 | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 2020-01-01T16:00:00Z | 25 | + + +#### Output data + +| *_start | *_stop | _value | _time | +| -------------------- | -------------------- | ------------------ | -------------------- | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 0 | 2016-01-01T00:00:00Z | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 1.6666666666666667 | 2017-01-01T00:00:00Z | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 1.6666666666666667 | 2018-01-01T00:00:00Z | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 3.5 | 2019-01-01T00:00:00Z | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 6 | 2020-01-01T00:00:00Z | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 11 | 2021-01-01T00:00:00Z | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 16.666666666666668 | 2021-01-01T00:00:00Z | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 16.666666666666668 | 2021-01-01T00:00:00Z | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 20.5 | 2021-01-01T00:00:00Z | +| 2015-01-01T00:00:00Z | 2021-01-01T00:00:00Z | 25 | 2021-01-01T00:00:00Z | {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/timeshift.md b/content/flux/v0.x/stdlib/universe/timeshift.md index 0d2d39a65..3dd999c3c 100644 --- a/content/flux/v0.x/stdlib/universe/timeshift.md +++ b/content/flux/v0.x/stdlib/universe/timeshift.md @@ -1,51 +1,74 @@ --- title: timeShift() function -description: The `timeShift()` function adds a fixed duration to time columns. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/shift - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/shift - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/timeshift/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/timeshift/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/timeshift/ +description: > + `timeShift()` adds a fixed duration to time columns. menu: flux_0_x_ref: name: timeShift parent: universe -weight: 102 + identifier: universe/timeShift +weight: 101 flux/v0.x/tags: [transformations, date/time] introduced: 0.7.0 --- -The `timeShift()` function adds a fixed duration to time columns. -The output table schema is the same as the input table. -If the time is `null`, the time will continue to be `null`. + + +`timeShift()` adds a fixed duration to time columns. + +The output table schema is the same as the input table schema. +`null` time values remain `null`. + +##### Function type signature ```js -timeShift(duration: 10h, columns: ["_start", "_stop", "_time"]) +(<-tables: stream[A], duration: duration, ?columns: [string]) => stream[A] ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### duration {data-type="duration"} +### duration ({{< req >}}) -The amount of time to add to each time value. -May be a negative duration. +Amount of time to add to each time value. May be a negative duration. + + + +### columns + +List of time columns to operate on. Default is `["_start", "_stop", "_time"]`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + -### columns {data-type="array of strings"} -The list of all columns to be shifted. -Default is `["_start", "_stop", "_time"]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Shift timestamps forward in time](#shift-timestamps-forward-in-time) - [Shift timestamps backward in time](#shift-timestamps-backward-in-time) -#### Shift timestamps forward in time +### Shift timestamps forward in time + ```js import "sampledata" @@ -54,40 +77,54 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T12:00:00Z | t1 | -2 | -| 2021-01-01T12:00:10Z | t1 | 10 | -| 2021-01-01T12:00:20Z | t1 | 7 | -| 2021-01-01T12:00:30Z | t1 | 17 | -| 2021-01-01T12:00:40Z | t1 | 15 | -| 2021-01-01T12:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T12:00:00Z | -2 | t1 | +| 2021-01-01T12:00:10Z | 10 | t1 | +| 2021-01-01T12:00:20Z | 7 | t1 | +| 2021-01-01T12:00:30Z | 17 | t1 | +| 2021-01-01T12:00:40Z | 15 | t1 | +| 2021-01-01T12:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T12:00:00Z | 19 | t2 | +| 2021-01-01T12:00:10Z | 4 | t2 | +| 2021-01-01T12:00:20Z | -3 | t2 | +| 2021-01-01T12:00:30Z | 19 | t2 | +| 2021-01-01T12:00:40Z | 13 | t2 | +| 2021-01-01T12:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T12:00:00Z | t2 | 19 | -| 2021-01-01T12:00:10Z | t2 | 4 | -| 2021-01-01T12:00:20Z | t2 | -3 | -| 2021-01-01T12:00:30Z | t2 | 19 | -| 2021-01-01T12:00:40Z | t2 | 13 | -| 2021-01-01T12:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Shift timestamps backward in time +### Shift timestamps backward in time + ```js import "sampledata" @@ -96,35 +133,48 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2020-12-31T12:00:00Z | t1 | -2 | -| 2020-12-31T12:00:10Z | t1 | 10 | -| 2020-12-31T12:00:20Z | t1 | 7 | -| 2020-12-31T12:00:30Z | t1 | 17 | -| 2020-12-31T12:00:40Z | t1 | 15 | -| 2020-12-31T12:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2020-12-31T12:00:00Z | -2 | t1 | +| 2020-12-31T12:00:10Z | 10 | t1 | +| 2020-12-31T12:00:20Z | 7 | t1 | +| 2020-12-31T12:00:30Z | 17 | t1 | +| 2020-12-31T12:00:40Z | 15 | t1 | +| 2020-12-31T12:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2020-12-31T12:00:00Z | 19 | t2 | +| 2020-12-31T12:00:10Z | 4 | t2 | +| 2020-12-31T12:00:20Z | -3 | t2 | +| 2020-12-31T12:00:30Z | 19 | t2 | +| 2020-12-31T12:00:40Z | 13 | t2 | +| 2020-12-31T12:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2020-12-31T12:00:00Z | t2 | 19 | -| 2020-12-31T12:00:10Z | t2 | 4 | -| 2020-12-31T12:00:20Z | t2 | -3 | -| 2020-12-31T12:00:30Z | t2 | 19 | -| 2020-12-31T12:00:40Z | t2 | 13 | -| 2020-12-31T12:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/timeweightedavg.md b/content/flux/v0.x/stdlib/universe/timeweightedavg.md index 052a08120..e01bc7ffb 100644 --- a/content/flux/v0.x/stdlib/universe/timeweightedavg.md +++ b/content/flux/v0.x/stdlib/universe/timeweightedavg.md @@ -1,80 +1,100 @@ --- title: timeWeightedAvg() function -description: The `timeWeightedAvg()` function outputs the timeWeightedAvg of non-null records as a float. -aliases: - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timeweightedavg/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/timeweightedavg/ +description: > + `timeWeightedAvg()` returns the time-weighted average of non-null values in + `_value` column as a float for each input table. menu: flux_0_x_ref: name: timeWeightedAvg parent: universe -weight: 102 -flux/v0.x/tags: [aggregates, transformations] -related: - - /flux/v0.x/stdlib/universe/integral/ + identifier: universe/timeWeightedAvg +weight: 101 +flux/v0.x/tags: [transformations, aggregates] introduced: 0.83.0 --- -The `timeWeightedAvg()` function outputs the time-weighted average of non-null records -in a table as a float. -Time is weighted using the linearly interpolated integral of values in the table. -_`timeWeightedAvg()` is an [aggregate function](/flux/v0.x/function-types/#aggregates)._ + + +`timeWeightedAvg()` returns the time-weighted average of non-null values in +`_value` column as a float for each input table. + +Time is weighted using the linearly interpolated integral of values in the table. + +##### Function type signature ```js -timeWeightedAvg(unit: 1m) +(<-tables: stream[A], unit: duration) => stream[{B with _value: float, _value: float, _stop: D, _start: C}] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### unit {data-type="duration"} +### unit ({{< req >}}) -Time duration used when computing the time-weighted average. +Unit of time to use to compute the time-weighted average. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Calculate the time-weighted average of values + ```js -import "sampledata" - -data = sampledata.int(includeNull: true) - |> range(start: sampledata.start, stop: sampledata.stop) - |> fill(usePrevious: true) - |> unique() - data |> timeWeightedAvg(unit: 1s) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -##### Input data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t1 | 4 | +{{% expand "View example input and ouput" %}} -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t2 | 1 | +#### Input data -##### Output data -| _start | _stop | tag | _value | -| :------------------- | :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 4.166666666666667 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | -| _start | _stop | tag | _value | -| :------------------- | :------------------- | :-- | ----------------: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 5.416666666666667 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| *_start | *_stop | _value | *tag | +| -------------------- | -------------------- | ----------------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 4.166666666666667 | t1 | + +| *_start | *_stop | _value | *tag | +| -------------------- | -------------------- | ----------------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 5.416666666666667 | t2 | {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/tobool.md b/content/flux/v0.x/stdlib/universe/tobool.md index a4356d3ef..9f94a60d8 100644 --- a/content/flux/v0.x/stdlib/universe/tobool.md +++ b/content/flux/v0.x/stdlib/universe/tobool.md @@ -1,51 +1,62 @@ --- title: toBool() function -description: The `toBool()` function converts all values in the `_value` column to booleans. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/tobool - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/tobool/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/tobool/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/tobool/ +description: > + `toBool()` converts all values in the `_value` column to boolean types. menu: flux_0_x_ref: name: toBool parent: universe -weight: 102 -flux/v0.x/tags: [type-conversions, transformations] -related: - - /flux/v0.x/data-types/basic/bool/ - - /flux/v0.x/stdlib/universe/bool/ + identifier: universe/toBool +weight: 101 +flux/v0.x/tags: [transformations, type-conversions] introduced: 0.7.0 --- -The `toBool()` function converts all values in the `_value` column to booleans. + + +`toBool()` converts all values in the `_value` column to boolean types. + +#### Supported data types - **string**: `true` or `false` - **int**: `1` or `0` - **uint**: `1` or `0` - **float**: `1.0` or `0.0` +##### Function type signature + +```js +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: bool}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} -#### Convert an integer value column to a boolean column +### Convert an integer _value column to booleans + ```js import "sampledata" @@ -54,35 +65,48 @@ sampledata.numericBool() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "numericBool" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 0 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 0 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | true | -| 2021-01-01T00:00:10Z | t1 | true | -| 2021-01-01T00:00:20Z | t1 | false | -| 2021-01-01T00:00:30Z | t1 | true | -| 2021-01-01T00:00:40Z | t1 | false | -| 2021-01-01T00:00:50Z | t1 | false | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 1 | t2 | +| 2021-01-01T00:00:20Z | 0 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | true | t1 | +| 2021-01-01T00:00:10Z | true | t1 | +| 2021-01-01T00:00:20Z | false | t1 | +| 2021-01-01T00:00:30Z | true | t1 | +| 2021-01-01T00:00:40Z | false | t1 | +| 2021-01-01T00:00:50Z | false | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | false | t2 | +| 2021-01-01T00:00:10Z | true | t2 | +| 2021-01-01T00:00:20Z | false | t2 | +| 2021-01-01T00:00:30Z | true | t2 | +| 2021-01-01T00:00:40Z | true | t2 | +| 2021-01-01T00:00:50Z | false | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | false | -| 2021-01-01T00:00:10Z | t2 | true | -| 2021-01-01T00:00:20Z | t2 | false | -| 2021-01-01T00:00:30Z | t2 | true | -| 2021-01-01T00:00:40Z | t2 | true | -| 2021-01-01T00:00:50Z | t2 | false | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/today.md b/content/flux/v0.x/stdlib/universe/today.md index e17fc1a94..4c8085a4b 100644 --- a/content/flux/v0.x/stdlib/universe/today.md +++ b/content/flux/v0.x/stdlib/universe/today.md @@ -1,41 +1,65 @@ --- title: today() function description: > - The `today()` function returns the `now()` timestamp truncated to the day unit. + `today()` returns the now() timestamp truncated to the day unit. menu: flux_0_x_ref: name: today parent: universe -weight: 102 -aliases: - - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/today/ - - /influxdb/cloud/reference/flux/stdlib/built-in/misc/today/ -related: - - /flux/v0.x/stdlib/universe/now/ - - /flux/v0.x/stdlib/date/truncate/ - - /flux/v0.x/stdlib/system/time/ + identifier: universe/today +weight: 101 flux/v0.x/tags: [date/time] introduced: 0.116.0 --- -The `today()` function returns the `now()` timestamp truncated to the day unit. + + +`today()` returns the now() timestamp truncated to the day unit. + + + +##### Function type signature ```js -today() +() => time ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + + ## Examples -##### Return a timestamp representing today -```js -option now = () => 2021-01-01T13:45:28Z +- [Return a timestamp representing today](#return-a-timestamp-representing-today) +- [Query data from today](#query-data-from-today) + +### Return a timestamp representing today + +```js +option now = () => 2022-01-01T13:45:28Z + +today()// Returns 2022-01-01T00:00:00.000000000Z -today() -// Returns 2021-01-01T00:00:00.000000000Z ``` -##### Query data from today + +### Query data from today + ```js from(bucket: "example-bucket") |> range(start: today()) ``` + diff --git a/content/flux/v0.x/stdlib/universe/toduration.md b/content/flux/v0.x/stdlib/universe/toduration.md deleted file mode 100644 index a914067a4..000000000 --- a/content/flux/v0.x/stdlib/universe/toduration.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: toDuration() function -description: The `toDuration()` function converts all values in the `_value` column to durations. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/toduration - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/toduration/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/toduration/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/toduration/ -weight: 102 -flux/v0.x/tags: [type-conversions, transformations] -related: - - /flux/v0.x/data-types/basic/duration/ - - /flux/v0.x/stdlib/universe/duration/ -introduced: 0.7.0 -removed: 0.37.0 ---- - -{{% warn %}} -**`toDuration()` was removed in Flux 0.37.** -{{% /warn %}} - -The `toDuration()` function converts all values in the `_value` column to durations. - -```js -toDuration() -``` - -_**Supported data types:** String | Integer | Uinteger_ - -{{% note %}} -`duration()` assumes **numeric** input values are **nanoseconds**. -**String** input values must use [duration literal representation](/flux/v0.x/spec/lexical-elements/#duration-literals). -{{% /note %}} - -## Parameters - -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). diff --git a/content/flux/v0.x/stdlib/universe/tofloat.md b/content/flux/v0.x/stdlib/universe/tofloat.md index 4dba914ee..1ab11de00 100644 --- a/content/flux/v0.x/stdlib/universe/tofloat.md +++ b/content/flux/v0.x/stdlib/universe/tofloat.md @@ -1,55 +1,65 @@ --- title: toFloat() function -description: The `toFloat()` function converts all values in the `_value` column to floats. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/tofloat - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/tofloat/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/tofloat/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/tofloat/ +description: > + `toFloat()` converts all values in the `_value` column to float types. menu: flux_0_x_ref: name: toFloat parent: universe -weight: 102 -flux/v0.x/tags: [type-conversions, transformations] -related: - - /flux/v0.x/data-types/basic/float/ - - /flux/v0.x/stdlib/universe/float/ + identifier: universe/toFloat +weight: 101 +flux/v0.x/tags: [transformations, type-conversions] introduced: 0.7.0 --- -The `toFloat()` function converts all values in the `_value` column to floats. + + +`toFloat()` converts all values in the `_value` column to float types. + +#### Supported data types +- string (numeric, scientific notation, ±Inf, or NaN) - boolean - int - uint +##### Function type signature + +```js +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: float}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro plural=true %}} -- [Convert an integer value column to a float column](#convert-an-integer-value-column-to-a-float-column) -- [Convert a boolean value column to a float column](#convert-a-boolean-value-column-to-a-float-column) +- [Convert an integer _value column to floats](#convert-an-integer-_value-column-to-floats) +- [Convert a boolean _value column to floats](#convert-a-boolean-_value-column-to-floats) + +### Convert an integer _value column to floats -#### Convert an integer value column to a float column ```js import "sampledata" @@ -58,40 +68,54 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2.0 | -| 2021-01-01T00:00:10Z | t1 | 10.0 | -| 2021-01-01T00:00:20Z | t1 | 7.0 | -| 2021-01-01T00:00:30Z | t1 | 17.0 | -| 2021-01-01T00:00:40Z | t1 | 15.0 | -| 2021-01-01T00:00:50Z | t1 | 4.0 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19.0 | -| 2021-01-01T00:00:10Z | t2 | 4.0 | -| 2021-01-01T00:00:20Z | t2 | -3.0 | -| 2021-01-01T00:00:30Z | t2 | 19.0 | -| 2021-01-01T00:00:40Z | t2 | 13.0 | -| 2021-01-01T00:00:50Z | t2 | 1.0 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Convert a boolean value column to a float column +### Convert a boolean _value column to floats + ```js import "sampledata" @@ -100,35 +124,48 @@ sampledata.bool() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "bool" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | true | +| 2021-01-01T00:00:10Z | t1 | true | +| 2021-01-01T00:00:20Z | t1 | false | +| 2021-01-01T00:00:30Z | t1 | true | +| 2021-01-01T00:00:40Z | t1 | false | +| 2021-01-01T00:00:50Z | t1 | false | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | 1.0 | -| 2021-01-01T00:00:10Z | t1 | 1.0 | -| 2021-01-01T00:00:20Z | t1 | 0.0 | -| 2021-01-01T00:00:30Z | t1 | 1.0 | -| 2021-01-01T00:00:40Z | t1 | 0.0 | -| 2021-01-01T00:00:50Z | t1 | 0.0 | +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | false | +| 2021-01-01T00:00:10Z | t2 | true | +| 2021-01-01T00:00:20Z | t2 | false | +| 2021-01-01T00:00:30Z | t2 | true | +| 2021-01-01T00:00:40Z | t2 | true | +| 2021-01-01T00:00:50Z | t2 | false | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 0 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 0 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 1 | t2 | +| 2021-01-01T00:00:20Z | 0 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 0.0 | -| 2021-01-01T00:00:10Z | t2 | 1.0 | -| 2021-01-01T00:00:20Z | t2 | 0.0 | -| 2021-01-01T00:00:30Z | t2 | 1.0 | -| 2021-01-01T00:00:40Z | t2 | 1.0 | -| 2021-01-01T00:00:50Z | t2 | 0.0 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/toint.md b/content/flux/v0.x/stdlib/universe/toint.md index c0c35f1c7..15f6c5d60 100644 --- a/content/flux/v0.x/stdlib/universe/toint.md +++ b/content/flux/v0.x/stdlib/universe/toint.md @@ -1,68 +1,72 @@ --- title: toInt() function -description: The `toInt()` function converts all values in the `_value` column to integers. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/toint - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/toint/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/toint/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/toint/ +description: > + `toInt()` converts all values in the `_value` column to integer types. menu: flux_0_x_ref: name: toInt parent: universe -weight: 102 -flux/v0.x/tags: [type-conversions, transformations] + identifier: universe/toInt +weight: 101 +flux/v0.x/tags: [transformations, type-conversions] introduced: 0.7.0 -related: - - /flux/v0.x/data-types/basic/int/ - - /flux/v0.x/stdlib/universe/int/ --- -The `toInt()` function converts all values in the `_value` column to integers. + + +`toInt()` converts all values in the `_value` column to integer types. + +#### Supported types and behaviors +`toInt()` behavior depends on the `_value` column type: + +| _value type | Returned value | +| :---------- | :---------------------------------------------- | +| string | Integer equivalent of the numeric string | +| bool | 1 (true) or 0 (false) | +| duration | Number of nanoseconds in the specified duration | +| time | Equivalent nanosecond epoch timestamp | +| float | Value truncated at the decimal | +| uint | Integer equivalent of the unsigned integer | + +##### Function type signature ```js -toInt() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: int}] ``` -##### Supported data types - -- bool -- duration -- float -- string (numeric) -- time -- uinteger - -`toInt()` behavior depends on the `_value` column data type: - -| \_value type | Returned value | -| :----------- | :---------------------------------------------- | -| string | Integer equivalent of the numeric string | -| bool | 1 (true) or 0 (false) | -| duration | Number of nanoseconds in the specified duration | -| time | Equivalent nanosecond epoch timestamp | -| float | Value truncated at the decimal | -| uint | Integer equivalent of the unsigned integer | - -{{% note %}} -To convert values in a column other than `_value`, use `map()` and `int()` -as shown in [this example](/flux/v0.x/stdlib/universe/int/#convert-all-values-in-a-column-to-integer-values). -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro plural=true %}} -- [Convert a float value column to an integer column](#convert-a-float-value-column-to-an-integer-column) -- [Convert a boolean value column to an integer column](#convert-a-boolean-value-column-to-an-integer-column) -- [Convert a uinteger value column to an integer column](#convert-a-uinteger-value-column-to-an-integer-column) +- [Convert a float _value column to integers](#convert-a-float-_value-column-to-integers) +- [Convert a boolean _value column to integers](#convert-a-boolean-_value-column-to-integers) +- [Convert a uinteger _value column to an integers](#convert-a-uinteger-_value-column-to-an-integers) + +### Convert a float _value column to integers -#### Convert a float value column to an integer column ```js import "sampledata" @@ -71,40 +75,54 @@ sampledata.float() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "float" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Convert a boolean value column to an integer column +### Convert a boolean _value column to integers + ```js import "sampledata" @@ -113,25 +131,54 @@ sampledata.bool() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "bool" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | true | +| 2021-01-01T00:00:10Z | t1 | true | +| 2021-01-01T00:00:20Z | t1 | false | +| 2021-01-01T00:00:30Z | t1 | true | +| 2021-01-01T00:00:40Z | t1 | false | +| 2021-01-01T00:00:50Z | t1 | false | -##### Output data -{{% flux/sample "numericBool" %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | false | +| 2021-01-01T00:00:10Z | t2 | true | +| 2021-01-01T00:00:20Z | t2 | false | +| 2021-01-01T00:00:30Z | t2 | true | +| 2021-01-01T00:00:40Z | t2 | true | +| 2021-01-01T00:00:50Z | t2 | false | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 0 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 0 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 1 | t2 | +| 2021-01-01T00:00:20Z | 0 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Convert a uinteger value column to an integer column +### Convert a uinteger _value column to an integers + ```js import "sampledata" @@ -140,35 +187,48 @@ sampledata.uint() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "uint" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/top.md b/content/flux/v0.x/stdlib/universe/top.md index c80c336c5..3ca773938 100644 --- a/content/flux/v0.x/stdlib/universe/top.md +++ b/content/flux/v0.x/stdlib/universe/top.md @@ -1,51 +1,72 @@ --- title: top() function -description: The `top()` function sorts a table by columns and keeps only the top n records. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/top - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/top/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/top/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/top/ +description: > + `top()` sorts each input table by specified columns and keeps the top `n` records + in each table. menu: flux_0_x_ref: name: top parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] + identifier: universe/top +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `top()` function sorts each input table by columns and keeps only the top `n` records. -_`top()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`top()` sorts each input table by specified columns and keeps the top `n` records +in each table. + +**Note:** `top()` drops empty tables. + +##### Function type signature ```js -top(n:10, columns: ["_value"]) +(<-tables: stream[A], n: int, ?columns: [string]) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`top()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n ({{< req >}}) -Number of records to return. +Number of rows to return from each input table. + + + +### columns + +List of columns to sort by. Default is `["_value"]`. -### columns {data-type="array of strings"} -List of columns to sort by. Sort precedence is determined by list order (left to right). -Default is `["_value"]`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} -##### Return rows with the top three values in each input table +### Return rows with the three highest values in each input table + ```js import "sampledata" @@ -54,29 +75,42 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "float" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:10Z | t1 | 10 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/tostring.md b/content/flux/v0.x/stdlib/universe/tostring.md index db21fca14..b136e8497 100644 --- a/content/flux/v0.x/stdlib/universe/tostring.md +++ b/content/flux/v0.x/stdlib/universe/tostring.md @@ -1,51 +1,58 @@ --- title: toString() function -description: The `toString()` function converts all values in the `_value` column to strings. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/tostring - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/tostring/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/tostring/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/tostring/ +description: > + `toString()` converts all values in the `_value` column to string types. menu: flux_0_x_ref: name: toString parent: universe -weight: 102 -flux/v0.x/tags: [type-conversions, transformations] + identifier: universe/toString +weight: 101 +flux/v0.x/tags: [transformations, type-conversions] introduced: 0.7.0 --- -The `toString()` function converts all values in the `_value` column to strings. + + +`toString()` converts all values in the `_value` column to string types. + + + +##### Function type signature ```js -toString() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: string}] ``` -{{% note %}} -To convert values in a column other than `_value`, use `map()` and `string()` -as shown in [this example](/flux/v0.x/stdlib/universe/string/#convert-all-values-in-a-column-to-string-values). -{{% /note %}} - -##### Supported data types - -- bool -- bytes -- duration -- float -- int -- time -- uint +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} -#### Convert a float value column to a string column +### Convert the _value column to strings + ```js import "sampledata" @@ -54,35 +61,48 @@ sampledata.float() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "float" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -##### Output data -| tag | _time | _value _(string)_ | -| :-- | :------------------- | ----------------------------------------------------------------: | -| t1 | 2021-01-01T00:00:00Z | -2.18 | -| t1 | 2021-01-01T00:00:10Z | 10.92 | -| t1 | 2021-01-01T00:00:20Z | 7.35 | -| t1 | 2021-01-01T00:00:30Z | 17.53 | -| t1 | 2021-01-01T00:00:40Z | 15.23 | -| t1 | 2021-01-01T00:00:50Z | 4.43 | +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2.18 | t1 | +| 2021-01-01T00:00:10Z | 10.92 | t1 | +| 2021-01-01T00:00:20Z | 7.35 | t1 | +| 2021-01-01T00:00:30Z | 17.53 | t1 | +| 2021-01-01T00:00:40Z | 15.23 | t1 | +| 2021-01-01T00:00:50Z | 4.43 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19.85 | t2 | +| 2021-01-01T00:00:10Z | 4.97 | t2 | +| 2021-01-01T00:00:20Z | -3.75 | t2 | +| 2021-01-01T00:00:30Z | 19.77 | t2 | +| 2021-01-01T00:00:40Z | 13.86 | t2 | +| 2021-01-01T00:00:50Z | 1.86 | t2 | -| tag | _time | _value _(string)_ | -| :-- | :------------------- | ----------------------------------------------------------------: | -| t2 | 2021-01-01T00:00:00Z | 19.85 | -| t2 | 2021-01-01T00:00:10Z | 4.97 | -| t2 | 2021-01-01T00:00:20Z | -3.75 | -| t2 | 2021-01-01T00:00:30Z | 19.77 | -| t2 | 2021-01-01T00:00:40Z | 13.86 | -| t2 | 2021-01-01T00:00:50Z | 1.86 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/totime.md b/content/flux/v0.x/stdlib/universe/totime.md index a1a2abd4c..78942205b 100644 --- a/content/flux/v0.x/stdlib/universe/totime.md +++ b/content/flux/v0.x/stdlib/universe/totime.md @@ -1,108 +1,111 @@ --- title: toTime() function -description: The `toTime()` function converts all values in the `_value` column to times. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/totime - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/totime/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/totime/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/totime/ +description: > + `toTime()` converts all values in the `_value` column to time types. menu: flux_0_x_ref: name: toTime parent: universe -weight: 102 -flux/v0.x/tags: [type-conversions, transformations] -related: - - /flux/v0.x/data-types/basic/time/ - - /flux/v0.x/stdlib/universe/time/ + identifier: universe/toTime +weight: 101 +flux/v0.x/tags: [transformations, type-conversions] introduced: 0.7.0 --- -The `toTime()` function converts all values in the `_value` column to times. + + +`toTime()` converts all values in the `_value` column to time types. + +#### Supported data types +- string (RFC3339 timestamp) - int - uint -{{% note %}} `toTime()` treats all numeric input values as nanosecond epoch timestamps. -{{% /note %}} + +##### Function type signature + +```js +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: time}] +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} -#### Convert an integer value column to a time column +### Convert an integer _value column to times + ```js -import "sampledata" - -data = sampledata.int() - |> map(fn: (r) => ({r with _value: r._value * 1000000000})) - data |> toTime() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -| _time | tag | _value | -| :------------------- | :-- | ----------: | -| 2021-01-01T00:00:00Z | t1 | -2000000000 | -| 2021-01-01T00:00:10Z | t1 | 10000000000 | -| 2021-01-01T00:00:20Z | t1 | 7000000000 | -| 2021-01-01T00:00:30Z | t1 | 17000000000 | -| 2021-01-01T00:00:40Z | t1 | 15000000000 | -| 2021-01-01T00:00:50Z | t1 | 4000000000 | +{{% expand "View example input and ouput" %}} -| _time | tag | _value | -| :------------------- | :-- | ----------: | -| 2021-01-01T00:00:00Z | t2 | 19000000000 | -| 2021-01-01T00:00:10Z | t2 | 4000000000 | -| 2021-01-01T00:00:20Z | t2 | -3000000000 | -| 2021-01-01T00:00:30Z | t2 | 19000000000 | -| 2021-01-01T00:00:40Z | t2 | 13000000000 | -| 2021-01-01T00:00:50Z | t2 | 1000000000 | +#### Input data -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -------------------: | -| 2021-01-01T00:00:00Z | t1 | 1969-12-31T23:59:58Z | -| 2021-01-01T00:00:10Z | t1 | 1970-01-01T00:00:10Z | -| 2021-01-01T00:00:20Z | t1 | 1970-01-01T00:00:07Z | -| 2021-01-01T00:00:30Z | t1 | 1970-01-01T00:00:17Z | -| 2021-01-01T00:00:40Z | t1 | 1970-01-01T00:00:15Z | -| 2021-01-01T00:00:50Z | t1 | 1970-01-01T00:00:04Z | +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | -20000000000000000 | t1 | +| 2021-01-01T00:00:10Z | 100000000000000000 | t1 | +| 2021-01-01T00:00:20Z | 70000000000000000 | t1 | +| 2021-01-01T00:00:30Z | 170000000000000000 | t1 | +| 2021-01-01T00:00:40Z | 150000000000000000 | t1 | +| 2021-01-01T00:00:50Z | 40000000000000000 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:00Z | 190000000000000000 | t2 | +| 2021-01-01T00:00:10Z | 40000000000000000 | t2 | +| 2021-01-01T00:00:20Z | -30000000000000000 | t2 | +| 2021-01-01T00:00:30Z | 190000000000000000 | t2 | +| 2021-01-01T00:00:40Z | 130000000000000000 | t2 | +| 2021-01-01T00:00:50Z | 10000000000000000 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 1969-05-14T12:26:40Z | t1 | +| 2021-01-01T00:00:10Z | 1973-03-03T09:46:40Z | t1 | +| 2021-01-01T00:00:20Z | 1972-03-21T04:26:40Z | t1 | +| 2021-01-01T00:00:30Z | 1975-05-22T14:13:20Z | t1 | +| 2021-01-01T00:00:40Z | 1974-10-03T02:40:00Z | t1 | +| 2021-01-01T00:00:50Z | 1971-04-08T23:06:40Z | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 1976-01-09T01:46:40Z | t2 | +| 2021-01-01T00:00:10Z | 1971-04-08T23:06:40Z | t2 | +| 2021-01-01T00:00:20Z | 1969-01-18T18:40:00Z | t2 | +| 2021-01-01T00:00:30Z | 1976-01-09T01:46:40Z | t2 | +| 2021-01-01T00:00:40Z | 1974-02-13T15:06:40Z | t2 | +| 2021-01-01T00:00:50Z | 1970-04-26T17:46:40Z | t2 | -| _time | tag | _value | -| :------------------- | :-- | -------------------: | -| 2021-01-01T00:00:00Z | t2 | 1970-01-01T00:00:19Z | -| 2021-01-01T00:00:10Z | t2 | 1970-01-01T00:00:04Z | -| 2021-01-01T00:00:20Z | t2 | 1969-12-31T23:59:57Z | -| 2021-01-01T00:00:30Z | t2 | 1970-01-01T00:00:19Z | -| 2021-01-01T00:00:40Z | t2 | 1970-01-01T00:00:13Z | -| 2021-01-01T00:00:50Z | t2 | 1970-01-01T00:00:01Z | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/touint.md b/content/flux/v0.x/stdlib/universe/touint.md index 25765b98f..3f997aed1 100644 --- a/content/flux/v0.x/stdlib/universe/touint.md +++ b/content/flux/v0.x/stdlib/universe/touint.md @@ -1,68 +1,72 @@ --- title: toUInt() function -description: The `toUInt()` function converts all values in the `_value` column to UIntegers. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/touint - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/touint/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/touint/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/touint/ +description: > + `toUInt()` converts all values in the `_value` column to unsigned integer types. menu: flux_0_x_ref: name: toUInt parent: universe -weight: 102 -flux/v0.x/tags: [type-conversions, transformations] -related: - - /flux/v0.x/data-types/basic/uint/ - - /flux/v0.x/stdlib/universe/uint/ + identifier: universe/toUInt +weight: 101 +flux/v0.x/tags: [transformations, type-conversions] introduced: 0.7.0 --- -The `toUInt()` function converts all values in the `_value` column to UIntegers. + + +`toUInt()` converts all values in the `_value` column to unsigned integer types. + +#### Supported types and behaviors +`toUInt()` behavior depends on the `_value` column type: + +| _value type | Returned value | +| :---------- | :---------------------------------------------- | +| string | UInteger equivalent of the numeric string | +| bool | 1 (true) or 0 (false) | +| duration | Number of nanoseconds in the specified duration | +| time | Equivalent nanosecond epoch timestamp | +| float | Value truncated at the decimal | +| int | UInteger equivalent of the integer | + +##### Function type signature ```js -toUInt() +(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: uint}] ``` -{{% note %}} -To convert values in a column other than `_value`, use `map()` and `uint()` -as shown in [this example](/flux/v0.x/stdlib/universe/uint/#convert-all-values-in-a-column-to-uinteger-values). -{{% /note %}} - -##### Supported data types - -- bool -- duration -- float -- int -- string (numeric) -- time - -`toInt()` behavior depends on the `_value` column data type: - -| \_value type | Returned value | -| :----------- | :-------------------------------------------------------------- | -| bool | 1 (true) or 0 (false) | -| duration | Number of nanoseconds in the specified duration | -| float | UInteger equivalent of the float value truncated at the decimal | -| int | UInteger equivalent of the integer | -| string | UInteger equivalent of the numeric string | -| time | Equivalent nanosecond epoch timestamp | +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro plural=true %}} -- [Convert a float value column to a uinteger column](#convert-a-float-value-column-to-a-uinteger-column) -- [Convert a boolean value column to a uinteger column](#convert-a-boolean-value-column-to-a-uinteger-column) -- [Convert a uinteger value column to a integer column](#convert-a-uinteger-value-column-to-a-integer-column) +- [Convert a float _value column to uintegers](#convert-a-float-_value-column-to-uintegers) +- [Convert a boolean _value column to uintegers](#convert-a-boolean-_value-column-to-uintegers) +- [Convert a uinteger _value column to an uintegers](#convert-a-uinteger-_value-column-to-an-uintegers) + +### Convert a float _value column to uintegers -#### Convert a float value column to a uinteger column ```js import "sampledata" @@ -71,25 +75,54 @@ sampledata.float() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "float" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | -2.18 | +| 2021-01-01T00:00:10Z | t1 | 10.92 | +| 2021-01-01T00:00:20Z | t1 | 7.35 | +| 2021-01-01T00:00:30Z | t1 | 17.53 | +| 2021-01-01T00:00:40Z | t1 | 15.23 | +| 2021-01-01T00:00:50Z | t1 | 4.43 | -##### Output data -{{% flux/sample "uint" %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | 19.85 | +| 2021-01-01T00:00:10Z | t2 | 4.97 | +| 2021-01-01T00:00:20Z | t2 | -3.75 | +| 2021-01-01T00:00:30Z | t2 | 19.77 | +| 2021-01-01T00:00:40Z | t2 | 13.86 | +| 2021-01-01T00:00:50Z | t2 | 1.86 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Convert a boolean value column to a uinteger column +### Convert a boolean _value column to uintegers + ```js import "sampledata" @@ -98,25 +131,54 @@ sampledata.bool() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "bool" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t1 | true | +| 2021-01-01T00:00:10Z | t1 | true | +| 2021-01-01T00:00:20Z | t1 | false | +| 2021-01-01T00:00:30Z | t1 | true | +| 2021-01-01T00:00:40Z | t1 | false | +| 2021-01-01T00:00:50Z | t1 | false | -##### Output data -{{% flux/sample "numericBool" %}} +| _time | *tag | _value | +| -------------------- | ---- | ------- | +| 2021-01-01T00:00:00Z | t2 | false | +| 2021-01-01T00:00:10Z | t2 | true | +| 2021-01-01T00:00:20Z | t2 | false | +| 2021-01-01T00:00:30Z | t2 | true | +| 2021-01-01T00:00:40Z | t2 | true | +| 2021-01-01T00:00:50Z | t2 | false | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | t1 | +| 2021-01-01T00:00:10Z | 1 | t1 | +| 2021-01-01T00:00:20Z | 0 | t1 | +| 2021-01-01T00:00:30Z | 1 | t1 | +| 2021-01-01T00:00:40Z | 0 | t1 | +| 2021-01-01T00:00:50Z | 0 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 0 | t2 | +| 2021-01-01T00:00:10Z | 1 | t2 | +| 2021-01-01T00:00:20Z | 0 | t2 | +| 2021-01-01T00:00:30Z | 1 | t2 | +| 2021-01-01T00:00:40Z | 1 | t2 | +| 2021-01-01T00:00:50Z | 0 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} -#### Convert a uinteger value column to a integer column +### Convert a uinteger _value column to an uintegers + ```js import "sampledata" @@ -125,20 +187,48 @@ sampledata.uint() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "uint" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -{{% flux/sample "int" %}} +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/tripleema.md b/content/flux/v0.x/stdlib/universe/tripleema.md index d2a16daac..b06e36c89 100644 --- a/content/flux/v0.x/stdlib/universe/tripleema.md +++ b/content/flux/v0.x/stdlib/universe/tripleema.md @@ -1,62 +1,78 @@ --- title: tripleEMA() function description: > - The `tripleEMA()` function calculates the exponential moving average of values - grouped into `n` number of points, giving more weight to recent data with less lag - than `exponentialMovingAverage()` and `doubleEMA()`. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleema/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/tripleema/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/tripleema/ + `tripleEMA()` returns the triple exponential moving average (TEMA) of values in + the `_value` column. menu: flux_0_x_ref: name: tripleEMA parent: universe -weight: 102 + identifier: universe/tripleEMA +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/movingaverage/ - - /flux/v0.x/stdlib/universe/doubleema/ - - /flux/v0.x/stdlib/universe/timedmovingaverage/ - - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#triple-exponential-moving-average, InfluxQL TRIPLE_EXPONENTIAL_MOVING_AVERAGE() introduced: 0.38.0 --- -The `tripleEMA()` function calculates the exponential moving average of values in -the `_value` column grouped into `n` number of points, giving more weight to recent -data with less lag than -[`exponentialMovingAverage()`](/flux/v0.x/stdlib/universe/exponentialmovingaverage/) -and [`doubleEMA()`](/flux/v0.x/stdlib/universe/doubleema/). + + +`tripleEMA()` returns the triple exponential moving average (TEMA) of values in +the `_value` column. + +`tripleEMA` uses `n` number of points to calculate the TEMA, giving more +weight to recent data with less lag than `exponentialMovingAverage()` and +`doubleEMA()`. + +#### Triple exponential moving average rules +- A triple exponential moving average is defined as `tripleEMA = (3 * EMA_1) - (3 * EMA_2) + EMA_3`. + - `EMA_1` is the exponential moving average of the original data. + - `EMA_2` is the exponential moving average of `EMA_1`. + - `EMA_3` is the exponential moving average of `EMA_2`. +- A true triple exponential moving average requires at least requires at least + `3 * n - 2` values. If not enough values exist to calculate the TEMA, it + returns a `NaN` value. +- `tripleEMA()` inherits all `exponentialMovingAverage()` rules. + +##### Function type signature ```js -tripleEMA(n: 5) +(<-tables: stream[{A with _value: B}], n: int) => stream[C] where B: Numeric, C: Record ``` -##### Triple exponential moving average rules -- A triple exponential moving average is defined as `tripleEMA = (3 * EMA_1) - (3 * EMA_2) + EMA_3`. - - `EMA_1` is the exponential moving average of the original data. - - `EMA_2` is the exponential moving average of `EMA_1`. - - `EMA_3` is the exponential moving average of `EMA_2`. -- A true triple exponential moving average requires at least requires at least `3 * n - 2` values. - If not enough values exist to calculate the triple EMA, it returns a `NaN` value. -- `tripleEMA()` inherits all [exponential moving average rules](/flux/v0.x/stdlib/universe/exponentialmovingaverage/#exponential-moving-average-rules). +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n ({{< req >}}) -Number of points to average. +Number of points to use in the calculation. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} -#### Calculate a three point triple exponential moving average +### Calculate a three point triple exponential moving average + ```js import "sampledata" @@ -65,26 +81,38 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:50Z | t1 | 7.6250000000000036 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | _value | -| :------------------- | :-- | -----------------: | -| 2021-01-01T00:00:50Z | t2 | 4.0729166666666625 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:50Z | 7.6250000000000036 | t1 | + +| _time | _value | *tag | +| -------------------- | ------------------ | ---- | +| 2021-01-01T00:00:50Z | 4.0729166666666625 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/tripleexponentialderivative.md b/content/flux/v0.x/stdlib/universe/tripleexponentialderivative.md index 0de7f3194..ca0a69370 100644 --- a/content/flux/v0.x/stdlib/universe/tripleexponentialderivative.md +++ b/content/flux/v0.x/stdlib/universe/tripleexponentialderivative.md @@ -1,42 +1,44 @@ --- title: tripleExponentialDerivative() function description: > - The `tripleExponentialDerivative()` function calculates a triple exponential - derivative (TRIX) of input tables using `n` points. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleexponentialderivative/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleexponentialderivative/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/tripleexponentialderivative/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/tripleexponentialderivative/ + `tripleExponentialDerivative()` returns the triple exponential derivative (TRIX) + values using `n` points. menu: flux_0_x_ref: name: tripleExponentialDerivative parent: universe -weight: 102 + identifier: universe/tripleExponentialDerivative +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/movingaverage/ - - /flux/v0.x/stdlib/universe/doubleema/ - - /flux/v0.x/stdlib/universe/tripleema/ - - /flux/v0.x/stdlib/universe/timedmovingaverage/ - - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ - - /{{< latest "influxdb" "v1" >}}/query_language/functions/#triple-exponential-derivative, InfluxQL TRIPLE_EXPONENTIAL_DERIVATIVE() introduced: 0.40.0 --- -The `tripleExponentialDerivative()` function calculates a triple exponential -derivative ([TRIX](https://en.wikipedia.org/wiki/Trix_(technical_analysis))) of -input tables using `n` points. + + +`tripleExponentialDerivative()` returns the triple exponential derivative (TRIX) +values using `n` points. + +Triple exponential derivative, commonly referred to as “[TRIX](https://en.wikipedia.org/wiki/Trix_(technical_analysis)),” +is a momentum indicator and oscillator. A triple exponential derivative uses +the natural logarithm (log) of input data to calculate a triple exponential +moving average over the period of time. The calculation prevents cycles +shorter than the defined period from being considered by the indicator. +`tripleExponentialDerivative()` uses the time between `n` points to define +the period. Triple exponential derivative oscillates around a zero line. A positive momentum **oscillator** value indicates an overbought market; @@ -44,30 +46,44 @@ a negative value indicates an oversold market. A positive momentum **indicator** value indicates increasing momentum; a negative value indicates decreasing momentum. -##### Triple exponential moving average rules +#### Triple exponential moving average rules - A triple exponential derivative is defined as: - - `TRIX[i] = ((EMA3[i] / EMA3[i - 1]) - 1) * 100`: - - `EMA_3 = EMA(EMA(EMA(data)))` + - `TRIX[i] = ((EMA3[i] / EMA3[i - 1]) - 1) * 100` + - `EMA3 = EMA(EMA(EMA(data)))` - If there are not enough values to calculate a triple exponential derivative, - the output `_value` is `NaN`; all other columns are the same as the _last_ record of the input table. -- The function behaves the same way as the [`exponentialMovingAverage()`](/flux/v0.x/stdlib/universe/exponentialmovingaverage/) function: - - The function does not include `null` values in the calculation. - - The function acts only on the `_value` column. + the output `_value` is `NaN`; all other columns are the same as the last + record of the input table. +- The function behaves the same way as the `exponentialMovingAverage()` function: + - The function ignores `null` values. + - The function operates only on the `_value` column. + +##### Function type signature + +```js +(<-tables: stream[{A with _value: B}], n: int) => stream[{A with _value: float}] where A: Record, B: Numeric +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### n {data-type="int"} +### n ({{< req >}}) Number of points to use in the calculation. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). + + +### tables + +Input data. Default is piped-forward data (`<-`). + + + ## Examples -{{% flux/sample-example-intro %}} -#### Calculate a two point triple exponential derivative +### Calculate a two-point triple exponential derivative + ```js import "sampledata" @@ -75,29 +91,3 @@ sampledata.float() |> tripleExponentialDerivative(n: 2) ``` -{{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} - -##### Input data -{{% flux/sample "int" %}} - -{{% /flex-content %}} -{{% flex-content %}} - -##### Output data -| tag | _time | _value | -| :-- | :------------------- | ------------------: | -| t1 | 2021-01-01T00:00:40Z | 46.03174603174607 | -| t1 | 2021-01-01T00:00:50Z | -11.666666666666647 | - -| tag | _time | _value | -| :-- | :------------------- | ------------------: | -| t2 | 2021-01-01T00:00:40Z | 26.675945256321064 | -| t2 | 2021-01-01T00:00:50Z | -22.205945187084176 | - -{{% /flex-content %}} -{{< /flex >}} -{{% /expand %}} -{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/truncatetimecolumn.md b/content/flux/v0.x/stdlib/universe/truncatetimecolumn.md index 8ab9781bc..8f6a2c161 100644 --- a/content/flux/v0.x/stdlib/universe/truncatetimecolumn.md +++ b/content/flux/v0.x/stdlib/universe/truncatetimecolumn.md @@ -1,87 +1,136 @@ --- title: truncateTimeColumn() function description: > - The `truncateTimeColumn()` function truncates all input table `_time` values to a specified unit. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/truncatetimecolumn/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/truncatetimecolumn/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/truncatetimecolumn/ + `truncateTimeColumn()` truncates all input time values in the `_time` to a + specified unit. menu: flux_0_x_ref: name: truncateTimeColumn parent: universe -weight: 102 + identifier: universe/truncateTimeColumn +weight: 101 flux/v0.x/tags: [transformations, date/time] -related: - - /flux/v0.x/stdlib/date/truncate/ introduced: 0.37.0 --- -The `truncateTimeColumn()` function truncates all input table `_time` values to a specified unit. + + +`truncateTimeColumn()` truncates all input time values in the `_time` to a +specified unit. + +#### Truncate to weeks +When truncating a time value to the week (`1w`), weeks are determined using the +**Unix epoch (1970-01-01T00:00:00Z UTC)**. The Unix epoch was on a Thursday, +so all calculated weeks begin on Thursday. + +##### Function type signature ```js -truncateTimeColumn(unit: 1s) +(<-tables: stream[{B with _time: C}], unit: duration, ?timeColumn: A) => stream[{B with _time: C, _time: time}] where C: Timeable ``` -{{% note %}} -#### Truncate to weeks -When truncating a time value to the week (`1w`), weeks are determined using the -**Unix epoch (1970-01-01T00:00:00Z UTC)**. The Unix epoch was on a Thursday, so -all calculated weeks begin on Thursday. -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### unit {data-type="duration"} -The unit of time to truncate to. +### unit +({{< req >}}) +Unit of time to truncate to. + +**Example units:** +- 1ns (nanosecond) +- 1us (microsecond) +- 1ms (millisecond) +- 1s (second) +- 1m (minute) +- 1h (hour) +- 1d (day) +- 1w (week) +- 1mo (month) +- 1y (year) + +### timeColumn + +Time column to truncate. Default is `_time`. + +**Note:** Currently, assigning a custom value to this parameter will have +no effect. + +### tables + +Input data. Default is piped-forward data (`<-`). + -{{% note %}} -Only use `1` and the unit of time to specify the `unit`. -For example: `1s`, `1m`, `1h`. -{{% /note %}} -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} -##### Truncate all time values to minutes +### Truncate all time values to the minute + ```js import "sampledata" -data = sampledata.int() - |> range(start: sampledata.start, stop: sampledata.stop) - -data +sampledata.int() |> truncateTimeColumn(unit: 1m) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" includeRange=true %}} +#### Input data -##### Output data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | 10 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | 7 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | 17 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | 15 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t1 | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | 4 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | -3 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | 13 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | t2 | 1 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 17 | t1 | +| 2021-01-01T00:00:00Z | 15 | t1 | +| 2021-01-01T00:00:00Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 4 | t2 | +| 2021-01-01T00:00:00Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 1 | t2 | {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/uint.md b/content/flux/v0.x/stdlib/universe/uint.md index 54ab3b0ce..6eccce9d7 100644 --- a/content/flux/v0.x/stdlib/universe/uint.md +++ b/content/flux/v0.x/stdlib/universe/uint.md @@ -1,32 +1,34 @@ --- title: uint() function -description: The `uint()` function converts a single value to a UInteger. -aliases: - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/uint/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/uint/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/uint/ +description: > + `uint()` converts a value to an unsigned integer type. menu: flux_0_x_ref: name: uint parent: universe -weight: 102 + identifier: universe/uint +weight: 101 flux/v0.x/tags: [type-conversions] -related: - - /flux/v0.x/data-types/basic/uint/ - - /flux/v0.x/stdlib/universe/touint/ introduced: 0.7.0 --- -The `uint()` function converts a single value to a UInteger. + + +`uint()` converts a value to an unsigned integer type. `uint()` behavior depends on the input data type: @@ -39,111 +41,102 @@ The value to convert. | string | UInteger equivalent of the numeric string | | time | Equivalent nanosecond epoch timestamp | +##### Function type signature + +```js +(v: A) => uint +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### v +({{< req >}}) +Value to convert. + + + + ## Examples -- [Convert a string to a uinteger value](#convert-a-string-to-a-uinteger-value) -- [Convert a boolean to a uinteger value](#convert-a-boolean-to-a-uinteger-value) -- [Convert a duration to a uinteger value](#convert-a-duration-to-a-uinteger-value) -- [Convert a time to a uinteger value](#convert-a-time-to-a-uinteger-value) -- [Convert a float to a uinteger value](#convert-a-float-to-a-uinteger-value) -- [Convert all values in a column to uinteger values](#convert-all-values-in-a-column-to-uinteger-values) +- [Convert basic types to unsigned integers](#convert-basic-types-to-unsigned-integers) +- [Convert all values in a column to unsigned integers](#convert-all-values-in-a-column-to-unsigned-integers) + +### Convert basic types to unsigned integers -#### Convert a string to a uinteger value ```js uint(v: "3") -// Returns 3 (uint) -``` - -#### Convert a boolean to a uinteger value -```js -uint(v: true) - -// Returns 1 -``` - -#### Convert a duration to a uinteger value -```js +// Returns 3 uint(v: 1m) // Returns 160000000000 -``` +uint(v: 2022-01-01T00:00:00Z) -#### Convert a time to a uinteger value -```js -uint(v: 2021-01-01T00:00:00Z) - -// Returns 1609459200000000000 -``` - -#### Convert a float to a uinteger value -```js +// Returns 1640995200000000000 uint(v: 10.12) // Returns 10 +uint(v: -100)// Returns 18446744073709551516 + ``` -#### Convert all values in a column to uinteger values -If updating values in the `_value` column, use [`toUInt()`](/flux/v0.x/stdlib/universe/touint/). -To update values in columns other than `_value`: -1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows. -2. Use `uint()` to update the value of a column. +### Convert all values in a column to unsigned integers -_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._ +If converting the `_value` column to uint types, use `toUInt()`. +If converting columns other than `_value`, use `map()` to iterate over each +row and `uint()` to covert a column value to a uint type. ```js -import "sampledata" - -data = sampledata.float() - |> rename(columns: {_value: "foo"}) - data - |> map(fn: (r) => ({r with foo: uint(v: r.foo)})) + |> map(fn: (r) => ({r with exampleCol: uint(v: r.exampleCol)})) ``` -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} -##### Input data -| tag | _time | foo | -| :-- | :------------------- | ----: | -| t1 | 2021-01-01T00:00:00Z | -2.18 | -| t1 | 2021-01-01T00:00:10Z | 10.92 | -| t1 | 2021-01-01T00:00:20Z | 7.35 | -| t1 | 2021-01-01T00:00:30Z | 17.53 | -| t1 | 2021-01-01T00:00:40Z | 15.23 | -| t1 | 2021-01-01T00:00:50Z | 4.43 | +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} -| tag | _time | foo | -| :-- | :------------------- | ----: | -| t2 | 2021-01-01T00:00:00Z | 19.85 | -| t2 | 2021-01-01T00:00:10Z | 4.97 | -| t2 | 2021-01-01T00:00:20Z | -3.75 | -| t2 | 2021-01-01T00:00:30Z | 19.77 | -| t2 | 2021-01-01T00:00:40Z | 13.86 | -| t2 | 2021-01-01T00:00:50Z | 1.86 | +#### Input data -{{% /flex-content %}} -{{% flex-content %}} -##### Output data -| _time | tag | foo | -| :------------------- | :-- | -------------------: | -| 2021-01-01T00:00:00Z | t1 | 18446744073709551614 | -| 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:50Z | t1 | 4 | +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | exampleCol | *tag | +| -------------------- | ----------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + + +#### Output data + +| _time | exampleCol | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 18446744073709551614 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | exampleCol | *tag | +| -------------------- | -------------------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | 18446744073709551613 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| _time | tag | foo | -| :------------------- | :-- | -------------------: | -| 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:20Z | t2 | 18446744073709551613 | -| 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:50Z | t2 | 1 | -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/union.md b/content/flux/v0.x/stdlib/universe/union.md index ad7797a92..7b52cd701 100644 --- a/content/flux/v0.x/stdlib/universe/union.md +++ b/content/flux/v0.x/stdlib/universe/union.md @@ -1,259 +1,140 @@ --- title: union() function -description: The `union()` function concatenates two or more input streams into a single output stream. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/union - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/union/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/union/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/union/ +description: > + `union()` merges two or more input streams into a single output stream. menu: flux_0_x_ref: name: union parent: universe -weight: 102 + identifier: universe/union +weight: 101 flux/v0.x/tags: [transformations] -related: - - /flux/v0.x/stdlib/universe/join/ introduced: 0.7.0 --- -The `union()` function concatenates two or more input streams into a single output stream. -In tables that have identical schemas and group keys, contents of the tables will be concatenated in the output stream. -The output schemas of the `union()` function is the union of all input schemas. + + +`union()` merges two or more input streams into a single output stream. + +The output schemas of `union()` is the union of all input schemas. `union()` does not preserve the sort order of the rows within tables. -A sort operation may be added if a specific sort order is needed. +Use `sort()` if you need a specific sort order. + +### Union vs join +`union()` does not modify data in rows, but unions separate streams of tables +into a single stream of tables and groups rows of data based on existing group keys. +`join()` creates new rows based on common values in one or more specified columns. +Output rows also contain the differing values from each of the joined streams. + +##### Function type signature ```js -union(tables: [table1, table2]) +(tables: [stream[A]]) => stream[A] where A: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -### tables {data-type="array of streams"} -Specifies the streams to union together. -There must be at least two streams. +### tables +({{< req >}}) +List of two or more streams of tables to union together. + + + ## Examples -The following examples use [`generate.from()`](/flux/v0.x/stdlib/generate/from/) -to illustrate how `union()` transforms data. - [Union two streams of tables with unique group keys](#union-two-streams-of-tables-with-unique-group-keys) - [Union two streams of tables with empty group keys](#union-two-streams-of-tables-with-empty-group-keys) ### Union two streams of tables with unique group keys + ```js import "generate" -t1 = generate.from(count: 4, fn: (n) => n + 1, start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) - |> set(key: "tag", value: "foo") - |> group(columns: ["tag"]) +t1 = + generate.from(count: 4, fn: (n) => n + 1, start: 2022-01-01T00:00:00Z, stop: 2022-01-05T00:00:00Z) + |> set(key: "tag", value: "foo") + |> group(columns: ["tag"]) -t2 = generate.from(count: 4, fn: (n) => n * -1, start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) - |> set(key: "tag", value: "bar") - |> group(columns: ["tag"]) +t2 = + generate.from(count: 4, fn: (n) => n * (-1), start: 2022-01-01T00:00:00Z, stop: 2022-01-05T00:00:00Z) + |> set(key: "tag", value: "bar") + |> group(columns: ["tag"]) union(tables: [t1, t2]) ``` {{< expand-wrapper >}} -{{% expand "View input and output streams" %}} -#### Input data streams +{{% expand "View example output" %}} -{{< flex >}} -{{% flex-content %}} +#### Output data -##### t1 +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2022-01-01T00:00:00Z | 0 | bar | +| 2022-01-02T00:00:00Z | -1 | bar | +| 2022-01-03T00:00:00Z | -2 | bar | +| 2022-01-04T00:00:00Z | -3 | bar | -{{< flux/group-key "[tag: \"foo\"]">}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2022-01-01T00:00:00Z | 1 | foo | +| 2022-01-02T00:00:00Z | 2 | foo | +| 2022-01-03T00:00:00Z | 3 | foo | +| 2022-01-04T00:00:00Z | 4 | foo | -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 1 | -| 2021-01-02T00:00:00Z | foo | 2 | -| 2021-01-03T00:00:00Z | foo | 3 | -| 2021-01-04T00:00:00Z | foo | 4 | - -{{% /flex-content %}} -{{% flex-content %}} - -##### t2 - -{{< flux/group-key "[tag: \"bar\"]">}} - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | bar | 0 | -| 2021-01-02T00:00:00Z | bar | -1 | -| 2021-01-03T00:00:00Z | bar | -2 | -| 2021-01-04T00:00:00Z | bar | -3 | - -{{% /flex-content %}} -{{< /flex >}} - -#### Output data stream -{{% caption %}} -A single stream of tables -{{% /caption %}} - -{{< flex >}} -{{% flex-content %}} - -{{< flux/group-key "[tag: \"foo\"]">}} - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 1 | -| 2021-01-02T00:00:00Z | foo | 2 | -| 2021-01-03T00:00:00Z | foo | 3 | -| 2021-01-04T00:00:00Z | foo | 4 | - -{{% /flex-content %}} -{{% flex-content %}} - -{{< flux/group-key "[tag: \"bar\"]">}} - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | bar | 0 | -| 2021-01-02T00:00:00Z | bar | -1 | -| 2021-01-03T00:00:00Z | bar | -2 | -| 2021-01-04T00:00:00Z | bar | -3 | - -{{% /flex-content %}} -{{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}} ### Union two streams of tables with empty group keys + ```js import "generate" -t1 = generate.from(count: 4, fn: (n) => n + 1, start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) - |> set(key: "tag", value: "foo") - |> group() +t1 = + generate.from(count: 4, fn: (n) => n + 1, start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) + |> set(key: "tag", value: "foo") + |> group() -t2 = generate.from(count: 4, fn: (n) => n * -1, start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) - |> set(key: "tag", value: "bar") - |> group() +t2 = + generate.from(count: 4, fn: (n) => n * (-1), start: 2021-01-01T00:00:00Z, stop: 2021-01-05T00:00:00Z) + |> set(key: "tag", value: "bar") + |> group() union(tables: [t1, t2]) ``` {{< expand-wrapper >}} -{{% expand "View input and output streams" %}} -#### Input data streams +{{% expand "View example output" %}} -{{< flex >}} -{{% flex-content %}} +#### Output data -##### t1 +| _time | _value | tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 1 | foo | +| 2021-01-02T00:00:00Z | 2 | foo | +| 2021-01-03T00:00:00Z | 3 | foo | +| 2021-01-04T00:00:00Z | 4 | foo | +| 2021-01-01T00:00:00Z | 0 | bar | +| 2021-01-02T00:00:00Z | -1 | bar | +| 2021-01-03T00:00:00Z | -2 | bar | +| 2021-01-04T00:00:00Z | -3 | bar | -{{< flux/group-key "[]">}} - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 1 | -| 2021-01-02T00:00:00Z | foo | 2 | -| 2021-01-03T00:00:00Z | foo | 3 | -| 2021-01-04T00:00:00Z | foo | 4 | - -{{% /flex-content %}} -{{% flex-content %}} - -##### t2 - -{{< flux/group-key "[]">}} - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | bar | 0 | -| 2021-01-02T00:00:00Z | bar | -1 | -| 2021-01-03T00:00:00Z | bar | -2 | -| 2021-01-04T00:00:00Z | bar | -3 | - -{{% /flex-content %}} -{{< /flex >}} - -#### Output data stream - -{{< flux/group-key "[]">}} - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 1 | -| 2021-01-02T00:00:00Z | foo | 2 | -| 2021-01-03T00:00:00Z | foo | 3 | -| 2021-01-04T00:00:00Z | foo | 4 | -| 2021-01-01T00:00:00Z | bar | 0 | -| 2021-01-02T00:00:00Z | bar | -1 | -| 2021-01-03T00:00:00Z | bar | -2 | -| 2021-01-04T00:00:00Z | bar | -3 | {{% /expand %}} {{< /expand-wrapper >}} - -## union() versus join() -`union()` merges separate streams of tables into a single stream of tables and -groups rows of data based on existing [group keys](/flux/v0.x/get-started/data-model/#group-key). -`union()` does not modify individual rows of data. -`join()` creates new rows based on common values in one or more specified columns. -Output rows also contain the differing values from each of the joined streams. - -{{% expand "View union() vs join() example" %}} -Given two streams of tables, `t1` and `t2`, the results of `union()` and `join()` -are illustrated below: - -#### Input streams - -{{< flex >}} -{{% flex-content %}} - -##### t1 - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 1 | -| 2021-01-02T00:00:00Z | foo | 2 | -| 2021-01-03T00:00:00Z | foo | 3 | -| 2021-01-04T00:00:00Z | foo | 4 | -{{% /flex-content %}} -{{% flex-content %}} -##### t2 - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 0 | -| 2021-01-02T00:00:00Z | foo | -1 | -| 2021-01-03T00:00:00Z | foo | -2 | -| 2021-01-04T00:00:00Z | foo | -3 | -{{% /flex-content %}} -{{< /flex >}} - -#### union() output -```js -union(tables: [t1, t2]) -``` - -| _time | tag | _value | -| :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | foo | 0 | -| 2021-01-02T00:00:00Z | foo | -1 | -| 2021-01-03T00:00:00Z | foo | -2 | -| 2021-01-04T00:00:00Z | foo | -3 | -| 2021-01-01T00:00:00Z | foo | 1 | -| 2021-01-02T00:00:00Z | foo | 2 | -| 2021-01-03T00:00:00Z | foo | 3 | -| 2021-01-04T00:00:00Z | foo | 4 | - -#### join() output -```js -join(tables: {t1: t1, t2: t2}, on: ["_time", "tag"]) -``` - -| _time | tag | _value_t1 | _value_t2 | -| :------------------- | :-- | --------: | --------: | -| 2021-01-01T00:00:00Z | foo | 1 | 0 | -| 2021-01-02T00:00:00Z | foo | 2 | -1 | -| 2021-01-03T00:00:00Z | foo | 3 | -2 | -| 2021-01-04T00:00:00Z | foo | 4 | -3 | -{{% /expand %}} diff --git a/content/flux/v0.x/stdlib/universe/unique.md b/content/flux/v0.x/stdlib/universe/unique.md index b365e0a2f..58e896149 100644 --- a/content/flux/v0.x/stdlib/universe/unique.md +++ b/content/flux/v0.x/stdlib/universe/unique.md @@ -1,45 +1,64 @@ --- title: unique() function -description: The `unique()` function returns all records containing unique values in a specified column. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/selectors/unique - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/unique/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/unique/ +description: > + `unique()` returns all records containing unique values in a specified column. menu: flux_0_x_ref: name: unique parent: universe -weight: 102 -flux/v0.x/tags: [selectors, transformations] + identifier: universe/unique +weight: 101 +flux/v0.x/tags: [transformations, selectors] introduced: 0.7.0 --- -The `unique()` function returns all records containing unique values in a specified column. -Group keys, record columns, and values are **not** modified. -_`unique()` is a [selector function](/flux/v0.x/function-types/#selectors)._ + + +`unique()` returns all records containing unique values in a specified column. + +Group keys, columns, and values are not modified. +`unique()` drops empty tables. + +##### Function type signature ```js -unique(column: "_value") +(<-tables: stream[A], ?column: string) => stream[A] where A: Record ``` -{{% warn %}} -#### Empty tables -`unique()` drops empty tables. -{{% /warn %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### column {data-type="string"} -Column to search for unique values. -Defaults to `"_value"`. +### column + +Column to search for unique values. Default is `_value`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro %}} + +### Return unique values from input tables ```js import "sampledata" @@ -49,35 +68,47 @@ sampledata.int() ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} -{{< flex >}} -{{% flex-content %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample "int" %}} +#### Input data -{{% /flex-content %}} -{{% flex-content %}} +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | -##### Output data -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t1 | 2021-01-01T00:00:00Z | -2 | -| t1 | 2021-01-01T00:00:10Z | 10 | -| t1 | 2021-01-01T00:00:20Z | 7 | -| t1 | 2021-01-01T00:00:30Z | 17 | -| t1 | 2021-01-01T00:00:40Z | 15 | -| t1 | 2021-01-01T00:00:50Z | 4 | +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | -| tag | _time | _value | -| :-- | :------------------- | -----: | -| t2 | 2021-01-01T00:00:00Z | 19 | -| t2 | 2021-01-01T00:00:10Z | 4 | -| t2 | 2021-01-01T00:00:20Z | -3 | -| t2 | 2021-01-01T00:00:40Z | 13 | -| t2 | 2021-01-01T00:00:50Z | 1 | -{{% /flex-content %}} -{{< /flex >}} +#### Output data + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:50Z | 4 | t1 | + +| _time | _value | *tag | +| -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:50Z | 1 | t2 | + {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/window.md b/content/flux/v0.x/stdlib/universe/window.md index c35e179e5..5ad268e41 100644 --- a/content/flux/v0.x/stdlib/universe/window.md +++ b/content/flux/v0.x/stdlib/universe/window.md @@ -1,265 +1,314 @@ --- title: window() function -description: The `window()` function groups records based on a time value. -aliases: - - /influxdb/v2.0/reference/flux/functions/transformations/window - - /influxdb/v2.0/reference/flux/functions/built-in/transformations/window/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/window/ - - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/window/ +description: > + `window()` groups records using regular time intervals. menu: flux_0_x_ref: name: window parent: universe -weight: 102 + identifier: universe/window +weight: 101 flux/v0.x/tags: [transformations] -related: - - /{{< latest "influxdb" >}}/query-data/flux/window-aggregate/ - - /flux/v0.x/stdlib/built-in/universe/aggregatewindow/ - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-group-by-clause, InfluxQL – GROUP BY time() introduced: 0.7.0 --- -The `window()` function groups records based on a time value. -The function calculates time windows and stores window bounds in the `_start` -and `_stop` columns. -`_start` and `_stop` values are assigned to rows based on the `_time` value. + + +`window()` groups records using regular time intervals. + +The function calculates time windows and stores window bounds in the +`_start` and `_stop` columns. `_start` and `_stop` values are assigned to +rows based on the row's `_time` value. A single input row may be placed into zero or more output tables depending on -the parameters passed into the `window()` function. +the parameters passed into `window()`. + +#### Window by calendar months and years +`every`, `period`, and `offset` parameters support all valid duration units, +including calendar months (`1mo`) and years (`1y`). + +#### Window by week +When windowing by week (`1w`), weeks are determined using the Unix epoch +(1970-01-01T00:00:00Z UTC). The Unix epoch was on a Thursday, so all +calculated weeks begin on Thursday. + +##### Function type signature ```js -window( - every: 5m, - period: 5m, - offset: 12h, - timeColumn: "_time", - startColumn: "_start", - stopColumn: "_stop", - location: "UTC", - createEmpty: false, -) +( + <-tables: stream[A], + ?createEmpty: bool, + ?every: duration, + ?location: {zone: string, offset: duration}, + ?offset: duration, + ?period: duration, + ?startColumn: string, + ?stopColumn: string, + ?timeColumn: string, +) => stream[B] where A: Record, B: Record ``` +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + ## Parameters -{{% note %}} -#### Calendar months and years -`every`, `period`, and `offset` support all [valid duration units](/flux/v0.x/spec/types/#duration-types), -including **calendar months (`1mo`)** and **years (`1y`)**. +### every -#### Window by week -When windowing by week (`1w`), weeks are determined using the -**Unix epoch (1970-01-01T00:00:00Z UTC)**. The Unix epoch was on a Thursday, so -all calculated weeks begin on Thursday. -{{% /note %}} - -### every {data-type="duration"} Duration of time between windows. -Defaults to `period` value. -### period {data-type="duration"} -Duration of the window. -Period is the length of each interval. -It can be negative, indicating the start and stop boundaries are reversed. -Defaults to `every` value. -### offset {data-type="duration"} -Offset is the duration by which to shift the window boundaries. -It can be negative, indicating that the offset goes backwards in time. -Defaults to 0, which will align window end boundaries with the `every` duration. -### timeColumn {data-type="string"} -The column containing time. -Defaults to `"_time"`. +### period -### startColumn {data-type="string"} -The column containing the window start time. -Defaults to `"_start"`. +Duration of windows. Default is the `every` value. -### stopColumn {data-type="string"} -The column containing the window stop time. -Defaults to `"_stop"`. +`period` can be negative, indicating the start and stop boundaries are reversed. -### location {data-type="string"} -Location used to determine timezone. -Default is the [`location` option](/flux/v0.x/stdlib/universe/#location). +### offset + +Duration to shift the window boundaries by. Defualt is `0s`. + +`offset` can be negative, indicating that the offset goes backwards in time. + +### location + +Location used to determine timezone. Default is the `location` option. + + + +### timeColumn + +Column that contains time values. Default is `_time`. + + + +### startColumn + +Column to store the window start time in. Default is `_start`. + + + +### stopColumn + +Column to store the window stop time in. Default is `_stop`. + + + +### createEmpty + +Create empty tables for empty window. Default is `false`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). -_Flux uses the timezone database (commonly referred to as "tz" or "zoneinfo") -provided by the operating system._ -### createEmpty {data-type="bool"} -Specifies whether empty tables should be created. -Defaults to `false`. -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples -{{% flux/sample-example-intro plural=true %}} - [Window data into 30 second intervals](#window-data-into-30-second-intervals) - [Window every 20 seconds covering 40 second periods](#window-every-20-seconds-covering-40-second-periods) - [Window by calendar month](#window-by-calendar-month) -#### Window data into 30 second intervals +### Window data into 30 second intervals + ```js -import "sampledata" - -data = sampledata.int() - |> range(start: sampledata.start, stop: sampledata.stop) - data |> window(every: 30s) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" includeRange=true %}} +#### Input data -##### Output data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:20Z | t1 | 7 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t1 | 4 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:20Z | t2 | -3 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t2 | 1 | +#### Output data + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:20Z | 7 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:30Z | 2021-01-01T00:00:20Z | -3 | t2 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:30Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | {{% /expand %}} {{< /expand-wrapper >}} -#### Window every 20 seconds covering 40 second periods +### Window every 20 seconds covering 40 second periods + ```js -import "sampledata" - -data = sampledata.int() - |> range(start: sampledata.start, stop: sampledata.stop) - data |> window(every: 20s, period: 40s) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} +{{% expand "View example input and ouput" %}} -##### Input data -{{% flux/sample set="int" includeRange=true %}} +#### Input data -##### Output data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:20Z | 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:20Z | 2021-01-01T00:00:10Z | t1 | 10 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:00Z | t1 | -2 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:10Z | t1 | 10 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:30Z | t1 | 17 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t1 | 7 | -| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t1 | 17 | -| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t1 | 4 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:40Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t1 | 15 | -| 2021-01-01T00:00:40Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t1 | 4 | +#### Output data -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:20Z | 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:20Z | 2021-01-01T00:00:10Z | t2 | 4 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:20Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:20Z | 2021-01-01T00:00:10Z | 10 | t1 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:00Z | t2 | 19 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:10Z | t2 | 4 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:30Z | t2 | 19 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:20Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:20Z | 2021-01-01T00:00:10Z | 4 | t2 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | t2 | -3 | -| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | t2 | 19 | -| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t2 | 1 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:00Z | -2 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:10Z | 10 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:30Z | 17 | t1 | -| _start | _stop | _time | tag | _value | -| :------------------- | :------------------- | :------------------- | :-- | -----: | -| 2021-01-01T00:00:40Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | t2 | 13 | -| 2021-01-01T00:00:40Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | t2 | 1 | +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:00Z | 19 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:10Z | 4 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:00Z | 2021-01-01T00:00:40Z | 2021-01-01T00:00:30Z | 19 | t2 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 | +| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 | +| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 | +| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 | +| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:20Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:40Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 | +| 2021-01-01T00:00:40Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 | + +| *_start | *_stop | _time | _value | *tag | +| -------------------- | -------------------- | -------------------- | ------- | ---- | +| 2021-01-01T00:00:40Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 | +| 2021-01-01T00:00:40Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 | {{% /expand %}} {{< /expand-wrapper >}} -#### Window by calendar month -The following example uses [`generate.from`](/flux/v0.x/stdlib/generate/from/) -to illustrate windowing by calendar month. +### Window by calendar month ```js -import "generate" - -timeRange = {start: 2021-01-01T00:00:00Z, stop: 2021-04-01T00:00:00Z} - -data = generate.from(count: 6, fn: (n) => n + n, start: timeRange.start, stop: timeRange.stop) - |> range(start: timeRange.start, stop: timeRange.stop) - data |> window(every: 1mo) ``` {{< expand-wrapper >}} -{{% expand "View input and output" %}} +{{% expand "View example input and ouput" %}} -##### Input data -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-01-01T00:00:00Z | 0 | -| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-01-16T00:00:00Z | 2 | -| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-01-31T00:00:00Z | 4 | -| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-02-15T00:00:00Z | 6 | -| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-03-02T00:00:00Z | 8 | -| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-03-17T00:00:00Z | 10 | +#### Input data -##### Output data -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-01T00:00:00Z | 0 | -| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-16T00:00:00Z | 2 | -| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-31T00:00:00Z | 4 | +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-01-01T00:00:00Z | 0 | +| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-01-16T00:00:00Z | 2 | +| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-01-31T00:00:00Z | 4 | +| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-02-15T00:00:00Z | 6 | +| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-03-02T00:00:00Z | 8 | +| 2021-01-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-03-17T00:00:00Z | 10 | -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-15T00:00:00Z | 6 | -| _start | _stop | _time | _value | -| :------------------- | :------------------- | :------------------- | -----: | -| 2021-03-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-03-02T00:00:00Z | 8 | -| 2021-03-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-03-17T00:00:00Z | 10 | +#### Output data + +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-01T00:00:00Z | 0 | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-16T00:00:00Z | 2 | +| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-31T00:00:00Z | 4 | + +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-15T00:00:00Z | 6 | + +| *_start | *_stop | _time | _value | +| -------------------- | -------------------- | -------------------- | ------- | +| 2021-03-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-03-02T00:00:00Z | 8 | +| 2021-03-01T00:00:00Z | 2021-04-01T00:00:00Z | 2021-03-17T00:00:00Z | 10 | {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/universe/yield.md b/content/flux/v0.x/stdlib/universe/yield.md index 3a49daf26..145ae37eb 100644 --- a/content/flux/v0.x/stdlib/universe/yield.md +++ b/content/flux/v0.x/stdlib/universe/yield.md @@ -1,48 +1,74 @@ --- title: yield() function -description: The `yield()` function indicates the input tables received should be delivered as a result of the query. -aliases: - - /influxdb/v2.0/reference/flux/functions/outputs/yield - - /influxdb/v2.0/reference/flux/functions/built-in/outputs/yield/ - - /influxdb/v2.0/reference/flux/stdlib/built-in/outputs/yield/ - - /influxdb/cloud/reference/flux/stdlib/built-in/outputs/yield/ +description: > + `yield()` delivers input data as a result of the query. menu: flux_0_x_ref: name: yield parent: universe -weight: 102 + identifier: universe/yield +weight: 101 flux/v0.x/tags: [outputs] -related: - - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-basic-select-statement, InfluxQL – SELECT AS introduced: 0.7.0 --- -The `yield()` function indicates the input tables received should be delivered as a result of the query. -Yield outputs the input stream unmodified. -A query may have multiple results, each identified by the name provided to the `yield()` function. + + +`yield()` delivers input data as a result of the query. + +A query may have multiple yields, each identified by unique name specified in +the `name` parameter. + +**Note:** `yield()` is implicit for queries that output a single stream of +tables and is only necessary when yielding multiple results from a query. + +##### Function type signature ```js -yield(name: "custom-name") +(<-tables: stream[A], ?name: string) => stream[A] where A: Record ``` -{{% note %}} -`yield()` is implicit for queries that do only one thing and are only needed when using multiple sources in a query. -With multiple sources, `yield()` is required to specify what is returned, and what name to give it. -{{% /note %}} +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} ## Parameters -### name {data-type="string"} -A unique name for the yielded results. -Default is `"_results"`. +### name + +Unique name for the yielded results. Default is `_results`. + + + +### tables + +Input data. Default is piped-forward data (`<-`). + + -### tables {data-type="stream of tables"} -Input data. -Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)). ## Examples + +### Yield multiple results from a query + ```js -from(bucket: "example-bucket") - |> range(start: -5m) - |> yield(name: "result-name") +import "sampledata" + +sampledata.int() + |> yield(name: "unmodified") + |> map(fn: (r) => ({r with _value: r._value * r._value})) + |> yield(name: "squared") ``` + diff --git a/data/flux_stdlib_frontmatter.yml b/data/flux_stdlib_frontmatter.yml new file mode 100644 index 000000000..015d19153 --- /dev/null +++ b/data/flux_stdlib_frontmatter.yml @@ -0,0 +1,3453 @@ +/flux/v0.x/stdlib/array/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/array/ + - /influxdb/cloud/reference/flux/stdlib/experimental/array/ + - /influxdb/v2.0/reference/flux/stdlib/array/ + - /influxdb/cloud/reference/flux/stdlib/array/ + related: + - /flux/v0.x/data-types/composite/array/ + +/flux/v0.x/stdlib/array/from.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/array/from/ + - /influxdb/cloud/reference/flux/stdlib/array/from/ + - /influxdb/v2.0/reference/flux/stdlib/experimental/array/from/ + - /influxdb/cloud/reference/flux/stdlib/experimental/array/from/ + - /flux/v0.x/stdlib/experimental/array/from/ + related: + - /flux/v0.x/data-types/composite/array/ + +/flux/v0.x/stdlib/contrib/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/ + - /influxdb/cloud/reference/flux/stdlib/contrib + +/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/alerta/ + - /influxdb/cloud/reference/flux/stdlib/contrib/alerta/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/alert.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/alerta/alert/ + - /influxdb/cloud/reference/flux/stdlib/contrib/alerta/alert/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/alerta/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/alerta/endpoint/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/hex/bytes.md: | + related: + - /flux/v0.x/data-types/basic/bytes/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/hex/int.md: | + related: + - /flux/v0.x/data-types/basic/int/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/hex/string.md: | + related: + - /flux/v0.x/stdlib/universe/string/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/hex/uint.md: | + related: + - /flux/v0.x/data-types/basic/uint/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/ + - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/alert.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/alert/ + - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/alert/ + related: + - /{{< latest "kapacitor" >}}/nodes/alert_node/, Kapacitor AlertNode + +/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/compute.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/compute/ + - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/compute/ + related: + - /flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/ + - /{{< latest "kapacitor" >}}/nodes/query_node/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/deadman.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/deadman/ + - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/deadman/ + related: + - /{{< latest "kapacitor" >}}/nodes/batch_node/#deadman, Kapacitor BatchNode – Deadman + +/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/definecheck.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/definecheck/ + - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/definecheck/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/groupby.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/groupby/ + - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/groupby/ + related: + - /{{< latest "kapacitor" >}}/nodes/query_node/#groupby, Kapacitor QueryNode - groupBy + +/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/join.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/join/ + - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/join/ + related: + - /{{< latest "kapacitor" >}}/nodes/join_node/, Kapacitor JoinNode + - /flux/v0.x/stdlib/universe/join/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/select/ + - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/select/ + related: + - /flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow/ + - /{{< latest "kapacitor" >}}/nodes/query_node/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/selectwindow/ + - /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/selectwindow/ + related: + - /flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/ + - /{{< latest "kapacitor" >}}/nodes/query_node/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/victorops/ + - /influxdb/cloud/reference/flux/stdlib/contrib/victorops/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/alert.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/victorops/event/ + - /influxdb/cloud/reference/flux/stdlib/contrib/victorops/event/ + - /flux/v0.x/stdlib/contrib/bonitoo-io/victorops/event/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/victorops/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/victorops/endpoint/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/zenoss/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/zenoss/endpoint/ + +/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/event.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/zenoss/event/ + - /influxdb/cloud/reference/flux/stdlib/contrib/zenoss/event/ + +/flux/v0.x/stdlib/contrib/chobbs/discord/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/discord/ + - /influxdb/cloud/reference/flux/stdlib/contrib/discord/ + +/flux/v0.x/stdlib/contrib/chobbs/discord/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/discord/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/discord/endpoint/ + +/flux/v0.x/stdlib/contrib/chobbs/discord/send.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/discord/send/ + - /influxdb/cloud/reference/flux/stdlib/contrib/discord/send/ + +/flux/v0.x/stdlib/contrib/jsternberg/influxdb/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/influxdb/ + - /influxdb/cloud/reference/flux/stdlib/contrib/influxdb/ + +/flux/v0.x/stdlib/contrib/jsternberg/influxdb/select.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/influxdb/select/ + - /influxdb/cloud/reference/flux/stdlib/contrib/influxdb/select/ + related: + - /flux/v0.x/stdlib/influxdata/influxdb/from/ + - /flux/v0.x/stdlib/universe/range/ + - /flux/v0.x/stdlib/universe/filter/ + - /flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols/ + - /flux/v0.x/stdlib/universe/pivot/ + +/flux/v0.x/stdlib/contrib/rhajek/bigpanda/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/ + - /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/ + +/flux/v0.x/stdlib/contrib/rhajek/bigpanda/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/endpoint/ + +/flux/v0.x/stdlib/contrib/rhajek/bigpanda/sendalert.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/sendAlert/ + - /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/sendAlert/ + +/flux/v0.x/stdlib/contrib/rhajek/bigpanda/statusfromlevel.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/statusfromlevel/ + - /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/statusfromlevel/ + +/flux/v0.x/stdlib/contrib/sranka/opsgenie/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/opsgenie/ + - /influxdb/cloud/reference/flux/stdlib/contrib/opsgenie/ + +/flux/v0.x/stdlib/contrib/sranka/opsgenie/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/opsgenie/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/opsgenie/endpoint/ + +/flux/v0.x/stdlib/contrib/sranka/opsgenie/sendalert.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/opsgenie/sendalert/ + - /influxdb/cloud/reference/flux/stdlib/contrib/opsgenie/sendalert/ + +/flux/v0.x/stdlib/contrib/sranka/sensu/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/sensu/ + - /influxdb/cloud/reference/flux/stdlib/contrib/sensu/ + +/flux/v0.x/stdlib/contrib/sranka/sensu/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/sensu/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/sensu/endpoint/ + related: + - https://docs.sensu.io/sensu-go/latest/api/events/, Sensu Events API + - https://docs.sensu.io/sensu-go/latest/api/apikeys/, Sensu APIKeys API + - https://docs.sensu.io/sensu-go/latest/reference/handlers/, Sensu handlers + +/flux/v0.x/stdlib/contrib/sranka/sensu/event.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/sensu/event/ + - /influxdb/cloud/reference/flux/stdlib/contrib/sensu/event/ + related: + - https://docs.sensu.io/sensu-go/latest/api/events/, Sensu Events API + - https://docs.sensu.io/sensu-go/latest/api/apikeys/, Sensu APIKeys API + - https://docs.sensu.io/sensu-go/latest/reference/handlers/, Sensu handlers + +/flux/v0.x/stdlib/contrib/sranka/teams/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/teams/ + - /influxdb/cloud/reference/flux/stdlib/contrib/teams/ + +/flux/v0.x/stdlib/contrib/sranka/teams/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/teams/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/teams/endpoint/ + +/flux/v0.x/stdlib/contrib/sranka/teams/message.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/teams/message/ + - /influxdb/cloud/reference/flux/stdlib/contrib/teams/message/ + +/flux/v0.x/stdlib/contrib/sranka/telegram/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/telegram/ + - /influxdb/cloud/reference/flux/stdlib/contrib/telegram/ + +/flux/v0.x/stdlib/contrib/sranka/telegram/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/telegram/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/telegram/endpoint/ + +/flux/v0.x/stdlib/contrib/sranka/telegram/message.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/telegram/message/ + - /influxdb/cloud/reference/flux/stdlib/contrib/telegram/message/ + +/flux/v0.x/stdlib/contrib/sranka/webexteams/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/webexteams/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/contrib/webexteams/endpoint/ + +/flux/v0.x/stdlib/contrib/sranka/webexteams/message.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/webexteams/message/ + - /influxdb/cloud/reference/flux/stdlib/contrib/webexteams/message/ + +/flux/v0.x/stdlib/contrib/tomhollingworth/events/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/events/ + - /influxdb/cloud/reference/flux/stdlib/contrib/events/ + +/flux/v0.x/stdlib/contrib/tomhollingworth/events/duration.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/contrib/events/duration/ + - /influxdb/cloud/reference/flux/stdlib/contrib/events/duration/ + related: + - /flux/v0.x/stdlib/universe/elapsed/ + - /flux/v0.x/stdlib/universe/stateduration/ + +/flux/v0.x/stdlib/csv/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/csv/ + - /influxdb/v2.0/reference/flux/stdlib/csv/ + - /influxdb/cloud/reference/flux/stdlib/csv/ + +/flux/v0.x/stdlib/csv/from.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/inputs/fromcsv + - /influxdb/v2.0/reference/flux/functions/built-in/inputs/fromcsv + - /influxdb/v2.0/reference/flux/functions/csv/from/ + - /influxdb/v2.0/reference/flux/stdlib/csv/from/ + - /influxdb/cloud/reference/flux/stdlib/csv/from/ + +/flux/v0.x/stdlib/date/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/language/built-ins/time-constants/ + - /influxdb/v2.0/reference/flux/functions/date/ + - /influxdb/v2.0/reference/flux/stdlib/date/ + - /influxdb/cloud/reference/flux/stdlib/date/ + +/flux/v0.x/stdlib/date/add.md: | + aliases: + - /flux/v0.x/stdlib/date/addduration/ + related: + - /flux/v0.x/stdlib/date/subduration/ + +/flux/v0.x/stdlib/date/hour.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/hour/ + - /influxdb/v2.0/reference/flux/stdlib/date/hour/ + - /influxdb/cloud/reference/flux/stdlib/date/hour/ + +/flux/v0.x/stdlib/date/microsecond.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/microsecond/ + - /influxdb/v2.0/reference/flux/stdlib/date/microsecond/ + - /influxdb/cloud/reference/flux/stdlib/date/microsecond/ + +/flux/v0.x/stdlib/date/millisecond.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/millisecond/ + - /influxdb/v2.0/reference/flux/stdlib/date/millisecond/ + - /influxdb/cloud/reference/flux/stdlib/date/millisecond/ + +/flux/v0.x/stdlib/date/minute.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/minute/ + - /influxdb/v2.0/reference/flux/stdlib/date/minute/ + - /influxdb/cloud/reference/flux/stdlib/date/minute/ + +/flux/v0.x/stdlib/date/month.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/month/ + - /influxdb/v2.0/reference/flux/stdlib/date/month/ + - /influxdb/cloud/reference/flux/stdlib/date/month/ + +/flux/v0.x/stdlib/date/monthday.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/monthday/ + - /influxdb/v2.0/reference/flux/stdlib/date/monthday/ + - /influxdb/cloud/reference/flux/stdlib/date/monthday/ + +/flux/v0.x/stdlib/date/nanosecond.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/nanosecond/ + - /influxdb/v2.0/reference/flux/stdlib/date/nanosecond/ + - /influxdb/cloud/reference/flux/stdlib/date/nanosecond/ + +/flux/v0.x/stdlib/date/quarter.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/quarter/ + - /influxdb/v2.0/reference/flux/stdlib/date/quarter/ + - /influxdb/cloud/reference/flux/stdlib/date/quarter/ + +/flux/v0.x/stdlib/date/second.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/second/ + - /influxdb/v2.0/reference/flux/stdlib/date/second/ + - /influxdb/cloud/reference/flux/stdlib/date/second/ + +/flux/v0.x/stdlib/date/sub.md: | + aliases: + - /flux/v0.x/stdlib/date/subduration/ + related: + - /flux/v0.x/stdlib/date/addduration/ + +/flux/v0.x/stdlib/date/truncate.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/truncate/ + - /influxdb/v2.0/reference/flux/stdlib/date/truncate/ + - /influxdb/cloud/reference/flux/stdlib/date/truncate/ + +/flux/v0.x/stdlib/date/week.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/week/ + - /influxdb/v2.0/reference/flux/stdlib/date/week/ + - /influxdb/cloud/reference/flux/stdlib/date/week/ + +/flux/v0.x/stdlib/date/weekday.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/weekday/ + - /influxdb/v2.0/reference/flux/stdlib/date/weekday/ + - /influxdb/cloud/reference/flux/stdlib/date/weekday/ + +/flux/v0.x/stdlib/date/year.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/year/ + - /influxdb/v2.0/reference/flux/stdlib/date/year/ + - /influxdb/cloud/reference/flux/stdlib/date/year/ + +/flux/v0.x/stdlib/date/yearday.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/date/yearday/ + - /influxdb/v2.0/reference/flux/stdlib/date/yearday/ + - /influxdb/cloud/reference/flux/stdlib/date/yearday/ + +/flux/v0.x/stdlib/dict/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/dict/ + - /influxdb/cloud/reference/flux/stdlib/dict/ + related: + - /flux/v0.x/data-types/composite/dict/ + +/flux/v0.x/stdlib/dict/fromlist.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/dict/fromlist/ + - /influxdb/cloud/reference/flux/stdlib/dict/fromlist/ + related: + - /flux/v0.x/data-types/composite/dict/ + +/flux/v0.x/stdlib/dict/get.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/dict/get/ + - /influxdb/cloud/reference/flux/stdlib/dict/get/ + related: + - /flux/v0.x/data-types/composite/dict/ + +/flux/v0.x/stdlib/dict/insert.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/dict/insert/ + - /influxdb/cloud/reference/flux/stdlib/dict/insert/ + related: + - /flux/v0.x/data-types/composite/dict/ + +/flux/v0.x/stdlib/dict/remove.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/dict/remove/ + - /influxdb/cloud/reference/flux/stdlib/dict/remove/ + related: + - /flux/v0.x/data-types/composite/dict/ + +/flux/v0.x/stdlib/experimental/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/ + - /influxdb/cloud/reference/flux/stdlib/experimental/ + +/flux/v0.x/stdlib/experimental/addduration.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/addduration/ + - /influxdb/cloud/reference/flux/stdlib/experimental/addduration/ + related: + - /flux/v0.x/stdlib/experimental/subduration/ + +/flux/v0.x/stdlib/experimental/aligntime.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/aligntime/ + - /influxdb/cloud/reference/flux/stdlib/experimental/aligntime/ + +/flux/v0.x/stdlib/experimental/chain.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/chain/ + - /influxdb/cloud/reference/flux/stdlib/experimental/chain/ + +/flux/v0.x/stdlib/experimental/count.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/count/ + - /influxdb/cloud/reference/flux/stdlib/experimental/count/ + related: + - /flux/v0.x/stdlib/universe/count/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#count, InfluxQL – COUNT() + +/flux/v0.x/stdlib/experimental/distinct.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/distinct/ + - /influxdb/cloud/reference/flux/stdlib/experimental/distinct/ + related: + - /flux/v0.x/stdlib/universe/distinct/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#distinct, InfluxQL – DISTINCT() + +/flux/v0.x/stdlib/experimental/fill.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/fill/ + - /influxdb/cloud/reference/flux/stdlib/experimental/fill/ + related: + - /influxdb/v2.0/query-data/flux/fill/ + - /flux/v0.x/stdlib/universe/fill + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#group-by-time-intervals-and-fill, InfluxQL – FILL + +/flux/v0.x/stdlib/experimental/first.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/first/ + - /influxdb/cloud/reference/flux/stdlib/experimental/first/ + related: + - /{{< latest "inflxudb" >}}/query-data/flux/first-last/ + - /flux/v0.x/stdlib/universe/first/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#first, InfluxQL – FIRST() + +/flux/v0.x/stdlib/experimental/group.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/group/ + - /influxdb/cloud/reference/flux/stdlib/experimental/group/ + related: + - /flux/v0.x/stdlib/universe/group/ + +/flux/v0.x/stdlib/experimental/histogram.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/histogram/ + - /influxdb/cloud/reference/flux/stdlib/experimental/histogram/ + related: + - /influxdb/v2.0/query-data/flux/histograms/ + - /flux/v0.x/stdlib/universe/histogram/ + +/flux/v0.x/stdlib/experimental/histogramquantile.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/histogramquantile/ + - /influxdb/cloud/reference/flux/stdlib/experimental/histogramquantile/ + related: + - /flux/v0.x/stdlib/universe/histogramquantile/ + +/flux/v0.x/stdlib/experimental/integral.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/integral/ + - /influxdb/cloud/reference/flux/stdlib/experimental/integral/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#integral, InfluxQL – INTEGRAL() + - /flux/v0.x/stdlib/universe/integral/ + +/flux/v0.x/stdlib/experimental/join.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/join/ + - /influxdb/cloud/reference/flux/stdlib/experimental/join/ + +/flux/v0.x/stdlib/experimental/kaufmansama.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/kaufmanama/ + - /influxdb/cloud/reference/flux/stdlib/experimental/kaufmanama/ + related: + - /flux/v0.x/stdlib/universe/kaufmanama/ + - /flux/v0.x/stdlib/universe/kaufmanser/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#kaufmans-adaptive-moving-average, InfluxQL KAUFMANS_ADAPTIVE_MOVING_AVERAGE() + +/flux/v0.x/stdlib/experimental/last.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/last/ + - /influxdb/cloud/reference/flux/stdlib/experimental/last/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/first-last/ + - /flux/v0.x/stdlib/universe/last + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#last, InfluxQL – LAST() + +/flux/v0.x/stdlib/experimental/max.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/max/ + - /influxdb/cloud/reference/flux/stdlib/experimental/max/ + related: + - /flux/v0.x/stdlib/universe/max/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#max, InfluxQL – MAX() + +/flux/v0.x/stdlib/experimental/mean.md: | + aliases: + - /influxdb/v2.0/reference/flux/experimental/mean + - /influxdb/cloud/reference/flux/experimental/mean + related: + - /flux/v0.x/stdlib/universe/mean + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#mean, InfluxQL – MEAN() + +/flux/v0.x/stdlib/experimental/min.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/min/ + - /influxdb/cloud/reference/flux/stdlib/experimental/min/ + related: + - /{{< latest "influxdb" >}}/flux/stdlib/built-in/transformations/selectors/min/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#min, InfluxQL – MIN() + +/flux/v0.x/stdlib/experimental/mode.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/mode/ + - /influxdb/cloud/reference/flux/stdlib/experimental/mode/ + related: + - /flux/v0.x/stdlib/universe/mode/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#mode, InfluxQL – MODE() + +/flux/v0.x/stdlib/experimental/objectkeys.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/objectkeys/ + - /influxdb/cloud/reference/flux/stdlib/experimental/objectkeys/ + +/flux/v0.x/stdlib/experimental/quantile.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/quantile/ + - /influxdb/cloud/reference/flux/stdlib/experimental/quantile/ + related: + - /influxdb/v2.0/query-data/flux/percentile-quantile/ + - /flux/v0.x/stdlib/universe/quantile/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#percentile, InfluxQL – PERCENTILE() + +/flux/v0.x/stdlib/experimental/set.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/set/ + - /influxdb/cloud/reference/flux/stdlib/experimental/set/ + related: + - /flux/v0.x/stdlib/universe/set/ + +/flux/v0.x/stdlib/experimental/skew.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/skew/ + - /influxdb/cloud/reference/flux/stdlib/experimental/skew/ + related: + - /flux/v0.x/stdlib/universe/skew/ + +/flux/v0.x/stdlib/experimental/spread.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/spread/ + - /influxdb/cloud/reference/flux/stdlib/experimental/spread/ + related: + - /flux/v0.x/stdlib/universe/spread/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#spread, InfluxQL – SPREAD() + +/flux/v0.x/stdlib/experimental/stddev.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/stddev/ + - /influxdb/cloud/reference/flux/stdlib/experimental/stddev/ + related: + - /flux/v0.x/stdlib/universe/stddev/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#stddev, InfluxQL – STDDEV() + +/flux/v0.x/stdlib/experimental/subduration.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/subduration/ + - /influxdb/cloud/reference/flux/stdlib/experimental/subduration/ + related: + - /flux/v0.x/stdlib/experimental/addduration/ + +/flux/v0.x/stdlib/experimental/sum.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/sum/ + - /influxdb/cloud/reference/flux/stdlib/experimental/sum/ + related: + - /flux/v0.x/stdlib/universe/sum/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#sum, InfluxQL – SUM() + +/flux/v0.x/stdlib/experimental/to.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/to/ + - /influxdb/cloud/reference/flux/stdlib/experimental/to/ + related: + - /flux/v0.x/stdlib/influxdata/influxdb/to/ + +/flux/v0.x/stdlib/experimental/unique.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/unique/ + - /influxdb/cloud/reference/flux/stdlib/experimental/unique/ + related: + - /flux/v0.x/stdlib/universe/unique/ + +/flux/v0.x/stdlib/experimental/window.md: | + related: + - /influxdb/v2.0/query-data/flux/window-aggregate/ + - /flux/v0.x/stdlib/universe/window/ + - /flux/v0.x/stdlib/universe/aggregatewindow/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-group-by-clause, InfluxQL – GROUP BY time() + +/flux/v0.x/stdlib/experimental/aggregate/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/aggregate/ + - /influxdb/cloud/reference/flux/stdlib/experimental/aggregate/ + +/flux/v0.x/stdlib/experimental/aggregate/rate.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/aggregate/rate/ + - /influxdb/cloud/reference/flux/stdlib/experimental/aggregate/rate/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/rate/ + +/flux/v0.x/stdlib/experimental/array/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/array/ + - /influxdb/cloud/reference/flux/stdlib/experimental/array/ + - /influxdb/v2.0/reference/flux/stdlib/array/ + - /influxdb/cloud/reference/flux/stdlib/array/ + related: + - /flux/v0.x/data-types/composite/array/ + +/flux/v0.x/stdlib/experimental/array/concat.md: | + related: + - /flux/v0.x/data-types/composite/array/ + +/flux/v0.x/stdlib/experimental/array/filter.md: | + related: + - /flux/v0.x/data-types/composite/array/ + +/flux/v0.x/stdlib/experimental/array/map.md: | + related: + - /flux/v0.x/data-types/composite/array/ + +/flux/v0.x/stdlib/experimental/bigtable/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/bigtable/ + - /influxdb/cloud/reference/flux/stdlib/experimental/bigtable/ + +/flux/v0.x/stdlib/experimental/bigtable/from.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/bigtable/from/ + - /influxdb/cloud/reference/flux/stdlib/experimental/bigtable/from/ + +/flux/v0.x/stdlib/experimental/bitwise/sand.md: | + related: + - /flux/v0.x/data-types/basic/int/ + +/flux/v0.x/stdlib/experimental/bitwise/sclear.md: | + related: + - /flux/v0.x/data-types/basic/int/ + +/flux/v0.x/stdlib/experimental/bitwise/slshift.md: | + related: + - /flux/v0.x/data-types/basic/int/ + +/flux/v0.x/stdlib/experimental/bitwise/snot.md: | + related: + - /flux/v0.x/data-types/basic/int/ + +/flux/v0.x/stdlib/experimental/bitwise/sor.md: | + related: + - /flux/v0.x/data-types/basic/int/ + +/flux/v0.x/stdlib/experimental/bitwise/srshift.md: | + related: + - /flux/v0.x/data-types/basic/int/ + +/flux/v0.x/stdlib/experimental/bitwise/sxor.md: | + related: + - /flux/v0.x/data-types/basic/int/ + +/flux/v0.x/stdlib/experimental/bitwise/uand.md: | + related: + - /flux/v0.x/data-types/basic/uint/ + +/flux/v0.x/stdlib/experimental/bitwise/uclear.md: | + related: + - /flux/v0.x/data-types/basic/uint/ + +/flux/v0.x/stdlib/experimental/bitwise/ulshift.md: | + related: + - /flux/v0.x/data-types/basic/uint/ + +/flux/v0.x/stdlib/experimental/bitwise/unot.md: | + related: + - /flux/v0.x/data-types/basic/uint/ + +/flux/v0.x/stdlib/experimental/bitwise/uor.md: | + related: + - /flux/v0.x/data-types/basic/uint/ + +/flux/v0.x/stdlib/experimental/bitwise/urshift.md: | + related: + - /flux/v0.x/data-types/basic/uint/ + +/flux/v0.x/stdlib/experimental/bitwise/uxor.md: | + related: + - /flux/v0.x/data-types/basic/uint/ + +/flux/v0.x/stdlib/experimental/csv/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/csv/ + - /influxdb/cloud/reference/flux/stdlib/experimental/csv/ + +/flux/v0.x/stdlib/experimental/csv/from.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/csv/from/ + - /influxdb/cloud/reference/flux/stdlib/experimental/csv/from/ + +/flux/v0.x/stdlib/experimental/geo/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/astracks.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/astracks/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/astracks/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/filterrows.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/filterrows/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/filterrows/ + related: + - /flux/v0.x/stdlib/experimental/geo/gridfilter/ + - /flux/v0.x/stdlib/experimental/geo/strictfilter/ + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/gridfilter.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/gridfilter/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/gridfilter/ + related: + - /flux/v0.x/stdlib/experimental/geo/strictfilter/ + - /flux/v0.x/stdlib/experimental/geo/filterRows/ + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/groupbyarea.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/groupbyarea/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/groupbyarea/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/s2cellidtoken.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/s2cellidtoken/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/s2cellidtoken/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/s2celllatlon.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/s2celllatlon/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/s2celllatlon/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/shapedata.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/shapedata/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/shapedata/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/st_contains.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_contains/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_contains/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/st_distance.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_distance/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_distance/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/st_dwithin.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_dwithin/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_dwithin/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/st_intersects.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_intersects/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_intersects/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/st_length.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_length/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_length/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/st_linestring.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/st_linestring/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/st_linestring/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/strictfilter.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/strictfilter/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/strictfilter/ + related: + - /flux/v0.x/stdlib/experimental/geo/gridfilter/ + - /flux/v0.x/stdlib/experimental/geo/filterRows/ + - /flux/v0.x/stdlib/experimental/geo/toRows/ + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + +/flux/v0.x/stdlib/experimental/geo/torows.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/geo/torows/ + - /influxdb/cloud/reference/flux/stdlib/experimental/geo/torows/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/geo/ + - /flux/v0.x/stdlib/universe/pivot/ + +/flux/v0.x/stdlib/experimental/http/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/http/ + - /influxdb/cloud/reference/flux/stdlib/experimental/http/ + +/flux/v0.x/stdlib/experimental/http/get.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/http/get/ + - /influxdb/cloud/reference/flux/stdlib/experimental/http/get/ + +/flux/v0.x/stdlib/experimental/influxdb/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/influxdb/ + - /influxdb/cloud/reference/flux/stdlib/experimental/influxdb/ + +/flux/v0.x/stdlib/experimental/influxdb/api.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/influxdb/api/ + - /influxdb/cloud/reference/flux/stdlib/experimental/influxdb/api/ + +/flux/v0.x/stdlib/experimental/json/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/json/ + - /influxdb/cloud/reference/flux/stdlib/experimental/json/ + +/flux/v0.x/stdlib/experimental/json/parse.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/json/parse/ + - /influxdb/cloud/reference/flux/stdlib/experimental/json/parse/ + +/flux/v0.x/stdlib/experimental/mqtt/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/mqtt/ + - /influxdb/cloud/reference/flux/stdlib/experimental/mqtt/ + +/flux/v0.x/stdlib/experimental/mqtt/to.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/mqtt/to/ + - /influxdb/cloud/reference/flux/stdlib/experimental/mqtt/to/ + +/flux/v0.x/stdlib/experimental/oee/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/oee/ + - /influxdb/cloud/reference/flux/stdlib/experimental/oee/ + +/flux/v0.x/stdlib/experimental/oee/apq.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/oee/apq/ + - /influxdb/cloud/reference/flux/stdlib/experimental/oee/apq/ + +/flux/v0.x/stdlib/experimental/oee/computeapq.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/oee/computeapq/ + - /influxdb/cloud/reference/flux/stdlib/experimental/oee/computeapq/ + +/flux/v0.x/stdlib/experimental/prometheus/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/prometheus/ + - /influxdb/cloud/reference/flux/stdlib/experimental/prometheus/ + +/flux/v0.x/stdlib/experimental/prometheus/histogramquantile.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/prometheus/histogramquantile/ + - /influxdb/cloud/reference/flux/stdlib/experimental/prometheus/histogramquantile/ + +/flux/v0.x/stdlib/experimental/prometheus/scrape.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/prometheus/scrape/ + - /influxdb/cloud/reference/flux/stdlib/experimental/prometheus/scrape/ + related: + - /{{< latest "influxdb" >}}/write-data/no-code/scrape-data/scrapable-endpoints/ + +/flux/v0.x/stdlib/experimental/query/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/query/ + - /influxdb/cloud/reference/flux/stdlib/experimental/query/ + +/flux/v0.x/stdlib/experimental/query/filterfields.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/query/filterfields/ + - /influxdb/cloud/reference/flux/stdlib/experimental/query/filterfields/ + +/flux/v0.x/stdlib/experimental/query/filtermeasurement.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/query/filtermeasurement/ + - /influxdb/cloud/reference/flux/stdlib/experimental/query/filtermeasurement/ + +/flux/v0.x/stdlib/experimental/query/fromrange.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/query/fromrange/ + - /influxdb/cloud/reference/flux/stdlib/experimental/query/fromrange/ + +/flux/v0.x/stdlib/experimental/query/inbucket.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/query/inbucket/ + - /influxdb/cloud/reference/flux/stdlib/experimental/query/inbucket/ + +/flux/v0.x/stdlib/experimental/record/get.md: | + related: + - /flux/v0.x/data-types/composite/record/ + +/flux/v0.x/stdlib/experimental/usage/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/usage/ + - /influxdb/cloud/reference/flux/stdlib/experimental/usage/ + related: + - https://www.influxdata.com/influxdb-templates/influxdb-cloud-usage-dashboard/, InfluxDB Cloud Usage – Community Template + +/flux/v0.x/stdlib/experimental/usage/from.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/usage/from/ + - /influxdb/cloud/reference/flux/stdlib/experimental/usage/from/ + related: + - /influxdb/cloud/account-management/data-usage/ + - /influxdb/cloud/account-management/limits/ + - https://www.influxdata.com/influxdb-templates/influxdb-cloud-usage-dashboard/, InfluxDB Cloud Usage – Community Template + +/flux/v0.x/stdlib/experimental/usage/limits.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/experimental/usage/limits/ + - /influxdb/cloud/reference/flux/stdlib/experimental/usage/limits/ + related: + - /flux/v0.x/stdlib/influxdata/influxdb/cardinality/ + - /influxdb/cloud/account-management/data-usage/ + - /influxdb/cloud/account-management/limits/ + - https://www.influxdata.com/influxdb-templates/influxdb-cloud-usage-dashboard/, InfluxDB Cloud Usage – Community Template + +/flux/v0.x/stdlib/http/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/http/ + - /influxdb/v2.0/reference/flux/stdlib/http/ + - /influxdb/cloud/reference/flux/stdlib/http/ + +/flux/v0.x/stdlib/http/basicauth.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/http/basicauth/ + - /influxdb/v2.0/reference/flux/stdlib/http/basicauth/ + - /influxdb/cloud/reference/flux/stdlib/http/basicauth/ + +/flux/v0.x/stdlib/http/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/http/endpoint/ + - /influxdb/v2.0/reference/flux/stdlib/http/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/http/endpoint/ + +/flux/v0.x/stdlib/http/pathescape.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/http/pathescape/ + - /influxdb/cloud/reference/flux/stdlib/http/pathescape/ + +/flux/v0.x/stdlib/http/post.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/http/post/ + - /influxdb/v2.0/reference/flux/stdlib/http/post/ + - /influxdb/cloud/reference/flux/stdlib/http/post/ + +/flux/v0.x/stdlib/influxdata/influxdb/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/influxdb/ + - /influxdb/cloud/reference/flux/stdlib/influxdb/ + +/flux/v0.x/stdlib/influxdata/influxdb/buckets.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/inputs/buckets + - /influxdb/v2.0/reference/flux/functions/built-in/inputs/buckets/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/inputs/buckets/ + - /influxdb/cloud/reference/flux/stdlib/built-in/inputs/buckets/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-databases, InfluxQL - SHOW DATABASES]() + +/flux/v0.x/stdlib/influxdata/influxdb/cardinality.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/influxdb/cardinality/ + - /influxdb/cloud/reference/flux/stdlib/influxdb/cardinality/ + - /flux/v0.x/stdlib/influxdb/cardinality/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/spec/#show-cardinality, SHOW CARDINALITY in InfluxQL + - /flux/v0.x/stdlib/experimental/usage/limits/ + +/flux/v0.x/stdlib/influxdata/influxdb/from.md: | + aliases: + - /flux/v0.x/stdlib/universe/from + - /influxdb/v2.0/reference/flux/functions/inputs/from + - /influxdb/v2.0/reference/flux/functions/built-in/inputs/from/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/inputs/from/ + - /influxdb/cloud/reference/flux/stdlib/built-in/inputs/from/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#from-clause, InfluxQL - FROM + +/flux/v0.x/stdlib/influxdata/influxdb/to.md: | + aliases: + - /flux/v0.x/stdlib/universe/to + - /influxdb/v2.0/reference/flux/functions/outputs/to + - /influxdb/v2.0/reference/flux/functions/built-in/outputs/to/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/outputs/to/ + - /influxdb/cloud/reference/flux/stdlib/built-in/outputs/to/ + related: + - /flux/v0.x/stdlib/experimental/to/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-into-clause, InfluxQL – SELECT INTO + +/flux/v0.x/stdlib/influxdata/influxdb/monitor/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/monitor/ + - /influxdb/v2.0/reference/flux/stdlib/monitor/ + - /influxdb/cloud/reference/flux/stdlib/monitor/ + +/flux/v0.x/stdlib/influxdata/influxdb/monitor/check.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/monitor/check/ + - /influxdb/v2.0/reference/flux/stdlib/monitor/check/ + - /influxdb/cloud/reference/flux/stdlib/monitor/check/ + +/flux/v0.x/stdlib/influxdata/influxdb/monitor/deadman.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/monitor/deadman/ + - /influxdb/v2.0/reference/flux/stdlib/monitor/deadman/ + - /influxdb/cloud/reference/flux/stdlib/monitor/deadman/ + +/flux/v0.x/stdlib/influxdata/influxdb/monitor/from.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/monitor/from/ + - /influxdb/v2.0/reference/flux/stdlib/monitor/from/ + - /influxdb/cloud/reference/flux/stdlib/monitor/from/ + +/flux/v0.x/stdlib/influxdata/influxdb/monitor/logs.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/monitor/logs/ + - /influxdb/v2.0/reference/flux/stdlib/monitor/logs/ + - /influxdb/cloud/reference/flux/stdlib/monitor/logs/ + +/flux/v0.x/stdlib/influxdata/influxdb/monitor/notify.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/monitor/notify/ + - /influxdb/v2.0/reference/flux/stdlib/monitor/notify/ + - /influxdb/cloud/reference/flux/stdlib/monitor/notify/ + +/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechanges.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/monitor/statechanges/ + - /influxdb/v2.0/reference/flux/stdlib/monitor/statechanges/ + - /influxdb/cloud/reference/flux/stdlib/monitor/statechanges/ + +/flux/v0.x/stdlib/influxdata/influxdb/monitor/statechangesonly.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/monitor/statechangesonly/ + - /influxdb/cloud/reference/flux/stdlib/monitor/statechangesonly/ + - /cloud/reference/flux/stdlib/monitor/statechangesonly/ + +/flux/v0.x/stdlib/influxdata/influxdb/sample/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/influxdb-sample + - /influxdb/cloud/reference/flux/stdlib/influxdb-sample + +/flux/v0.x/stdlib/influxdata/influxdb/sample/aligntonow.md: | + related: + - /{{< latest "influxdb" >}}/reference/sample-data/ + +/flux/v0.x/stdlib/influxdata/influxdb/sample/data.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/influxdb-sample/data + - /influxdb/cloud/reference/flux/stdlib/influxdb-sample/data + related: + - /{{< latest "influxdb" >}}/reference/sample-data/ + +/flux/v0.x/stdlib/influxdata/influxdb/sample/list.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/influxdb-sample/list + - /influxdb/cloud/reference/flux/stdlib/influxdb-sample/list + related: + - /{{< latest "influxdb" >}}/reference/sample-data/ + +/flux/v0.x/stdlib/influxdata/influxdb/schema/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/ + append: + block: warn + content: | + #### Not supported in the Flux REPL + `schema` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldkeys.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/fieldkeys + - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/fieldkeys/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/fieldkeys/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-field-keys, SHOW FIELD KEYS in InfluxQL + append: + block: warn + content: | + #### Not supported in the Flux REPL + `schema` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/inputs/fromrows + - /influxdb/v2.0/reference/flux/functions/transformations/influxfieldsascols + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/fieldsascols/ + - /influxdb/v2.0/reference/flux/functions/influxdb-schema/fieldsascols/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/fieldsascols/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/fieldsascols/ + append: + block: warn + content: | + #### Not supported in the Flux REPL + `schema` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementfieldkeys/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/measurementfieldkeys/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/measurementfieldkeys/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-field-keys, SHOW FIELD KEYS in InfluxQL + append: + block: warn + content: | + #### Not supported in the Flux REPL + `schema` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/schema/measurements.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurements/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/measurements/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/measurements/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-measurements, SHOW MEASUREMENTS in InfluxQL + append: + block: warn + content: | + #### Not supported in the Flux REPL + `schema` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementtagkeys/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/measurementtagkeys/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/measurementtagkeys/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-keys, SHOW TAG KEYS in InfluxQL + append: + block: warn + content: | + #### Not supported in the Flux REPL + `schema` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagvalues.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementtagvalues/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/measurementtagvalues/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/measurementtagvalues/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-values, SHOW TAG VALUES in InfluxQL + append: + block: warn + content: | + #### Not supported in the Flux REPL + `schema` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/schema/tagkeys.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/tagkeys/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/tagkeys/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/tagkeys/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-keys, SHOW TAG KEYS in InfluxQL + append: + block: warn + content: | + #### Not supported in the Flux REPL + `schema` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/schema/tagvalues.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/tagvalues/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-schema/tagvalues/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-schema/tagvalues/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-values, SHOW TAG VALUES in InfluxQL + append: + block: warn + content: | + #### Not supported in the Flux REPL + `schema` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/secrets/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/secrets/ + - /influxdb/v2.0/reference/flux/stdlib/secrets/ + - /influxdb/cloud/reference/flux/stdlib/secrets/ + related: + - /{{< latest "influxdb" >}}/security/secrets/, Manage secrets in InfluxDB + +/flux/v0.x/stdlib/influxdata/influxdb/secrets/get.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/secrets/get/ + - /influxdb/v2.0/reference/flux/stdlib/secrets/get/ + - /influxdb/cloud/reference/flux/stdlib/secrets/get/ + related: + - /{{< latest "influxdb" >}}/security/secrets/, Manage secrets in InfluxDB + +/flux/v0.x/stdlib/influxdata/influxdb/tasks/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-tasks/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-tasks/ + related: + - /{{< latest "influxdb" >}}/process-data/get-started/ + +/flux/v0.x/stdlib/influxdata/influxdb/tasks/lastsuccess.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/influxdb-tasks/lastsuccess/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-tasks/lastsuccess/ + +/flux/v0.x/stdlib/influxdata/influxdb/v1/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/ + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/v1/databases.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/databases/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/databases/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-databases, SHOW DATABASES in InfluxQL + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldkeys.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/fieldkeys + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/fieldkeys/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-field-keys, SHOW FIELD KEYS in InfluxQL + prepend: + block: warn + content: | + #### Deprecated + `v1.fieldKeys()` was deprecated in **Flux v0.88.0** in favor of + [`schema.fieldKeys()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldkeys/). + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/v1/fieldsascols.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/inputs/fromrows + - /influxdb/v2.0/reference/flux/functions/transformations/influxfieldsascols + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/fieldsascols/ + - /influxdb/v2.0/reference/flux/functions/influxdb-schema/fieldsascols/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/fieldsascols/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/fieldsascols/ + append: + block: warn + content: | + #### Deprecated + `v1.fieldsAsCols()` was deprecated in **Flux v0.88.0** in favor of + [`schema.fieldsAsCols()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols/). + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementfieldkeys.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementfieldkeys/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/measurementfieldkeys/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-field-keys, SHOW FIELD KEYS in InfluxQL + prepend: + block: warn + content: | + #### Deprecated + `v1.measurementFieldKeys()` was deprecated in **Flux v0.88.0** in favor of + [`schema.measurementFieldKeys()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys/). + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/v1/measurements.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurements/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/measurements/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/measurements/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-measurements, SHOW MEASUREMENTS in InfluxQL + prepend: + block: warn + content: | + #### Deprecated + `v1.measurements()` was deprecated in **Flux v0.88.0** in favor of + [`schema.measurements()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurements/). + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagkeys.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementtagkeys/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/measurementtagkeys/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-keys, SHOW TAG KEYS in InfluxQL + prepend: + block: warn + content: | + #### Deprecated + `v1.measurementTagKeys()` was deprecated in **Flux v0.88.0** in favor of + [`schema.measurementTagKeys()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys/). + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/v1/measurementtagvalues.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/measurementtagvalues/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/measurementtagvalues/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-values, SHOW TAG VALUES in InfluxQL + prepend: + block: warn + content: | + #### Deprecated + `v1.measurementTagValues()` was deprecated in **Flux v0.88.0** in favor of + [`schema.measurementTagValues()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagvalues/). + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/v1/tagkeys.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/tagkeys/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/tagkeys/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-keys, SHOW TAG KEYS in InfluxQL + prepend: + block: warn + content: | + #### Deprecated + `v1.tagkeys()` was deprecated in **Flux v0.88.0** in favor of + [`schema.tagkeys()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/tagkeys/). + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/influxdata/influxdb/v1/tagvalues.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/influxdb-v1/tagvalues/ + - /influxdb/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues/ + - /influxdb/cloud/reference/flux/stdlib/influxdb-v1/tagvalues/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/explore-schema/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema#show-tag-values, SHOW TAG VALUES in InfluxQL + prepend: + block: warn + content: | + #### Deprecated + `v1.tagValues()` was deprecated in **Flux v0.88.0** in favor of + [`schema.tagValues()`](/flux/v0.x/stdlib/influxdata/influxdb/schema/tagvalues/). + append: + block: warn + content: | + #### Not supported in the Flux REPL + `v1` functions can retrieve schema information when executed within + the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/). + +/flux/v0.x/stdlib/interpolate/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/interpolate/ + - /influxdb/cloud/reference/flux/stdlib/interpolate/ + +/flux/v0.x/stdlib/interpolate/linear.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/interpolate/linear/ + - /influxdb/cloud/reference/flux/stdlib/interpolate/linear/ + +/flux/v0.x/stdlib/json/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/json/ + - /influxdb/v2.0/reference/flux/stdlib/json/ + - /influxdb/cloud/reference/flux/stdlib/json/ + +/flux/v0.x/stdlib/json/encode.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/json/encode/ + - /influxdb/v2.0/reference/flux/stdlib/json/encode/ + - /influxdb/cloud/reference/flux/stdlib/json/encode/ + +/flux/v0.x/stdlib/math/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/ + - /influxdb/v2.0/reference/flux/stdlib/math/ + - /influxdb/cloud/reference/flux/stdlib/math/ + +/flux/v0.x/stdlib/math/abs.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/abs/ + - /influxdb/v2.0/reference/flux/stdlib/math/abs/ + - /influxdb/cloud/reference/flux/stdlib/math/abs/ + +/flux/v0.x/stdlib/math/acos.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/acos/ + - /influxdb/v2.0/reference/flux/stdlib/math/acos/ + - /influxdb/cloud/reference/flux/stdlib/math/acos/ + +/flux/v0.x/stdlib/math/acosh.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/acosh/ + - /influxdb/v2.0/reference/flux/stdlib/math/acosh/ + - /influxdb/cloud/reference/flux/stdlib/math/acosh/ + +/flux/v0.x/stdlib/math/asin.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/asin/ + - /influxdb/v2.0/reference/flux/stdlib/math/asin/ + - /influxdb/cloud/reference/flux/stdlib/math/asin/ + +/flux/v0.x/stdlib/math/asinh.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/asinh/ + - /influxdb/v2.0/reference/flux/stdlib/math/asinh/ + - /influxdb/cloud/reference/flux/stdlib/math/asinh/ + +/flux/v0.x/stdlib/math/atan.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/atan/ + - /influxdb/v2.0/reference/flux/stdlib/math/atan/ + - /influxdb/cloud/reference/flux/stdlib/math/atan/ + +/flux/v0.x/stdlib/math/atan2.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/atan2/ + - /influxdb/v2.0/reference/flux/stdlib/math/atan2/ + - /influxdb/cloud/reference/flux/stdlib/math/atan2/ + +/flux/v0.x/stdlib/math/atanh.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/atanh/ + - /influxdb/v2.0/reference/flux/stdlib/math/atanh/ + - /influxdb/cloud/reference/flux/stdlib/math/atanh/ + +/flux/v0.x/stdlib/math/cbrt.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/cbrt/ + - /influxdb/v2.0/reference/flux/stdlib/math/cbrt/ + - /influxdb/cloud/reference/flux/stdlib/math/cbrt/ + +/flux/v0.x/stdlib/math/ceil.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/ceil/ + - /influxdb/v2.0/reference/flux/stdlib/math/ceil/ + - /influxdb/cloud/reference/flux/stdlib/math/ceil/ + +/flux/v0.x/stdlib/math/copysign.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/copysign/ + - /influxdb/v2.0/reference/flux/stdlib/math/copysign/ + - /influxdb/cloud/reference/flux/stdlib/math/copysign/ + +/flux/v0.x/stdlib/math/cos.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/cos/ + - /influxdb/v2.0/reference/flux/stdlib/math/cos/ + - /influxdb/cloud/reference/flux/stdlib/math/cos/ + +/flux/v0.x/stdlib/math/cosh.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/cosh/ + - /influxdb/v2.0/reference/flux/stdlib/math/cosh/ + - /influxdb/cloud/reference/flux/stdlib/math/cosh/ + +/flux/v0.x/stdlib/math/dim.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/dim/ + - /influxdb/v2.0/reference/flux/stdlib/math/dim/ + - /influxdb/cloud/reference/flux/stdlib/math/dim/ + +/flux/v0.x/stdlib/math/erf.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/erf/ + - /influxdb/v2.0/reference/flux/stdlib/math/erf/ + - /influxdb/cloud/reference/flux/stdlib/math/erf/ + +/flux/v0.x/stdlib/math/erfc.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/erfc/ + - /influxdb/v2.0/reference/flux/stdlib/math/erfc/ + - /influxdb/cloud/reference/flux/stdlib/math/erfc/ + +/flux/v0.x/stdlib/math/erfcinv.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/erfcinv/ + - /influxdb/v2.0/reference/flux/stdlib/math/erfcinv/ + - /influxdb/cloud/reference/flux/stdlib/math/erfcinv/ + +/flux/v0.x/stdlib/math/erfinv.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/erfinv/ + - /influxdb/v2.0/reference/flux/stdlib/math/erfinv/ + - /influxdb/cloud/reference/flux/stdlib/math/erfinv/ + +/flux/v0.x/stdlib/math/exp.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/exp/ + - /influxdb/v2.0/reference/flux/stdlib/math/exp/ + - /influxdb/cloud/reference/flux/stdlib/math/exp/ + +/flux/v0.x/stdlib/math/exp2.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/exp2/ + - /influxdb/v2.0/reference/flux/stdlib/math/exp2/ + - /influxdb/cloud/reference/flux/stdlib/math/exp2/ + +/flux/v0.x/stdlib/math/expm1.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/expm1/ + - /influxdb/v2.0/reference/flux/stdlib/math/expm1/ + - /influxdb/cloud/reference/flux/stdlib/math/expm1/ + +/flux/v0.x/stdlib/math/float64bits.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/float64bits/ + - /influxdb/v2.0/reference/flux/stdlib/math/float64bits/ + - /influxdb/cloud/reference/flux/stdlib/math/float64bits/ + +/flux/v0.x/stdlib/math/floor.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/floor/ + - /influxdb/v2.0/reference/flux/stdlib/math/floor/ + - /influxdb/cloud/reference/flux/stdlib/math/floor/ + +/flux/v0.x/stdlib/math/frexp.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/frexp/ + - /influxdb/v2.0/reference/flux/stdlib/math/frexp/ + - /influxdb/cloud/reference/flux/stdlib/math/frexp/ + +/flux/v0.x/stdlib/math/gamma.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/gamma/ + - /influxdb/v2.0/reference/flux/stdlib/math/gamma/ + - /influxdb/cloud/reference/flux/stdlib/math/gamma/ + +/flux/v0.x/stdlib/math/hypot.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/hypot/ + - /influxdb/v2.0/reference/flux/stdlib/math/hypot/ + - /influxdb/cloud/reference/flux/stdlib/math/hypot/ + +/flux/v0.x/stdlib/math/ilogb.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/ilogb/ + - /influxdb/v2.0/reference/flux/stdlib/math/ilogb/ + - /influxdb/cloud/reference/flux/stdlib/math/ilogb/ + +/flux/v0.x/stdlib/math/isinf.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/isinf/ + - /influxdb/v2.0/reference/flux/stdlib/math/isinf/ + - /influxdb/cloud/reference/flux/stdlib/math/isinf/ + +/flux/v0.x/stdlib/math/isnan.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/isnan/ + - /influxdb/v2.0/reference/flux/stdlib/math/isnan/ + - /influxdb/cloud/reference/flux/stdlib/math/isnan/ + +/flux/v0.x/stdlib/math/j0.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/j0/ + - /influxdb/v2.0/reference/flux/stdlib/math/j0/ + - /influxdb/cloud/reference/flux/stdlib/math/j0/ + +/flux/v0.x/stdlib/math/j1.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/j1/ + - /influxdb/v2.0/reference/flux/stdlib/math/j1/ + - /influxdb/cloud/reference/flux/stdlib/math/j1/ + +/flux/v0.x/stdlib/math/jn.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/jn/ + - /influxdb/v2.0/reference/flux/stdlib/math/jn/ + - /influxdb/cloud/reference/flux/stdlib/math/jn/ + +/flux/v0.x/stdlib/math/ldexp.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/ldexp/ + - /influxdb/v2.0/reference/flux/stdlib/math/ldexp/ + - /influxdb/cloud/reference/flux/stdlib/math/ldexp/ + +/flux/v0.x/stdlib/math/lgamma.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/lgamma/ + - /influxdb/v2.0/reference/flux/stdlib/math/lgamma/ + - /influxdb/cloud/reference/flux/stdlib/math/lgamma/ + +/flux/v0.x/stdlib/math/log.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/log/ + - /influxdb/v2.0/reference/flux/stdlib/math/log/ + - /influxdb/cloud/reference/flux/stdlib/math/log/ + +/flux/v0.x/stdlib/math/log1p.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/log1p/ + - /influxdb/v2.0/reference/flux/stdlib/math/log1p/ + - /influxdb/cloud/reference/flux/stdlib/math/log1p/ + +/flux/v0.x/stdlib/math/log2.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/log2/ + - /influxdb/v2.0/reference/flux/stdlib/math/log2/ + - /influxdb/cloud/reference/flux/stdlib/math/log2/ + +/flux/v0.x/stdlib/math/log10.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/log10/ + - /influxdb/v2.0/reference/flux/stdlib/math/log10/ + - /influxdb/cloud/reference/flux/stdlib/math/log10/ + +/flux/v0.x/stdlib/math/logb.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/logb/ + - /influxdb/v2.0/reference/flux/stdlib/math/logb/ + - /influxdb/cloud/reference/flux/stdlib/math/logb/ + +/flux/v0.x/stdlib/math/minf.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/m_inf/ + - /influxdb/v2.0/reference/flux/stdlib/math/m_inf/ + - /influxdb/v2.0/reference/flux/stdlib/math/minf/ + - /influxdb/cloud/reference/flux/stdlib/math/minf/ + +/flux/v0.x/stdlib/math/mmax.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/m_max/ + - /influxdb/v2.0/reference/flux/stdlib/math/m_max/ + - /influxdb/v2.0/reference/flux/stdlib/math/mmax/ + - /influxdb/cloud/reference/flux/stdlib/math/mmax/ + +/flux/v0.x/stdlib/math/mmin.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/m_min/ + - /influxdb/v2.0/reference/flux/stdlib/math/m_min/ + - /influxdb/v2.0/reference/flux/stdlib/math/mmin/ + - /influxdb/cloud/reference/flux/stdlib/math/mmin/ + +/flux/v0.x/stdlib/math/mod.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/mod/ + - /influxdb/v2.0/reference/flux/stdlib/math/mod/ + - /influxdb/cloud/reference/flux/stdlib/math/mod/ + +/flux/v0.x/stdlib/math/modf.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/modf/ + - /influxdb/v2.0/reference/flux/stdlib/math/modf/ + - /influxdb/cloud/reference/flux/stdlib/math/modf/ + +/flux/v0.x/stdlib/math/nan.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/nan/ + - /influxdb/v2.0/reference/flux/stdlib/math/nan/ + - /influxdb/cloud/reference/flux/stdlib/math/nan/ + +/flux/v0.x/stdlib/math/nextafter.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/nextafter/ + - /influxdb/v2.0/reference/flux/stdlib/math/nextafter/ + - /influxdb/cloud/reference/flux/stdlib/math/nextafter/ + +/flux/v0.x/stdlib/math/pow.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/pow/ + - /influxdb/v2.0/reference/flux/stdlib/math/pow/ + - /influxdb/cloud/reference/flux/stdlib/math/pow/ + +/flux/v0.x/stdlib/math/pow10.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/pow10/ + - /influxdb/v2.0/reference/flux/stdlib/math/pow10/ + - /influxdb/cloud/reference/flux/stdlib/math/pow10/ + +/flux/v0.x/stdlib/math/remainder.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/remainder/ + - /influxdb/v2.0/reference/flux/stdlib/math/remainder/ + - /influxdb/cloud/reference/flux/stdlib/math/remainder/ + +/flux/v0.x/stdlib/math/round.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/round/ + - /influxdb/v2.0/reference/flux/stdlib/math/round/ + - /influxdb/cloud/reference/flux/stdlib/math/round/ + +/flux/v0.x/stdlib/math/roundtoeven.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/roundtoeven/ + - /influxdb/v2.0/reference/flux/stdlib/math/roundtoeven/ + - /influxdb/cloud/reference/flux/stdlib/math/roundtoeven/ + +/flux/v0.x/stdlib/math/signbit.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/signbit/ + - /influxdb/v2.0/reference/flux/stdlib/math/signbit/ + - /influxdb/cloud/reference/flux/stdlib/math/signbit/ + +/flux/v0.x/stdlib/math/sin.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/sin/ + - /influxdb/v2.0/reference/flux/stdlib/math/sin/ + - /influxdb/cloud/reference/flux/stdlib/math/sin/ + +/flux/v0.x/stdlib/math/sincos.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/sincos/ + - /influxdb/v2.0/reference/flux/stdlib/math/sincos/ + - /influxdb/cloud/reference/flux/stdlib/math/sincos/ + +/flux/v0.x/stdlib/math/sinh.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/sinh/ + - /influxdb/v2.0/reference/flux/stdlib/math/sinh/ + - /influxdb/cloud/reference/flux/stdlib/math/sinh/ + +/flux/v0.x/stdlib/math/sqrt.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/sqrt/ + - /influxdb/v2.0/reference/flux/stdlib/math/sqrt/ + - /influxdb/cloud/reference/flux/stdlib/math/sqrt/ + +/flux/v0.x/stdlib/math/tan.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/tan/ + - /influxdb/v2.0/reference/flux/stdlib/math/tan/ + - /influxdb/cloud/reference/flux/stdlib/math/tan/ + +/flux/v0.x/stdlib/math/tanh.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/tanh/ + - /influxdb/v2.0/reference/flux/stdlib/math/tanh/ + - /influxdb/cloud/reference/flux/stdlib/math/tanh/ + +/flux/v0.x/stdlib/math/trunc.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/trunc/ + - /influxdb/v2.0/reference/flux/stdlib/math/trunc/ + - /influxdb/cloud/reference/flux/stdlib/math/trunc/ + +/flux/v0.x/stdlib/math/y0.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/y0/ + - /influxdb/v2.0/reference/flux/stdlib/math/y0/ + - /influxdb/cloud/reference/flux/stdlib/math/y0/ + +/flux/v0.x/stdlib/math/y1.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/y1/ + - /influxdb/v2.0/reference/flux/stdlib/math/y1/ + - /influxdb/cloud/reference/flux/stdlib/math/y1/ + +/flux/v0.x/stdlib/math/yn.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/math/yn/ + - /influxdb/v2.0/reference/flux/stdlib/math/yn/ + - /influxdb/cloud/reference/flux/stdlib/math/yn/ + +/flux/v0.x/stdlib/pagerduty/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/pagerduty/ + - /influxdb/v2.0/reference/flux/stdlib/pagerduty/ + - /influxdb/cloud/reference/flux/stdlib/pagerduty/ + +/flux/v0.x/stdlib/pagerduty/actionfromseverity.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/pagerduty/actionfromseverity/ + - /influxdb/v2.0/reference/flux/stdlib/pagerduty/actionfromseverity/ + - /influxdb/cloud/reference/flux/stdlib/pagerduty/actionfromseverity/ + +/flux/v0.x/stdlib/pagerduty/dedupkey.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/pagerduty/dedupkey/ + - /influxdb/v2.0/reference/flux/stdlib/pagerduty/dedupkey/ + - /influxdb/cloud/reference/flux/stdlib/pagerduty/dedupkey/ + +/flux/v0.x/stdlib/pagerduty/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/pagerduty/endpoint/ + - /influxdb/v2.0/reference/flux/stdlib/pagerduty/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/pagerduty/endpoint/ + +/flux/v0.x/stdlib/pagerduty/sendevent.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/pagerduty/sendevent/ + - /influxdb/v2.0/reference/flux/stdlib/pagerduty/sendevent/ + - /influxdb/cloud/reference/flux/stdlib/pagerduty/sendevent/ + +/flux/v0.x/stdlib/pagerduty/severityfromlevel.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/pagerduty/severityfromlevel/ + - /influxdb/v2.0/reference/flux/stdlib/pagerduty/severityfromlevel/ + - /influxdb/cloud/reference/flux/stdlib/pagerduty/severityfromlevel/ + +/flux/v0.x/stdlib/profiler/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/profiler/ + - /influxdb/cloud/reference/flux/stdlib/profiler/ + related: + - /{{< latest "influxdb" >}}/query-data/optimize-queries/ + +/flux/v0.x/stdlib/pushbullet/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/pushbullet/ + - /influxdb/cloud/reference/flux/stdlib/pushbullet/ + +/flux/v0.x/stdlib/pushbullet/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/pushbullet/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/pushbullet/endpoint/ + +/flux/v0.x/stdlib/pushbullet/pushdata.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/pushbullet/pushdata/ + - /influxdb/cloud/reference/flux/stdlib/pushbullet/pushdata/ + +/flux/v0.x/stdlib/pushbullet/pushnote.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/pushbullet/pushnote/ + - /influxdb/cloud/reference/flux/stdlib/pushbullet/pushnote/ + +/flux/v0.x/stdlib/regexp/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/regexp/ + - /influxdb/v2.0/reference/flux/stdlib/regexp/ + - /influxdb/cloud/reference/flux/stdlib/regexp/ + related: + - /flux/v0.x/data-types/basic/regexp/ + +/flux/v0.x/stdlib/regexp/compile.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/regexp/compile/ + - /influxdb/v2.0/reference/flux/stdlib/regexp/compile/ + - /influxdb/cloud/reference/flux/stdlib/regexp/compile/ + related: + - /flux/v0.x/data-types/basic/regexp/ + +/flux/v0.x/stdlib/regexp/findstring.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/regexp/findstring/ + - /influxdb/v2.0/reference/flux/stdlib/regexp/findstring/ + - /influxdb/cloud/reference/flux/stdlib/regexp/findstring/ + related: + - /flux/v0.x/stdlib/regexp/splitregexp + - /flux/v0.x/data-types/basic/regexp/ + +/flux/v0.x/stdlib/regexp/findstringindex.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/regexp/findstringindex/ + - /influxdb/v2.0/reference/flux/stdlib/regexp/findstringindex/ + - /influxdb/cloud/reference/flux/stdlib/regexp/findstringindex/ + related: + - /flux/v0.x/stdlib/regexp/compile/ + - /flux/v0.x/data-types/basic/regexp/ + +/flux/v0.x/stdlib/regexp/getstring.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/regexp/getstring/ + - /influxdb/v2.0/reference/flux/stdlib/regexp/getstring/ + - /influxdb/cloud/reference/flux/stdlib/regexp/getstring/ + related: + - /flux/v0.x/stdlib/regexp/compile/ + - /flux/v0.x/data-types/basic/regexp/ + +/flux/v0.x/stdlib/regexp/matchregexpstring.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/regexp/matchregexpstring/ + - /influxdb/v2.0/reference/flux/stdlib/regexp/matchregexpstring/ + - /influxdb/cloud/reference/flux/stdlib/regexp/matchregexpstring/ + related: + - /flux/v0.x/data-types/basic/regexp/ + +/flux/v0.x/stdlib/regexp/quotemeta.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/regexp/quotemeta/ + - /influxdb/v2.0/reference/flux/stdlib/regexp/quotemeta/ + - /influxdb/cloud/reference/flux/stdlib/regexp/quotemeta/ + related: + - /flux/v0.x/data-types/basic/regexp/ + +/flux/v0.x/stdlib/regexp/replaceallstring.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/regexp/replaceallstring/ + - /influxdb/v2.0/reference/flux/stdlib/regexp/replaceallstring/ + - /influxdb/cloud/reference/flux/stdlib/regexp/replaceallstring/ + related: + - /flux/v0.x/data-types/basic/regexp/ + +/flux/v0.x/stdlib/regexp/splitregexp.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/regexp/splitregexp/ + - /influxdb/v2.0/reference/flux/stdlib/regexp/splitregexp/ + - /influxdb/cloud/reference/flux/stdlib/regexp/splitregexp/ + related: + - /flux/v0.x/data-types/basic/regexp/ + +/flux/v0.x/stdlib/runtime/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/runtime/ + - /influxdb/v2.0/reference/flux/stdlib/runtime/ + - /influxdb/cloud/reference/flux/stdlib/runtime/ + +/flux/v0.x/stdlib/runtime/version.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/runtime/version/ + - /influxdb/v2.0/reference/flux/stdlib/runtime/version/ + - /influxdb/cloud/reference/flux/stdlib/runtime/version/ + +/flux/v0.x/stdlib/sampledata/_index.md: | + related: + - /flux/v0.x/stdlib/influxdata/influxdb/sample/ + +/flux/v0.x/stdlib/sampledata/bool.md: | + related: + - /flux/v0.x/stdlib/influxdata/influxdb/sample/ + +/flux/v0.x/stdlib/sampledata/float.md: | + related: + - /flux/v0.x/stdlib/influxdata/influxdb/sample/ + +/flux/v0.x/stdlib/sampledata/int.md: | + related: + - /flux/v0.x/stdlib/influxdata/influxdb/sample/ + +/flux/v0.x/stdlib/sampledata/numericbool.md: | + related: + - /flux/v0.x/stdlib/influxdata/influxdb/sample/ + +/flux/v0.x/stdlib/sampledata/string.md: | + related: + - /flux/v0.x/stdlib/influxdata/influxdb/sample/ + +/flux/v0.x/stdlib/sampledata/uint.md: | + related: + - /flux/v0.x/stdlib/influxdata/influxdb/sample/ + +/flux/v0.x/stdlib/slack/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/slack/ + - /influxdb/v2.0/reference/flux/stdlib/slack/ + - /influxdb/cloud/reference/flux/stdlib/slack/ + +/flux/v0.x/stdlib/slack/endpoint.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/slack/endpoint/ + - /influxdb/v2.0/reference/flux/stdlib/slack/endpoint/ + - /influxdb/cloud/reference/flux/stdlib/slack/endpoint/ + +/flux/v0.x/stdlib/slack/message.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/slack/message/ + - /influxdb/v2.0/reference/flux/stdlib/slack/message/ + - /influxdb/cloud/reference/flux/stdlib/slack/message/ + +/flux/v0.x/stdlib/sql/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/sql/ + - /influxdb/v2.0/reference/flux/stdlib/sql/ + - /influxdb/cloud/reference/flux/stdlib/sql/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/sql/ + +/flux/v0.x/stdlib/sql/from.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/sql/from/ + - /influxdb/v2.0/reference/flux/stdlib/sql/from/ + - /influxdb/cloud/reference/flux/stdlib/sql/from/ + related: + - /flux/v0.x/query-data/sql/ + +/flux/v0.x/stdlib/sql/to.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/sql/to/ + - /influxdb/v2.0/reference/flux/stdlib/sql/to/ + - /influxdb/cloud/reference/flux/stdlib/sql/to/ + related: + - /flux/v0.x/write-data/sql/ + +/flux/v0.x/stdlib/strings/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/ + - /influxdb/v2.0/reference/flux/stdlib/strings/ + - /influxdb/cloud/reference/flux/stdlib/strings/ + +/flux/v0.x/stdlib/strings/compare.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/compare/ + - /influxdb/v2.0/reference/flux/stdlib/strings/compare/ + - /influxdb/cloud/reference/flux/stdlib/strings/compare/ + +/flux/v0.x/stdlib/strings/containsany.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/containsany/ + - /influxdb/v2.0/reference/flux/stdlib/strings/containsany/ + - /influxdb/cloud/reference/flux/stdlib/strings/containsany/ + +/flux/v0.x/stdlib/strings/containsstr.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/containsstr/ + - /influxdb/v2.0/reference/flux/stdlib/strings/containsstr/ + - /influxdb/cloud/reference/flux/stdlib/strings/containsstr/ + +/flux/v0.x/stdlib/strings/countstr.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/countstr/ + - /influxdb/v2.0/reference/flux/stdlib/strings/countstr/ + - /influxdb/cloud/reference/flux/stdlib/strings/countstr/ + +/flux/v0.x/stdlib/strings/equalfold.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/equalfold/ + - /influxdb/v2.0/reference/flux/stdlib/strings/equalfold/ + - /influxdb/cloud/reference/flux/stdlib/strings/equalfold/ + +/flux/v0.x/stdlib/strings/hasprefix.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/hasprefix/ + - /influxdb/v2.0/reference/flux/stdlib/strings/hasprefix/ + - /influxdb/cloud/reference/flux/stdlib/strings/hasprefix/ + related: + - /flux/v0.x/stdlib/strings/hassuffix + +/flux/v0.x/stdlib/strings/hassuffix.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/hassuffix/ + - /influxdb/v2.0/reference/flux/stdlib/strings/hassuffix/ + - /influxdb/cloud/reference/flux/stdlib/strings/hassuffix/ + related: + - /flux/v0.x/stdlib/strings/hasprefix + +/flux/v0.x/stdlib/strings/index-fn.md: | + aliases: + - /flux/v0.x/stdlib/strings/index-func/ + - /influxdb/v2.0/reference/flux/functions/strings/index-func/ + - /influxdb/v2.0/reference/flux/stdlib/strings/index-func/ + - /influxdb/cloud/reference/flux/stdlib/strings/index-func/ + related: + - /flux/v0.x/stdlib/strings/indexany/ + - /flux/v0.x/stdlib/strings/lastindex/ + - /flux/v0.x/stdlib/strings/lastindexany/ + +/flux/v0.x/stdlib/strings/indexany.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/indexany/ + - /influxdb/v2.0/reference/flux/stdlib/strings/indexany/ + - /influxdb/cloud/reference/flux/stdlib/strings/indexany/ + related: + - /flux/v0.x/stdlib/strings/index-fn/ + - /flux/v0.x/stdlib/strings/lastindex/ + - /flux/v0.x/stdlib/strings/lastindexany/ + +/flux/v0.x/stdlib/strings/isdigit.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/isdigit/ + - /influxdb/v2.0/reference/flux/stdlib/strings/isdigit/ + - /influxdb/cloud/reference/flux/stdlib/strings/isdigit/ + related: + - /flux/v0.x/stdlib/strings/isletter/ + +/flux/v0.x/stdlib/strings/isletter.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/isletter/ + - /influxdb/v2.0/reference/flux/stdlib/strings/isletter/ + - /influxdb/cloud/reference/flux/stdlib/strings/isletter/ + related: + - /flux/v0.x/stdlib/strings/isdigit/ + +/flux/v0.x/stdlib/strings/islower.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/islower/ + - /influxdb/v2.0/reference/flux/stdlib/strings/islower/ + - /influxdb/cloud/reference/flux/stdlib/strings/islower/ + related: + - /flux/v0.x/stdlib/strings/isupper + +/flux/v0.x/stdlib/strings/isupper.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/isupper/ + - /influxdb/v2.0/reference/flux/stdlib/strings/isupper/ + - /influxdb/cloud/reference/flux/stdlib/strings/isupper/ + related: + - /flux/v0.x/stdlib/strings/islower + +/flux/v0.x/stdlib/strings/joinstr.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/joinstr/ + - /influxdb/v2.0/reference/flux/stdlib/strings/joinstr/ + - /influxdb/cloud/reference/flux/stdlib/strings/joinstr/ + +/flux/v0.x/stdlib/strings/lastindex.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/lastindex/ + - /influxdb/v2.0/reference/flux/stdlib/strings/lastindex/ + - /influxdb/cloud/reference/flux/stdlib/strings/lastindex/ + related: + - /flux/v0.x/stdlib/strings/index-fn/ + - /flux/v0.x/stdlib/strings/indexany/ + - /flux/v0.x/stdlib/strings/lastindexany/ + +/flux/v0.x/stdlib/strings/lastindexany.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/lastindexany/ + - /influxdb/v2.0/reference/flux/stdlib/strings/lastindexany/ + - /influxdb/cloud/reference/flux/stdlib/strings/lastindexany/ + related: + - /flux/v0.x/stdlib/strings/index-fn/ + - /flux/v0.x/stdlib/strings/indexany/ + - /flux/v0.x/stdlib/strings/lastindex/ + +/flux/v0.x/stdlib/strings/repeat.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/repeat/ + - /influxdb/v2.0/reference/flux/stdlib/strings/repeat/ + - /influxdb/cloud/reference/flux/stdlib/strings/repeat/ + +/flux/v0.x/stdlib/strings/replace.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/replace/ + - /influxdb/v2.0/reference/flux/stdlib/strings/replace/ + - /influxdb/cloud/reference/flux/stdlib/strings/replace/ + related: + - /flux/v0.x/stdlib/strings/replaceall/ + +/flux/v0.x/stdlib/strings/replaceall.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/replaceall/ + - /influxdb/v2.0/reference/flux/stdlib/strings/replaceall/ + - /influxdb/cloud/reference/flux/stdlib/strings/replaceall/ + related: + - /flux/v0.x/stdlib/strings/replace/ + +/flux/v0.x/stdlib/strings/split.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/split/ + - /influxdb/v2.0/reference/flux/stdlib/strings/split/ + - /influxdb/cloud/reference/flux/stdlib/strings/split/ + related: + - /flux/v0.x/stdlib/strings/splitafter/ + - /flux/v0.x/stdlib/strings/splitaftern/ + - /flux/v0.x/stdlib/strings/splitn/ + +/flux/v0.x/stdlib/strings/splitafter.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/splitafter/ + - /influxdb/v2.0/reference/flux/stdlib/strings/splitafter/ + - /influxdb/cloud/reference/flux/stdlib/strings/splitafter/ + related: + - /flux/v0.x/stdlib/strings/split/ + - /flux/v0.x/stdlib/strings/splitaftern/ + - /flux/v0.x/stdlib/strings/splitn/ + +/flux/v0.x/stdlib/strings/splitaftern.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/splitaftern/ + - /influxdb/v2.0/reference/flux/stdlib/strings/splitaftern/ + - /influxdb/cloud/reference/flux/stdlib/strings/splitaftern/ + related: + - /flux/v0.x/stdlib/strings/split/ + - /flux/v0.x/stdlib/strings/splitafter/ + - /flux/v0.x/stdlib/strings/splitn/ + +/flux/v0.x/stdlib/strings/splitn.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/splitn/ + - /influxdb/v2.0/reference/flux/stdlib/strings/splitn/ + - /influxdb/cloud/reference/flux/stdlib/strings/splitn/ + related: + - /flux/v0.x/stdlib/strings/split/ + - /flux/v0.x/stdlib/strings/splitafter/ + - /flux/v0.x/stdlib/strings/splitaftern/ + +/flux/v0.x/stdlib/strings/strlen.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/strlen/ + - /influxdb/v2.0/reference/flux/stdlib/strings/strlen/ + - /influxdb/cloud/reference/flux/stdlib/strings/strlen/ + +/flux/v0.x/stdlib/strings/substring.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/substring/ + - /influxdb/v2.0/reference/flux/stdlib/strings/substring/ + - /influxdb/cloud/reference/flux/stdlib/strings/substring/ + +/flux/v0.x/stdlib/strings/title.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/title/ + - /influxdb/v2.0/reference/flux/stdlib/strings/title/ + - /influxdb/cloud/reference/flux/stdlib/strings/title/ + related: + - /flux/v0.x/stdlib/strings/tolower/ + - /flux/v0.x/stdlib/strings/totitle/ + - /flux/v0.x/stdlib/strings/toupper/ + +/flux/v0.x/stdlib/strings/tolower.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/tolower/ + - /influxdb/v2.0/reference/flux/stdlib/strings/tolower/ + - /influxdb/cloud/reference/flux/stdlib/strings/tolower/ + related: + - /flux/v0.x/stdlib/strings/totitle/ + - /flux/v0.x/stdlib/strings/toupper/ + - /flux/v0.x/stdlib/strings/title/ + +/flux/v0.x/stdlib/strings/totitle.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/totitle/ + - /influxdb/v2.0/reference/flux/stdlib/strings/totitle/ + - /influxdb/cloud/reference/flux/stdlib/strings/totitle/ + related: + - /flux/v0.x/stdlib/strings/toupper/ + - /flux/v0.x/stdlib/strings/tolower/ + - /flux/v0.x/stdlib/strings/title/ + +/flux/v0.x/stdlib/strings/toupper.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/toupper/ + - /influxdb/v2.0/reference/flux/stdlib/strings/toupper/ + - /influxdb/cloud/reference/flux/stdlib/strings/toupper/ + related: + - /flux/v0.x/stdlib/strings/totitle/ + - /flux/v0.x/stdlib/strings/tolower/ + - /flux/v0.x/stdlib/strings/title/ + +/flux/v0.x/stdlib/strings/trim.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/trim/ + - /influxdb/v2.0/reference/flux/stdlib/strings/trim/ + - /influxdb/cloud/reference/flux/stdlib/strings/trim/ + related: + - /flux/v0.x/stdlib/strings/trimleft/ + - /flux/v0.x/stdlib/strings/trimright/ + - /flux/v0.x/stdlib/strings/trimprefix/ + - /flux/v0.x/stdlib/strings/trimsuffix/ + - /flux/v0.x/stdlib/strings/trimspace/ + +/flux/v0.x/stdlib/strings/trimleft.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/trimleft/ + - /influxdb/v2.0/reference/flux/stdlib/strings/trimleft/ + - /influxdb/cloud/reference/flux/stdlib/strings/trimleft/ + related: + - /flux/v0.x/stdlib/strings/trim/ + - /flux/v0.x/stdlib/strings/trimright/ + - /flux/v0.x/stdlib/strings/trimprefix/ + - /flux/v0.x/stdlib/strings/trimsuffix/ + - /flux/v0.x/stdlib/strings/trimspace/ + +/flux/v0.x/stdlib/strings/trimprefix.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/trimprefix/ + - /influxdb/v2.0/reference/flux/stdlib/strings/trimprefix/ + - /influxdb/cloud/reference/flux/stdlib/strings/trimprefix/ + related: + - /flux/v0.x/stdlib/strings/trim/ + - /flux/v0.x/stdlib/strings/trimleft/ + - /flux/v0.x/stdlib/strings/trimright/ + - /flux/v0.x/stdlib/strings/trimsuffix/ + - /flux/v0.x/stdlib/strings/trimspace/ + +/flux/v0.x/stdlib/strings/trimright.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/trimright/ + - /influxdb/v2.0/reference/flux/stdlib/strings/trimright/ + - /influxdb/cloud/reference/flux/stdlib/strings/trimright/ + related: + - /flux/v0.x/stdlib/strings/trim/ + - /flux/v0.x/stdlib/strings/trimleft/ + - /flux/v0.x/stdlib/strings/trimprefix/ + - /flux/v0.x/stdlib/strings/trimsuffix/ + - /flux/v0.x/stdlib/strings/trimspace/ + +/flux/v0.x/stdlib/strings/trimspace.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/trimspace/ + - /influxdb/v2.0/reference/flux/stdlib/strings/trimspace/ + - /influxdb/cloud/reference/flux/stdlib/strings/trimspace/ + related: + - /flux/v0.x/stdlib/strings/trim/ + - /flux/v0.x/stdlib/strings/trimleft/ + - /flux/v0.x/stdlib/strings/trimright/ + - /flux/v0.x/stdlib/strings/trimprefix/ + - /flux/v0.x/stdlib/strings/trimsuffix/ + +/flux/v0.x/stdlib/strings/trimsuffix.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/strings/trimsuffix/ + - /influxdb/v2.0/reference/flux/stdlib/strings/trimsuffix/ + - /influxdb/cloud/reference/flux/stdlib/strings/trimsuffix/ + related: + - /flux/v0.x/stdlib/strings/trim/ + - /flux/v0.x/stdlib/strings/trimleft/ + - /flux/v0.x/stdlib/strings/trimright/ + - /flux/v0.x/stdlib/strings/trimprefix/ + - /flux/v0.x/stdlib/strings/trimspace/ + +/flux/v0.x/stdlib/system/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/system/ + - /influxdb/v2.0/reference/flux/stdlib/system/ + - /influxdb/cloud/reference/flux/stdlib/system/ + +/flux/v0.x/stdlib/system/time.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/misc/systemtime + - /influxdb/v2.0/reference/flux/functions/built-in/misc/systemtime + - /influxdb/v2.0/reference/flux/functions/system/time/ + - /influxdb/v2.0/reference/flux/stdlib/system/time/ + - /influxdb/cloud/reference/flux/stdlib/system/time/ + related: + - /flux/v0.x/stdlib/universe/now/ + - /flux/v0.x/stdlib/universe/today/ + +/flux/v0.x/stdlib/testing/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/testing/ + - /influxdb/v2.0/reference/flux/stdlib/testing/ + - /influxdb/cloud/reference/flux/stdlib/testing/ + +/flux/v0.x/stdlib/testing/assertempty.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/testing/assertempty/ + - /influxdb/v2.0/reference/flux/stdlib/testing/assertempty/ + - /influxdb/cloud/reference/flux/stdlib/testing/assertempty/ + +/flux/v0.x/stdlib/testing/assertequals.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/tests/assertequals + - /influxdb/v2.0/reference/flux/functions/testing/assertequals/ + - /influxdb/v2.0/reference/flux/stdlib/testing/assertequals/ + - /influxdb/cloud/reference/flux/stdlib/testing/assertequals/ + +/flux/v0.x/stdlib/testing/benchmark.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/testing/benchmark/ + - /influxdb/cloud/reference/flux/stdlib/testing/benchmark/ + +/flux/v0.x/stdlib/testing/diff.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/testing/diff/ + - /influxdb/v2.0/reference/flux/stdlib/testing/diff/ + - /influxdb/cloud/reference/flux/stdlib/testing/diff/ + +/flux/v0.x/stdlib/testing/inspect.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/testing/inspect/ + - /influxdb/cloud/reference/flux/stdlib/testing/inspect/ + +/flux/v0.x/stdlib/testing/load.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/testing/load/ + - /influxdb/cloud/reference/flux/stdlib/testing/load/ + +/flux/v0.x/stdlib/testing/run.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/testing/run/ + - /influxdb/cloud/reference/flux/stdlib/testing/run/ + +/flux/v0.x/stdlib/universe/_index.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/ + - /influxdb/cloud/reference/flux/stdlib/built-in/ + +/flux/v0.x/stdlib/universe/aggregatewindow.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/aggregatewindow + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/aggregatewindow/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/aggregatewindow/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/aggregatewindow/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/window-aggregate/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#aggregations, InfluxQL – Aggregate functions + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-group-by-clause, InfluxQL – GROUP BY time() + +/flux/v0.x/stdlib/universe/bool.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/bool/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/bool/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/bool/ + related: + - /flux/v0.x/data-types/basic/bool/ + - /flux/v0.x/stdlib/universe/tobool/ + +/flux/v0.x/stdlib/universe/bottom.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/bottom + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/bottom/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/bottom/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/bottom/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#bottom, InfluxQL – BOTTOM() + +/flux/v0.x/stdlib/universe/bytes.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/bytes/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/bytes/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/bytes/ + related: + - /flux/v0.x/data-types/basic/bytes/ + +/flux/v0.x/stdlib/universe/chandemomentumoscillator.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/chandemomentumoscillator/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/chandemomentumoscillator/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/chandemomentumoscillator/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/chandemomentumoscillator/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#triple-exponential-moving-average, InfluxQL CHANDE_MOMENTUM_OSCILLATOR() + +/flux/v0.x/stdlib/universe/columns.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/columns + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/columns/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/columns/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/columns/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-measurements, InfluxQL – SHOW MEASUREMENTS + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-field-keys, InfluxQL – SHOW FIELD KEYS + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW TAG KEYS + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW SERIES + +/flux/v0.x/stdlib/universe/contains.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/tests/contains/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/tests/contains/ + - /influxdb/cloud/reference/flux/stdlib/built-in/tests/contains/ + related: + - /flux/v0.x/data-types/composite/array/ + +/flux/v0.x/stdlib/universe/count.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/count + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/count/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/count/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#count, InfluxQL – COUNT() + - /flux/v0.x/stdlib/experimental/count/ + +/flux/v0.x/stdlib/universe/cov.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/cov + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/cov/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/cov/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/cov/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/cov/ + related: + - /flux/v0.x/stdlib/universe/covariance/ + +/flux/v0.x/stdlib/universe/covariance.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/covariance + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/covariance/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/covariance/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/covariance/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/covariance/ + related: + - /flux/v0.x/stdlib/universe/cov/ + +/flux/v0.x/stdlib/universe/cumulativesum.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/cumulativesum + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/cumulativesum/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/cumulativesum/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/cumulativesum/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/cumulativesum/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#cumulative-sum, InfluxQL – CUMULATIVE_SUM() + +/flux/v0.x/stdlib/universe/derivative.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/derivative + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/derivative/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/derivative/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/derivative/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/rate/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#derivative, InfluxQL – DERIVATIVE() + +/flux/v0.x/stdlib/universe/difference.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/difference + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/difference/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/difference/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/difference/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#difference, InfluxQL – DIFFERENCE() + +/flux/v0.x/stdlib/universe/distinct.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/distinct + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/distinct/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/distinct/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/distinct/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#distinct, InfluxQL – DISTINCT() + +/flux/v0.x/stdlib/universe/doubleema.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/doubleema/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/doubleema/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/doubleema/ + related: + - /flux/v0.x/stdlib/universe/movingaverage/ + - /flux/v0.x/stdlib/universe/tripleema/ + - /flux/v0.x/stdlib/universe/timedmovingaverage/ + - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#double-exponential-moving-average, InfluxQL DOUBLE_EXPONENTIAL_MOVING_AVERAGE() + +/flux/v0.x/stdlib/universe/drop.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/drop + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/drop/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/drop/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/drop/ + related: + - /flux/v0.x/stdlib/universe/keep/ + +/flux/v0.x/stdlib/universe/duplicate.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/duplicate + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/duplicate/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/duplicate/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/duplicate/ + +/flux/v0.x/stdlib/universe/duration.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/duration/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/duration/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/duration/ + related: + - /flux/v0.x/data-types/basic/duration/ + +/flux/v0.x/stdlib/universe/elapsed.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/elapsed/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/elapsed/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/elapsed/ + related: + - /flux/v0.x/stdlib/contrib/tomhollingworth/events/duration/ + +/flux/v0.x/stdlib/universe/exponentialmovingaverage.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/ + related: + - /flux/v0.x/stdlib/universe/movingaverage/ + - /flux/v0.x/stdlib/universe/timedmovingaverage/ + - /flux/v0.x/stdlib/universe/doubleema/ + - /flux/v0.x/stdlib/universe/tripleema/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#exponential-moving-average, InfluxQL EXPONENTIAL_MOVING_AVERAGE() + +/flux/v0.x/stdlib/universe/fill.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/fill + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/fill/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/fill/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/fill/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/fill/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#group-by-time-intervals-and-fill, InfluxQL – FILL + +/flux/v0.x/stdlib/universe/filter.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/filter + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/filter/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/filter/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/filter/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/query-fields/ + - /{{< latest "influxdb" >}}/query-data/flux/conditional-logic/ + - /{{< latest "influxdb" >}}/query-data/flux/exists/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-basic-select-statement, InfluxQL – SELECT + +/flux/v0.x/stdlib/universe/findcolumn.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ + +/flux/v0.x/stdlib/universe/findrecord.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ + +/flux/v0.x/stdlib/universe/first.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/first + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/first/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/first/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/first/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/first-last/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#first, InfluxQL – FIRST() + +/flux/v0.x/stdlib/universe/float.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/float/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/float/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/float/ + related: + - /flux/v0.x/data-types/basic/float/ + - /flux/v0.x/stdlib/universe/tofloat/ + +/flux/v0.x/stdlib/universe/getcolumn.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/stream-table/getcolumn/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ + +/flux/v0.x/stdlib/universe/getrecord.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/stream-table/getrecord/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ + +/flux/v0.x/stdlib/universe/group.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/group + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/group/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/group/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/group/ + related: + - /flux/v0.x/get-started/data-model/#restructure-tables, Data model - Restructure tables + - /{{< latest "influxdb" >}}/query-data/flux/group-data/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-group-by-clause, InfluxQL – GROUP BY + +/flux/v0.x/stdlib/universe/highestaverage.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/highestaverage + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/highestaverage/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestaverage/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/highestaverage/ + +/flux/v0.x/stdlib/universe/highestcurrent.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/highestcurrent + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/highestcurrent/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestcurrent/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/highestcurrent/ + +/flux/v0.x/stdlib/universe/highestmax.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/highestmax + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/highestmax/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestmax/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/highestmax/ + +/flux/v0.x/stdlib/universe/histogram.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/histogram + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/histogram/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/histogram/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/histogram/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/histograms/ + +/flux/v0.x/stdlib/universe/histogramquantile.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/histogramquantile + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/histogramquantile/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/histogramquantile/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/histogramquantile/ + related: + - /flux/v0.x/stdlib/experimental/histogramquantile/ + +/flux/v0.x/stdlib/universe/holtwinters.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/holtwinters + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/holtwinters/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/holtwinters/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/holtwinters/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/holtwinters/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#holt-winters, InfluxQL HOLT_WINTERS() + +/flux/v0.x/stdlib/universe/hourselection.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/hourselection + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/hourselection/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/hourselection/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/hourselection/ + +/flux/v0.x/stdlib/universe/increase.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/increase + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/increase/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/increase/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/increase/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/increase/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/increase/ + +/flux/v0.x/stdlib/universe/int.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/int/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/int/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/int/ + related: + - /flux/v0.x/data-types/basic/int/ + - /flux/v0.x/stdlib/universe/toint/ + +/flux/v0.x/stdlib/universe/integral.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/integral + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/integral/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/integral/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/integral/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#integral, InfluxQL – INTEGRAL() + - /flux/v0.x/stdlib/experimental/integral/ + +/flux/v0.x/stdlib/universe/join.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/join + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/join/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/join/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/join/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/join/ + - /flux/v0.x/stdlib/universe/union/ + +/flux/v0.x/stdlib/universe/kaufmansama.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/kaufmansama/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmansama/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/kaufmansama/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/kaufmansama/ + related: + - /flux/v0.x/stdlib/universe/kaufmanser/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#kaufmans-adaptive-moving-average, InfluxQL KAUFMANS_ADAPTIVE_MOVING_AVERAGE() + - /flux/v0.x/stdlib/experimental/kaufmansama/ + +/flux/v0.x/stdlib/universe/kaufmanser.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/kaufmanser/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmanser/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/kaufmanser/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/kaufmanser/ + related: + - /flux/v0.x/stdlib/universe/kaufmansama/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#kaufmans-efficiency-ratio, InfluxQL KAUFMANS_EFFICIENCY_RATIO() + +/flux/v0.x/stdlib/universe/keep.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/keep + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/keep/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keep/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/keep/ + related: + - /flux/v0.x/stdlib/universe/drop/ + +/flux/v0.x/stdlib/universe/keys.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/keys + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/keys/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keys/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/keys/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-measurements, InfluxQL – SHOW MEASUREMENTS + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-field-keys, InfluxQL – SHOW FIELD KEYS + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW TAG KEYS + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW SERIES + +/flux/v0.x/stdlib/universe/keyvalues.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/keyvalues + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/keyvalues/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keyvalues/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/keyvalues/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-measurements, InfluxQL – SHOW MEASUREMENTS + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-field-keys, InfluxQL – SHOW FIELD KEYS + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-keys, InfluxQL – SHOW TAG KEYS + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-tag-values, InfluxQL – SHOW TAG VALUES + - /{{< latest "influxdb" "v1" >}}/query_language/explore-schema/#show-serie, InfluxQL – SHOW SERIES + +/flux/v0.x/stdlib/universe/last.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/last + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/last/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/last/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/first-last/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#last, InfluxQL – LAST() + +/flux/v0.x/stdlib/universe/length.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/length/ + - /influxdb/cloud/reference/flux/stdlib/built-in/misc/length/ + related: + - /flux/v0.x/data-types/composite/array/ + +/flux/v0.x/stdlib/universe/limit.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/limit + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/limit/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/limit/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/limit/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/sort-limit/ + - /flux/v0.x/stdlib/universe/tail/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-limit-and-slimit-clauses, InfluxQL LIMIT + +/flux/v0.x/stdlib/universe/linearbins.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/misc/linearbins + - /influxdb/v2.0/reference/flux/functions/built-in/misc/linearbins/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/linearbins/ + - /influxdb/cloud/reference/flux/stdlib/built-in/misc/linearbins/ + +/flux/v0.x/stdlib/universe/logarithmicbins.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/misc/logarithmicbins + - /influxdb/v2.0/reference/flux/functions/built-in/misc/logarithmicbins/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/logarithmicbins/ + - /influxdb/cloud/reference/flux/stdlib/built-in/misc/logarithmicbins/ + +/flux/v0.x/stdlib/universe/lowestaverage.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/lowestaverage + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/lowestaverage/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestaverage/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/lowestaverage/ + +/flux/v0.x/stdlib/universe/lowestcurrent.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/lowestcurrent + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/lowestcurrent/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestcurrent/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/lowestcurrent/ + +/flux/v0.x/stdlib/universe/lowestmin.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/lowestmin + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/lowestmin/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestmin/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/lowestmin/ + +/flux/v0.x/stdlib/universe/map.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/map + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/map/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/map/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/conditional-logic/ + - /{{< latest "influxdb" >}}/query-data/flux/mathematic-operations/ + - /flux/v0.x/stdlib/contrib/jsternberg/rows/map/ + +/flux/v0.x/stdlib/universe/max.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/max + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/max/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/max/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/max/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#max, InfluxQL – MAX() + +/flux/v0.x/stdlib/universe/mean.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/mean + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/mean/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mean/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/mean/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#mean, InfluxQL – MEAN() + - /flux/v0.x/stdlib/experimental/mean/ + +/flux/v0.x/stdlib/universe/median.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/median + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/median/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/median/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/median/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/median/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#median, InfluxQL – MEDIAN() + +/flux/v0.x/stdlib/universe/min.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/min + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/min/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/min/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/min/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#min, InfluxQL – MIN() + +/flux/v0.x/stdlib/universe/mode.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/mode/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mode/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/mode/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#mode, InfluxQL – MODE() + - /flux/v0.x/stdlib/experimental/mode/ + +/flux/v0.x/stdlib/universe/movingaverage.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage/ + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/movingaverage/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/movingaverage/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/movingaverage/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/moving-average/ + - /flux/v0.x/stdlib/universe/timedmovingaverage/ + - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ + - /flux/v0.x/stdlib/universe/doubleema/ + - /flux/v0.x/stdlib/universe/tripleema/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE() + +/flux/v0.x/stdlib/universe/now.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/misc/now/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/now/ + - /influxdb/cloud/reference/flux/stdlib/built-in/misc/now/ + related: + - /flux/v0.x/stdlib/universe/today/ + - /flux/v0.x/stdlib/system/time/ + +/flux/v0.x/stdlib/universe/pearsonr.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/pearsonr + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/pearsonr/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/pearsonr/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/pearsonr/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/pearsonr/ + +/flux/v0.x/stdlib/universe/pivot.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/pivot + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/pivot/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/pivot/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/pivot/ + +/flux/v0.x/stdlib/universe/quantile.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/percentile + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/percentile + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/quantile/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/quantile/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/quantile/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/percentile-quantile/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#percentile, InfluxQL – PERCENTILE() + - /flux/v0.x/stdlib/experimental/quantile/ + +/flux/v0.x/stdlib/universe/range.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/range + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/range/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/range/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/range/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-where-clause, InfluxQL – WHERE + +/flux/v0.x/stdlib/universe/reduce.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/reduce/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/reduce/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/reduce/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/custom-functions/custom-aggregate/ + - /{{< latest "influxdb" >}}/query-data/flux/conditional-logic/ + +/flux/v0.x/stdlib/universe/relativestrengthindex.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/relativestrengthindex/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/relativestrengthindex/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/relativestrengthindex/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/relativestrengthindex/ + related: + - /flux/v0.x/stdlib/universe/movingaverage/ + - /flux/v0.x/stdlib/universe/timedmovingaverage/ + - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#relative-strength-index, InfluxQL RELATIVE_STRENGTH_INDEX() + +/flux/v0.x/stdlib/universe/rename.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/rename + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/rename/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/rename/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/rename/ + +/flux/v0.x/stdlib/universe/sample.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/sample + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/sample/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/sample/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/sample/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#sample, InfluxQL – SAMPLE() + +/flux/v0.x/stdlib/universe/set.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/set + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/set/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/set/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/set/ + +/flux/v0.x/stdlib/universe/skew.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/skew + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/skew/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/skew/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/skew/ + related: + - /flux/v0.x/stdlib/experimental/skew/ + +/flux/v0.x/stdlib/universe/sort.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/sort + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/sort/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/sort/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/sort/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/sort-limit/ + +/flux/v0.x/stdlib/universe/spread.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/spread + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/spread/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/spread/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/spread/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#spread, InfluxQL – SPREAD() + - /flux/v0.x/stdlib/experimental/spread/ + +/flux/v0.x/stdlib/universe/statecount.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/statecount + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/statecount/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/statecount/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/statecount/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/monitor-states/ + +/flux/v0.x/stdlib/universe/stateduration.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/stateduration + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/stateduration/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stateduration/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stateduration/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/monitor-states/ + - /flux/v0.x/stdlib/contrib/tomhollingworth/events/duration/ + +/flux/v0.x/stdlib/universe/stddev.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/stddev + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/stddev/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/stddev/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/stddev/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#stddev, InfluxQL – STDDEV() + - /flux/v0.x/stdlib/experimental/stddev/ + +/flux/v0.x/stdlib/universe/string.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/string/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/string/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/string/ + related: + - /flux/v0.x/data-types/basic/string/ + - /flux/v0.x/stdlib/universe/tostring/ + +/flux/v0.x/stdlib/universe/sum.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/aggregates/sum + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/sum/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/sum/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/sum/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#sum, InfluxQL – SUM() + - /flux/v0.x/stdlib/experimental/sum/ + +/flux/v0.x/stdlib/universe/tablefind.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/scalar-values/ + +/flux/v0.x/stdlib/universe/tail.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/tail/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/tail/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/tail/ + related: + - /flux/v0.x/stdlib/universe/limit/ + +/flux/v0.x/stdlib/universe/time.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/time/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/time/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/time/ + related: + - /flux/v0.x/data-types/basic/time/ + - /flux/v0.x/stdlib/universe/totime/ + +/flux/v0.x/stdlib/universe/timedmovingaverage.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/timedmovingaverage/ + related: + - /flux/v0.x/stdlib/universe/movingaverage/ + - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ + - /flux/v0.x/stdlib/universe/doubleema/ + - /flux/v0.x/stdlib/universe/tripleema/ + - /{{< latest "influxdb" >}}/query-data/flux/moving-average/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE() + +/flux/v0.x/stdlib/universe/timeshift.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/shift + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/shift + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/timeshift/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/timeshift/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/timeshift/ + +/flux/v0.x/stdlib/universe/timeweightedavg.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timeweightedavg/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/timeweightedavg/ + related: + - /flux/v0.x/stdlib/universe/integral/ + +/flux/v0.x/stdlib/universe/tobool.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/tobool + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/tobool/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/tobool/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/tobool/ + related: + - /flux/v0.x/data-types/basic/bool/ + - /flux/v0.x/stdlib/universe/bool/ + +/flux/v0.x/stdlib/universe/today.md: | + aliases: + - /influxdb/v2.0/reference/flux/stdlib/built-in/misc/today/ + - /influxdb/cloud/reference/flux/stdlib/built-in/misc/today/ + related: + - /flux/v0.x/stdlib/universe/now/ + - /flux/v0.x/stdlib/date/truncate/ + - /flux/v0.x/stdlib/system/time/ + +/flux/v0.x/stdlib/universe/tofloat.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/tofloat + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/tofloat/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/tofloat/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/tofloat/ + related: + - /flux/v0.x/data-types/basic/float/ + - /flux/v0.x/stdlib/universe/float/ + +/flux/v0.x/stdlib/universe/toint.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/toint + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/toint/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/toint/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/toint/ + related: + - /flux/v0.x/data-types/basic/int/ + - /flux/v0.x/stdlib/universe/int/ + +/flux/v0.x/stdlib/universe/top.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/top + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/top/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/top/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/top/ + +/flux/v0.x/stdlib/universe/tostring.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/tostring + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/tostring/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/tostring/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/tostring/ + related: + - /flux/v0.x/data-types/basic/string/ + +/flux/v0.x/stdlib/universe/totime.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/totime + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/totime/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/totime/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/totime/ + related: + - /flux/v0.x/data-types/basic/time/ + - /flux/v0.x/stdlib/universe/time/ + +/flux/v0.x/stdlib/universe/touint.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/type-conversions/touint + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/touint/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/touint/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/touint/ + related: + - /flux/v0.x/data-types/basic/uint/ + - /flux/v0.x/stdlib/universe/uint/ + +/flux/v0.x/stdlib/universe/tripleema.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleema/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/tripleema/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/tripleema/ + related: + - /flux/v0.x/stdlib/universe/movingaverage/ + - /flux/v0.x/stdlib/universe/doubleema/ + - /flux/v0.x/stdlib/universe/timedmovingaverage/ + - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#triple-exponential-moving-average, InfluxQL TRIPLE_EXPONENTIAL_MOVING_AVERAGE() + +/flux/v0.x/stdlib/universe/tripleexponentialderivative.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleexponentialderivative/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleexponentialderivative/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/tripleexponentialderivative/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/tripleexponentialderivative/ + related: + - /flux/v0.x/stdlib/universe/movingaverage/ + - /flux/v0.x/stdlib/universe/doubleema/ + - /flux/v0.x/stdlib/universe/tripleema/ + - /flux/v0.x/stdlib/universe/timedmovingaverage/ + - /flux/v0.x/stdlib/universe/exponentialmovingaverage/ + - /{{< latest "influxdb" "v1" >}}/query_language/functions/#triple-exponential-derivative, InfluxQL TRIPLE_EXPONENTIAL_DERIVATIVE() + +/flux/v0.x/stdlib/universe/truncatetimecolumn.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/truncatetimecolumn/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/truncatetimecolumn/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/truncatetimecolumn/ + related: + - /flux/v0.x/stdlib/date/truncate/ + +/flux/v0.x/stdlib/universe/uint.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/type-conversions/uint/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/uint/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/type-conversions/uint/ + related: + - /flux/v0.x/data-types/basic/uint/ + - /flux/v0.x/stdlib/universe/touint/ + +/flux/v0.x/stdlib/universe/union.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/union + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/union/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/union/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/union/ + related: + - /flux/v0.x/stdlib/universe/join/ + +/flux/v0.x/stdlib/universe/unique.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/selectors/unique + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/unique/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/unique/ + +/flux/v0.x/stdlib/universe/window.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/transformations/window + - /influxdb/v2.0/reference/flux/functions/built-in/transformations/window/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/transformations/window/ + - /influxdb/cloud/reference/flux/stdlib/built-in/transformations/window/ + related: + - /{{< latest "influxdb" >}}/query-data/flux/window-aggregate/ + - /flux/v0.x/stdlib/built-in/universe/aggregatewindow/ + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-group-by-clause, InfluxQL – GROUP BY time() + +/flux/v0.x/stdlib/universe/yield.md: | + aliases: + - /influxdb/v2.0/reference/flux/functions/outputs/yield + - /influxdb/v2.0/reference/flux/functions/built-in/outputs/yield/ + - /influxdb/v2.0/reference/flux/stdlib/built-in/outputs/yield/ + - /influxdb/cloud/reference/flux/stdlib/built-in/outputs/yield/ + related: + - /{{< latest "influxdb" "v1" >}}/query_language/explore-data/#the-basic-select-statement, InfluxQL – SELECT AS diff --git a/inject-flux-stdlib-frontmatter.js b/inject-flux-stdlib-frontmatter.js new file mode 100644 index 000000000..bc4b79d40 --- /dev/null +++ b/inject-flux-stdlib-frontmatter.js @@ -0,0 +1,46 @@ +/* +This script appends frontmatter to Flux standard library documentation that +can't be generated in the Flux auto-gen process. +The script iterates through file paths defined in data/flux_stdlib_frontmatter.yml +and appends the associated frontmatter. +*/ + +const yaml = require('js-yaml') +const fs = require('fs') + +// Check to see if frontmatter has already been injected +hasFrontmatter = () => { + var sampleFile = fs.readFileSync("./content/flux/v0.x/stdlib/array/_index.md").toString(); + + return sampleFile.includes("aliases:"); +} + +// Exit with success +exitWithSuccess = (message) => { + console.log(message); + process.exit(0); +} + +injectFrontmatter = () => { + const frontmatter = yaml.load(fs.readFileSync('./data/flux_stdlib_frontmatter.yml', 'utf8')) + + for (const [key, value] of Object.entries(frontmatter)) { + + let pageText = fs.readFileSync(`./content${key}`).toString() + let i = 0 + + pageText = pageText.replace(/^---/gm, (match) => ++i === 2 ? `${value}---` : match); + + fs.writeFile(`./content${key}`, pageText, (err) => { + if (err) throw err; + }); + } + + console.log("Flux standard library frontmatter injected!"); +} + +if ( hasFrontmatter() ) { + exitWithSuccess("Flux standard library frontmatter has already been injected. Skipping..."); +} else { + injectFrontmatter(); +} diff --git a/layouts/partials/article.html b/layouts/partials/article.html index a3522bcbf..45fe2815d 100644 --- a/layouts/partials/article.html +++ b/layouts/partials/article.html @@ -10,6 +10,7 @@ {{ partial "article/flux-contrib.html" . }} {{ partial "article/prepend.html" . }} {{ partial "article/content.html" . }} + {{ partial "article/contributors.html" . }} {{ partial "article/append.html" . }} {{ partial "article/related.html" . }} {{ partial "article/tags.html" . }} diff --git a/layouts/partials/article/contributors.html b/layouts/partials/article/contributors.html new file mode 100644 index 000000000..ba9d98c22 --- /dev/null +++ b/layouts/partials/article/contributors.html @@ -0,0 +1,11 @@ + +{{ if .Params.contributors }} +
+

Package author and maintainer

+

+ {{ range .Params.contributors }} + {{ . | markdownify }}
+ {{ end }} +

+
+{{ end }} \ No newline at end of file diff --git a/layouts/partials/article/flux-contrib.html b/layouts/partials/article/flux-contrib.html index 81f1fadd3..8f06e43e7 100644 --- a/layouts/partials/article/flux-contrib.html +++ b/layouts/partials/article/flux-contrib.html @@ -4,10 +4,10 @@ {{ if in .RelPermalink $contribPath }} {{ if not (eq .RelPermalink $contribPath) }} {{ if eq .Kind "page" }} - {{ $name := replaceRE `^\w*\.\w*\(\)` "$0" .Title }} + {{ $name := replaceRE " function" "" .Title }}

- The {{ $name | safeHTML }} is a user-contributed function maintained by + {{ $name | safeHTML }} is a user-contributed function maintained by the package author and can be updated or removed at any time.

diff --git a/layouts/partials/article/flux-experimental.html b/layouts/partials/article/flux-experimental.html index eb702c2b3..43d967b4b 100644 --- a/layouts/partials/article/flux-experimental.html +++ b/layouts/partials/article/flux-experimental.html @@ -1,14 +1,14 @@ {{ $currentVersion := index (findRE "[^/]+.*?" .RelPermalink) 1 }} -{{ $expRiskURL := print "/flux/v0.x/stdlib/experimental/#experimental-functions-are-subject-to-change" }} +{{ $expRiskURL := print "/flux/v0.x/stdlib/experimental/#experimental-packages-are-subject-to-change" }} {{ $expPath := print "/flux/v0.x/stdlib/experimental/" }} {{ if in .RelPermalink $expPath }} {{ if not (eq .RelPermalink $expPath) }} {{ if eq .Kind "page" }} - {{ $name := replaceRE `^\w*\.\w*\(\)` "$0" .Title }} + {{ $name := replaceRE " function" "" .Title }}

- The {{ $name | safeHTML }} is {{ if in $name "experimental" }}{{ else }}experimental and{{ end }} subject to change at any time. + {{ $name | safeHTML }} is {{ if in $name "experimental" }}{{ else }}experimental and{{ end }} subject to change at any time. By using this function, you accept the risks of experimental functions.

diff --git a/package.json b/package.json index ebcb5d9fc..de1eda30b 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "autoprefixer": "^10.2.5", "hugo-extended": "^0.92.1", "postcss": "^8.2.13", - "postcss-cli": "^9.1.0" + "postcss-cli": "^9.1.0", + "js-yaml": "^4.1.0" } } diff --git a/yarn.lock b/yarn.lock index b2a67c0d8..baec9f3aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -135,6 +135,11 @@ anymatch@~3.1.2: normalize-path "^3.0.0" picomatch "^2.0.4" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" @@ -842,6 +847,13 @@ js-tokens@^4.0.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + json-buffer@3.0.1, json-buffer@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13"