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` varchar(100),
    `generalLogType` varchar(100),
    `operateObj` varchar(1000),
    `status` bool,
    `description` varchar(1000),
    `timestamp` varchar(100)
);

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

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

    `disconnectedConnectors` int,

    `totalFailRead` int,

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

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


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

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


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


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