create database hiot vgroups 8 duration 1d keep 1080d;
create database system_metric vgroups 8 duration 1d keep 1080d;

CREATE TABLE hiot.`generalLog` (
    ts timestamp,
    `operator` nchar(100),
    `generalLogType` nchar(100),
    `operateObj` nchar(1000),
    `status` bool,
    `description` nchar(1000),
    `timestamp` nchar(100)
);

CREATE TABLE hiot.`field_state` (
    ts timestamp,
    `name` nchar(100),
    `value` nchar(100),
    `equipmentId` nchar(100),
    `state` bool,
    `equipmentCode` nchar(100),
    `respFailCategory` nchar(500),
    `code` nchar(100),
    `id` nchar(100)
);

CREATE TABLE hiot.`edge_status` (
    ts timestamp,
    `name` nchar(100),
    `stats` nchar(1000),
    `connectedEquipmentsIds` nchar(1000),
    `connectedConnectors` int,
    `totalFailWrite` int,
    `disconnectedEquipments` int,
    `disconnectedEquipmentsIds` nchar(1000),

    `disconnectedConnectors` int,

    `totalFailRead` int,

    `totalEquipmentsIds` nchar(1000),
    `totalEquipments` int,
    `connectedConnectorsIds` nchar(1000),
    `connectedEquipments` int,
    `totalConnectorsIds` nchar(1000),
    `disconnectedConnectorsIds` nchar(1000),
    `totalConnectors` int,
    `totalSuccessRead` int,
    `totalSuccessWrite` int,
    `totalFields` int,
    `connectedFields` int,
    `disconnectedFields` int,
    `id` nchar(100)
);

CREATE TABLE hiot.`docker_container_mem` (
    ts timestamp,
    `container_name` nchar(100),
    `usage_percent` float,
    `rss` float,
    `collect_type` nchar(100),
    `id` nchar(100),
    `time` nchar(100)
);
CREATE TABLE hiot.`docker_container_cpu` (
    ts timestamp,
    `container_name` nchar(100),
    `container_id` nchar(100),
    `container_image` nchar(100),
    `container_status` nchar(100),
    `container_version` nchar(100),
    `cpu` nchar(100),
    `engine_host` nchar(100),
    `host` nchar(100),
    `usage_percent` float,
    `usage_total` bigint,
    `usage_system` bigint,
    `serverIp` nchar(100),
    `serverName` nchar(100),
    `serverVersion` nchar(100)
);
CREATE TABLE hiot.`api_requests` (
    ts timestamp,
    `service_name` nchar(100),
    `value` float
);
CREATE TABLE hiot.`system_event_warning` (
    ts timestamp,
    `eventType` nchar(100),
    `eventName` nchar(100),
    `message` nchar(100),
    `recipent` nchar(1000),
    `mailSendingResult` bool,
    `timestamp` nchar(100)
);
CREATE TABLE hiot.`operateLog` (
    ts timestamp,
    `logContent` nchar(1000),
    `logType` nchar(100),
    `objInfo` nchar(1000),
    `opTime` nchar(100),
    `operator` nchar(1000)
);
CREATE TABLE hiot.`connectionDriverStatusLog` (
    ts timestamp,
    `timestamp` nchar(100),
    `connectionId` nchar(100),
    `connectionName` nchar(1000),
    `connectionModel` nchar(100),
    `detail` nchar(1000),
    `locale` nchar(100),
    `dateTime` nchar(100),
    `connected` bool
);
CREATE TABLE hiot.`equipmentStatusLog` (
    ts timestamp,
    `timestamp` nchar(100),
    `id` nchar(100),
    `name` nchar(1000),
    `code` nchar(100),
    `detail` nchar(1000),
    `status` nchar(100),
    `dateTime` nchar(100)
);
CREATE TABLE hiot.`alarm` (
    ts timestamp,
    `cause` nchar(1000),
    `typeName` nchar(100),
    `source` nchar(100),
    `equipmentId` nchar(100),
    `equipmentName` nchar(100),
    `address` nchar(100),
    `nodeName` nchar(100),
    `connectionId` int,
    `connectionName` nchar(100),
    `name` nchar(100),
    `status` bool,
    `duration` int,
    `severityLevel` int,
    `startTime` nchar(100),
    `endTime` nchar(100),
    `id` int,
    `fieldName` nchar(100),
    `fieldValue` nchar(100),
    `equipmentCode` nchar(100),
    `groupName` nchar(100),
    `time` nchar(100)
);


CREATE TABLE hiot.`api_log` (
    ts timestamp,
    `apiId` int,
    `status` nchar(100),
    `name` nchar(100),
    `msg` nchar(1000),
    `dateTime` nchar(100)
);

CREATE TABLE hiot.`api_count` (
    ts timestamp,
    `apiId` int,
    `success` int,
    `fail` int,
    `name` nchar(100),
    `dateTime` nchar(100)
);


CREATE TABLE hiot.`pipedata` (
    ts timestamp,
    `data` nchar(5000),
    `pipeId` nchar(100),
    `time` nchar(100)
);


CREATE TABLE hiot.`monitor_alarm_record` (
    ts timestamp,
    `content` nchar(5000),
    `serviceIp` nchar(100),
    `triggerTime` nchar(100),
    `alarmType` nchar(100),
    `monitorName` nchar(100),
    `type` nchar(100),
    `isNotify` bool,
    `serviceName` nchar(100),
    `timestamp` nchar(100)
);
CREATE TABLE hiot.`vip_monitor` (
    ts timestamp,
    `name` nchar(100),
    `leader` nchar(100),
    `beLeaderTime` nchar(100),
    `backup` nchar(100),
    `beBackupTime` nchar(100)
);
CREATE TABLE hiot.`field_num` (
    ts timestamp,
    `totalFields` int,
    `connectedFields` int,
    `disconnectedFields` int
);