Code Monkey home page Code Monkey logo

Comments (4)

docmerlin avatar docmerlin commented on July 17, 2024

This is a similar but not directly related issue, with the API. influxdata/influxdb#20048

from influx-cli.

will-influxdata avatar will-influxdata commented on July 17, 2024

@danatinflux
Could really use this as a parameter for the netreo migration(https://github.com/influxdata/InfluxDB-Cloud-2-Migration/issues/19) They have 36 customers and 5 buckets for each. I use the customer id in the bucket name. For token and dbrp processing on the scripts, I do a bucket list, grep out the buckets and then process them. Now I get clipped at 20. You should be able to specify something like --size 500

from influx-cli.

danxmoran avatar danxmoran commented on July 17, 2024

A --size or --limit flag could be part of the solution, but not enough to fully address this; the DB backends (both OSS and Cloud) enforce a max-size on list requests to protect themselves from abuse.

To fully address this, the CLI will need to make iterative requests to the buckets API, setting after=<ID-of-last-bucket-from-previous-batch> and limit=<some-page-size>. The iteration would stop once a request returned an empty list. We could expose flags for users to control the process:

  • --limit: Limit on total number of buckets to fetch & print
  • --page-size: Value to set for limit in each HTTP request
  • --offset: Number of buckets to skip on initial request
  • --after: ID of bucket to set as after in the initial request

We'd probably want this for all of our list commands, but we see it requested most frequently for buckets so it makes sense to implement it there first as a one-off.

from influx-cli.

will-influxdata avatar will-influxdata commented on July 17, 2024

@btasker gave me a work around in python:

#!/usr/bin/env python3

import json
import requests
import sys


# https://docs.influxdata.com/influxdb/v2.0/api/#tag/Buckets
INFLUX="https://us-west-2-1.aws.cloud2.influxdata.com"
ORG="xxxx"
TOKEN="xxx"


def reqAPI(path):
    headers = {
        "Authorization": f"Token {TOKEN}"
    }

    r = requests.get(f'{INFLUX}{path}', headers=headers)
    return r.json()


def printBuckets(r):

    for bucket in r['buckets']:
        print(f"{bucket['id']}\t{bucket['name']}")


r = reqAPI('/api/v2/buckets?org={ORG}')

if r:
    while "links" in r and "next" in r['links']:
        printBuckets(r)
        r = reqAPI(r['links']['next'])

printBuckets(r)

from influx-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.