-
Notifications
You must be signed in to change notification settings - Fork 3
query
LUYONGQIANG edited this page Dec 3, 2019
·
3 revisions
/api/query
Probably the most useful endpoint in the API, /api/query enables extracting data from the storage system in various formats determined by the serializer selected. Queries can be submitted via the 1.0 query string format or body content.
OpenTsdbClient apiClient = new OpenTsdbClient();
QueryRequest quest = new QueryRequest();
quest.Start = ConvertDateTimeInt(DateTime.Now.AddDays(-30)).ToString();
quest.End = ConvertDateTimeInt(DateTime.Now).ToString();
var search = new Dictionary<string, string>()
{
{ "host","YL-01-01"},
{"dc","lga" }
};
quest.Queries = new SubQueryRequest[] {
new SubQueryRequest()
{
Metric = "bridge",
Rate = true,
Aggregator = "sum",
Tags = search
}
};
var result = await apiClient.PostAsync<dynamic>("/api/query", quest);
Console.WriteLine(result);
[
{
"metric": "bridge",
"tags": {},
"aggregateTags": [
"host",
"dc"
],
"dps": {
"1573796728": 3.11,
"1573796729": 1.46,
"1574325428": 0.1,
"1574325645": -0.08,
"1574325705": -0.01,
"1574325765": 0.61,
"1574325825": -0.52,
}
}
]