//native
type Signoz = {
apiKey: string;
baseUrl: string;
};
/**
* Add a dashboard to the system
* Add a dashboard to the system
*/
export async function main(
auth: Signoz,
body: {} & {
title: string;
description?: string;
tags?: string[];
layout: {
x?: number;
y?: number;
w?: number;
h?: number;
i?: string;
moved?: false | true;
static?: false | true;
}[];
variables?: {
key?: {
id?: string;
name?: string;
description?: string;
key?: string;
type?: "QUERY" | "CONSTANT";
queryValue?: string;
allSelected?: false | true;
customValue?: string;
multiSelect?: false | true;
order?: number;
showALLOption?: false | true;
sort?: "ASC" | "DESC";
textboxValue?: string;
};
};
widgets: {
id: string;
description?: string;
isStacked?: false | true;
nullZeroValues?: false | true;
opacity?: number;
panelTypes: "graph" | "table" | "value" | "list" | "trace";
timePreferance?: "GLOBAL_TIME";
title: string;
yAxisUnit?: string;
query: {
queryType: "builder" | "clickhouse_sql" | "promql";
promql?: {
disabled: false | true;
name: string;
query: string;
legend?: string;
}[];
clickhouse_sql?: {
disabled: false | true;
name: string;
query: string;
legend?: string;
}[];
builder?: {
queryData?: {
queryName: string;
stepInterval: number;
dataSource: "metrics" | "traces" | "logs";
aggregateOperator?:
| "noop"
| "count"
| "count_distinct"
| "sum"
| "avg"
| "min"
| "max"
| "p05"
| "p10"
| "p20"
| "p25"
| "p50"
| "p75"
| "p90"
| "p95"
| "p99"
| "rate"
| "rate_sum"
| "rate_avg"
| "rate_min"
| "rate_max";
aggregateAttribute?: {
key: string;
dataType?:
| "string"
| "int64"
| "float64"
| "bool"
| "array(string)"
| "array(int64)"
| "array(float64)"
| "array(bool)";
type?: "tag" | "resource" | "scope" | "spanSearchScope";
isColumn?: false | true;
isJSON?: false | true;
};
temporality?: "Unspecified" | "Delta" | "Cumulative";
filters?: {
op?: "AND" | "OR";
items?: {
key: {
key: string;
dataType?:
| "string"
| "int64"
| "float64"
| "bool"
| "array(string)"
| "array(int64)"
| "array(float64)"
| "array(bool)";
type?: "tag" | "resource" | "scope" | "spanSearchScope";
isColumn?: false | true;
isJSON?: false | true;
};
value?: {};
op:
| "="
| "!="
| ">"
| ">="
| "<"
| "<="
| "in"
| "nin"
| "like"
| "nlike"
| "contains"
| "ncontains"
| "regex"
| "nregex"
| "exists"
| "nexists"
| "has"
| "nhas";
}[];
};
groupBy?: {
key: string;
dataType?:
| "string"
| "int64"
| "float64"
| "bool"
| "array(string)"
| "array(int64)"
| "array(float64)"
| "array(bool)";
type?: "tag" | "resource" | "scope" | "spanSearchScope";
isColumn?: false | true;
isJSON?: false | true;
}[];
expression: string;
disabled?: false | true;
having?: {
columnName: string;
op: "=" | "!=" | ">" | ">=" | "<" | "<=" | "IN" | "NOT_IN";
value: {};
}[];
legend?: string;
limit?: number;
offset?: number;
pageSize?: number;
orderBy?: { columnName: string; order: "asc" | "desc" }[];
reduceTo?: "sum" | "avg" | "min" | "max" | "last";
selectColumns?: {
key: string;
dataType?:
| "string"
| "int64"
| "float64"
| "bool"
| "array(string)"
| "array(int64)"
| "array(float64)"
| "array(bool)";
type?: "tag" | "resource" | "scope" | "spanSearchScope";
isColumn?: false | true;
isJSON?: false | true;
}[];
timeAggregation?:
| "count"
| "count_distinct"
| "sum"
| "avg"
| "min"
| "max"
| "rate"
| "latest"
| "increase";
spaceAggregation?:
| "count"
| "sum"
| "avg"
| "min"
| "max"
| "p50"
| "p75"
| "p90"
| "p95"
| "p99";
seriesAggregation?: "sum" | "avg" | "min" | "max";
functions?: {
name:
| "cutOffMin"
| "cutOffMax"
| "clampMin"
| "clampMax"
| "absolute"
| "runningDiff"
| "log2"
| "log10"
| "cumSum"
| "ewma3"
| "ewma5"
| "ewma7"
| "median3"
| "median5"
| "median7"
| "timeShift"
| "anomaly";
args?: {}[];
namedArgs?: {};
}[];
};
queryFormulas?: {
queryName: string;
stepInterval: number;
dataSource: "metrics" | "traces" | "logs";
aggregateOperator?:
| "noop"
| "count"
| "count_distinct"
| "sum"
| "avg"
| "min"
| "max"
| "p05"
| "p10"
| "p20"
| "p25"
| "p50"
| "p75"
| "p90"
| "p95"
| "p99"
| "rate"
| "rate_sum"
| "rate_avg"
| "rate_min"
| "rate_max";
aggregateAttribute?: {
key: string;
dataType?:
| "string"
| "int64"
| "float64"
| "bool"
| "array(string)"
| "array(int64)"
| "array(float64)"
| "array(bool)";
type?: "tag" | "resource" | "scope" | "spanSearchScope";
isColumn?: false | true;
isJSON?: false | true;
};
temporality?: "Unspecified" | "Delta" | "Cumulative";
filters?: {
op?: "AND" | "OR";
items?: {
key: {
key: string;
dataType?:
| "string"
| "int64"
| "float64"
| "bool"
| "array(string)"
| "array(int64)"
| "array(float64)"
| "array(bool)";
type?: "tag" | "resource" | "scope" | "spanSearchScope";
isColumn?: false | true;
isJSON?: false | true;
};
value?: {};
op:
| "="
| "!="
| ">"
| ">="
| "<"
| "<="
| "in"
| "nin"
| "like"
| "nlike"
| "contains"
| "ncontains"
| "regex"
| "nregex"
| "exists"
| "nexists"
| "has"
| "nhas";
}[];
};
groupBy?: {
key: string;
dataType?:
| "string"
| "int64"
| "float64"
| "bool"
| "array(string)"
| "array(int64)"
| "array(float64)"
| "array(bool)";
type?: "tag" | "resource" | "scope" | "spanSearchScope";
isColumn?: false | true;
isJSON?: false | true;
}[];
expression: string;
disabled?: false | true;
having?: {
columnName: string;
op: "=" | "!=" | ">" | ">=" | "<" | "<=" | "IN" | "NOT_IN";
value: {};
}[];
legend?: string;
limit?: number;
offset?: number;
pageSize?: number;
orderBy?: { columnName: string; order: "asc" | "desc" }[];
reduceTo?: "sum" | "avg" | "min" | "max" | "last";
selectColumns?: {
key: string;
dataType?:
| "string"
| "int64"
| "float64"
| "bool"
| "array(string)"
| "array(int64)"
| "array(float64)"
| "array(bool)";
type?: "tag" | "resource" | "scope" | "spanSearchScope";
isColumn?: false | true;
isJSON?: false | true;
}[];
timeAggregation?:
| "count"
| "count_distinct"
| "sum"
| "avg"
| "min"
| "max"
| "rate"
| "latest"
| "increase";
spaceAggregation?:
| "count"
| "sum"
| "avg"
| "min"
| "max"
| "p50"
| "p75"
| "p90"
| "p95"
| "p99";
seriesAggregation?: "sum" | "avg" | "min" | "max";
functions?: {
name:
| "cutOffMin"
| "cutOffMax"
| "clampMin"
| "clampMax"
| "absolute"
| "runningDiff"
| "log2"
| "log10"
| "cumSum"
| "ewma3"
| "ewma5"
| "ewma7"
| "median3"
| "median5"
| "median7"
| "timeShift"
| "anomaly";
args?: {}[];
namedArgs?: {};
}[];
};
};
};
}[];
},
) {
const url = new URL(`https://${auth.baseUrl}/api/v1/dashboards`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"SIGNOZ-API-KEY": auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 235 days ago