Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i create, and read data by python using CLI? #2167

Closed
Dhruvinhp opened this issue Sep 2, 2021 · 5 comments
Closed

How can i create, and read data by python using CLI? #2167

Dhruvinhp opened this issue Sep 2, 2021 · 5 comments
Labels

Comments

@Dhruvinhp
Copy link

Dhruvinhp commented Sep 2, 2021

I'm trying to save json data into the database of opentsdb, but when i try to retrieve the data that time i got this ERROR,
invalid character 'E' looking for beginning of value
i don't know what causing it! I'm using opentsdb with python,
Here is my Commands for it,
for put the data,
curl -X POST --data-binary @opentsdb.json 'https://DESC:[email protected]/api/put'

for retrieve the data,

curl --data-binary @query.json 'https://DESC:[email protected]/api/query'

and here is my Json files for enter and retrieve data,
opentsdb.json

    {
        "metric": "sys.cpu.nice",
        "timestamp": 1346846400000,
        "value": 18,
        "tags": {
           "host": "web01",
           "dc": "lga"
        }
    },
    {
        "metric": "sys.cpu.nice",
        "timestamp": 1346846800000,
        "value": 19,
        "tags": {
           "host": "web01",
           "dc": "lga"
        }
    },
    {
        "metric": "sys.cpu.nice",
        "timestamp": 1346847000000,
        "value": 20,
        "tags": {
           "host": "web01",
           "dc": "lga"
        }
    },
    {
        "metric": "sys.cpu.nice",
        "timestamp": 1346847000005,
        "value": 19,
        "tags": {
           "host": "web01",
           "dc": "lga"
        }
    },
    {
        "metric": "sys.cpu.nice",
        "timestamp": 1346846400000,
        "value": 9,
        "tags": {
           "host": "web02",
           "dc": "lga"
        }
    },
    {
        "metric": "sys.cpu.nice",
        "timestamp": 1346846800000,
        "value": 8,
        "tags": {
           "host": "web02",
           "dc": "lga"
        }
    },
    {
        "metric": "sys.cpu.nice",
        "timestamp": 1346847000000,
        "value": 7,
        "tags": {
           "host": "web02",
           "dc": "lga"
        }
    },
    {
        "metric": "sys.cpu.nice",
        "timestamp": 1346847000005,
        "value": 10,
        "tags": {
           "host": "web02",
           "dc": "lga"
        }
    }
]

query.json

    "start": 1346846000000,
    "end": 1346847300005,
    "queries": [{
        "metric": "sys.cpu.nice",
        "aggregator": "min",
        "downsample": "4m-avg",
        "tags": {
            "host": "*",
            "dc": "*"
        }
    }]
}
And also i want to perform these kind of queries by python & CLI, if you know the way to do this please share it with me, cause opentsdb don't have enough community to help us.
@manolama
Copy link
Member

Unfortunately I don't have a good Python library recommendation. I know there were a few attempts but the bits I've seen are focused on writes, not on the query side.

Where does the invalid character 'E' looking for beginning of value show up? In a TSD log or the app log? I'd try using the --data flag for CURL instead of the --data-binary flag. Then try running it from a shell with the -i flag as well to see what the response is.

@bjozet
Copy link
Contributor

bjozet commented Oct 30, 2021

@Dhruvinhp if the opentsdb.json you posted here, is the same that you use and get the error, it's malformed. Missing an opening [ at the beginning. Verify your json before posting to opentsdb maybe? :)

@langerma
Copy link

if you want to tryout: https://github.com/langerma/py-opentsdb

@Dhruvinhp
Copy link
Author

As I'm not working on this anymore I close this issue, Thanks for reaching out!

@deamerfire
Copy link

deamerfire commented Dec 9, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants