Feature: Netdata service widget (#2672)
parent
72efd9a08d
commit
7f621ed518
@ -0,0 +1,12 @@
|
||||
---
|
||||
title: Netdata
|
||||
description: Netdata Widget Configuration
|
||||
---
|
||||
|
||||
Allowed fields: `["warnings", "criticals"]`.
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: Netdata
|
||||
url: http://netdata.host.or.ip
|
||||
```
|
@ -0,0 +1,33 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
|
||||
const { data: netdataData, error: netdataError } = useWidgetAPI(widget, "info");
|
||||
|
||||
if (netdataError) {
|
||||
return <Container service={service} error={netdataError} />;
|
||||
}
|
||||
|
||||
if (!netdataData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="netdata.warnings" />
|
||||
<Block label="netdata.criticals" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="netdata.warnings" value={t("common.number", { value: netdataData.alarms.warning })} />
|
||||
<Block label="netdata.criticals" value={t("common.number", { value: netdataData.alarms.critical })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/v1/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
info: {
|
||||
endpoint: "info",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
Loading…
Reference in new issue