Skip to content

Commit

Permalink
Add more examples to usage.limits (influxdata#3519)
Browse files Browse the repository at this point in the history
* added more examples to usage.limits, closes influxdata#3502

* remove search.html modifications
  • Loading branch information
sanderson authored Dec 22, 2021
1 parent e34213e commit f0f9361
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
2 changes: 2 additions & 0 deletions content/flux/v0.x/stdlib/experimental/usage/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ weight: 301
flux/v0.x/tags: [functions, usage, package]
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
Expand Down
54 changes: 50 additions & 4 deletions content/flux/v0.x/stdlib/experimental/usage/limits.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ Default is `""`.

## Examples

- [Get rate limits for your InfluxDB Cloud organization](#get-rate-limits-for-your-influxdb-cloud-organization)
- [Get rate limits for a different InfluxDB Cloud organization](#get-rate-limits-for-a-different-influxdb-cloud-organization)
- [Output organization limits in a table](#output-organization-limits-in-a-table)
- [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"
Expand All @@ -94,9 +99,50 @@ 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://cloud2.influxdata.com", orgID: "x000X0x0xx0X00x0", token: token)
```

##### Output organization limits in a table
```js
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)

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: "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: "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: "task", limitName: "Max Tasks", limit: limits.task.maxTasks},
{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},
],
)
```

##### Output current cardinality with your cardinality limit
```js
import "array"
import "experimental/usage"
import "influxdata/influxdb"
import "influxdata/influxdb/secrets"

host = "https://cloud2.influxdata.com"
orgID = "x000X0x0xx0X00x0"
token = secrets.get(key: "INFLUX_TOKEN")

cardinality = (influxdb.cardinality(bucket: "example-bucket", orgID: orgID, host: host, token: token)
|> findColumn(fn: (key) => true, column: "_value"))[0]

limits = usage.limits(host: host, orgID: orgID, token: token)

array.from(rows: [{cardinality: cardinality, cardinalityLimit: limits.rate.cardinality}])
```
1 change: 1 addition & 0 deletions deploy/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ exports.handler = (event, context, callback) => {
'.eot': true,
'.ttf': true,
'.woff': true,
'.woff2': true,
'.otf': true,
'.gz': true,
'.tar': true,
Expand Down

0 comments on commit f0f9361

Please sign in to comment.