Query data from m3db

196 views
Skip to first unread message

Luu Nghia

unread,
Nov 29, 2019, 3:31:22 AM11/29/19
to M3
Hi Supporter,

I am a beginner in m3db. I having some trouble about query data. I have also referred https://m3db.github.io/m3/how_to/single_node/ but cannot adjust it on my way.
How can I add/adjust a condition from the  "query" ? Where can I find an example of this format of which I can base my code?

The following is what I want to query
Ex: "SELECT * FROM City WHERE city_name = 'new_york'" => I want to query data in m3db as this command in sql
curl -sS -X POST http://localhost:9003/query -d '{
  "namespace": "default",
  "query": {
    "regexp": {
      "field": "city",
      "regexp": ".*"
    }
  },
  "rangeStart": 0,
  "rangeEnd": '"$(date "+%s")"'
}' | jq .
Thanks & Best regards,
Nghia Luu

Luu Nghia

unread,
Nov 29, 2019, 10:24:19 AM11/29/19
to M3
curl -sS -X POST http://localhost:9003/query -d '{
  "namespace": "default",
  "query": {
    "regexp": {
      "field": "city",
      "regexp": ".*"
    }
  },
  "rangeStart": 0,
  "rangeEnd": '"$(date "+%s")"'
}' | jq .
I really don't know the rule/format of the above query. So I cannot adjust on my way.

Please help me about this issue.

Thanks.

Benjamin Raskin

unread,
Dec 1, 2019, 3:32:35 PM12/1/19
to Luu Nghia, M3
Hi Nghia,

What you'll want to do is use the coordinator/query endpoint that should be exposed on port 7201 (it's embedded in the single node m3db binary). We support PromQL and you can take a look at the documentation for the API here. Basically your curl will look something like the following. This will return all time series that have the tag `city=new_york`.
curl 'http://localhost:7201/api/v1/query_range?query={city="new_york"}&start=<start>&end=<end>&step=15s'
Thanks,
Ben

--
You received this message because you are subscribed to the Google Groups "M3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to m3db+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/m3db/b1181bbf-a633-4e96-b4f2-553b46bf760a%40googlegroups.com.


--

Benjamin Raskin

Sales Engineer

www.chronosphere.io

Luu Nghia

unread,
Dec 2, 2019, 9:52:49 PM12/2/19
to M3
Wow, Great! Thank you for your support, Ben.

I still have a issue related to query data. With your suggestion, It query data on default namespace, I don't know the way that query data on other namespace. 
Ex: I am using "test" namespace, not use "default" namespace.

How can I switch other namespace if use the query that you suggested?
And can we not adjust the following to query data?

http://localhost:9003/query -d '{
  "namespace": "default",
  "query": {
    "regexp": {
      "field": "city",
      "regexp": ".*"
    }
  },
  "rangeStart": 0,
  "rangeEnd": '"$(date "+%s")"'
}

Luu Nghia

unread,
Dec 4, 2019, 9:49:35 AM12/4/19
to M3
Hi Ben & others,

I'm looking forward to your support.

Please help me.

Thanks,
Nghia Luu

Benjamin Raskin

unread,
Dec 4, 2019, 9:51:44 AM12/4/19
to Luu Nghia, M3
Hey, apologies, just saw your previous email. Can you join our Slack channel? Might be easier to help debug in real time.

Ben

--
You received this message because you are subscribed to the Google Groups "M3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to m3db+uns...@googlegroups.com.

Luu Nghia

unread,
Dec 4, 2019, 10:08:37 AM12/4/19
to M3
Thank you so much, Ben!
To unsubscribe from this group and stop receiving emails from it, send an email to m3...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages