Attempt to make *hastic* client which works with old version of hastic-server https://code.corpglory.net/hastic/hastic-server
based on new version of hastic client from https://code.corpglory.net/hastic/hastic
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
746 B
24 lines
746 B
// TODO: https://github.com/hastic/hastic-grafana-app/blob/c67bd8af140105c36f24c875187929869e48e51e/src/panel/graph_panel/services/analytic_service.ts |
|
|
|
import { API_URL } from "@/config"; |
|
import axios from 'axios'; |
|
|
|
import _ from 'lodash'; |
|
|
|
const METRICS_API_URL = API_URL + "metric/"; |
|
|
|
export async function getMetrics(from: number, to: number, step: number) { |
|
if(from >= to) { |
|
throw new Error("`from` can`t be less than `to`"); |
|
} |
|
if(step < 1) { |
|
throw new Error("`step` can`t be less than 1"); |
|
} |
|
|
|
const uri = METRICS_API_URL + `?from=${from}&to=${to}&step=${step}`; |
|
const res = await axios.get(uri); |
|
|
|
const target = _.keys(res["data"]["data"])[0]; |
|
const values = res["data"]["data"][target]; |
|
return [target, values]; |
|
}
|
|
|