Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staus Page Component #1449

Merged
merged 26 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,44 @@ public interface CommonConstants {
* prometheus
*/
String PROMETHEUS = "prometheus";

/**
* status page component state normal
*/
byte STATUS_PAGE_COMPONENT_STATE_NORMAL = 0;

/**
* status page component state abnormal
*/
byte STATUS_PAGE_COMPONENT_STATE_ABNORMAL = 1;

/**
* status page component state unknown
*/
byte STATUS_PAGE_COMPONENT_STATE_UNKNOWN = 2;

/**
* status page org state all normal
*/
byte STATUS_PAGE_ORG_STATE_ALL_NORMAL = 0;

/**
* status page org state some abnormal
*/
byte STATUS_PAGE_ORG_STATE_SOME_ABNORMAL = 1;

/**
* status page org state all abnormal
*/
byte STATUS_PAGE_ORG_STATE_ALL_ABNORMAL = 2;

/**
* status page component calculate method auto
*/
byte STATUE_PAGE_CALCULATE_METHOD_AUTO = 0;

/**
* status page component calculate method manual
*/
byte STATUS_PAGE_CALCULATE_METHOD_MANUAL = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.dromara.hertzbeat.common.entity.manager;

import com.fasterxml.jackson.core.type.TypeReference;
import org.dromara.hertzbeat.common.util.JsonUtil;

import javax.persistence.AttributeConverter;

/**
* json str to tag item
* @author tom
*
*/
public class JsonTagAttributeConverter implements AttributeConverter<TagItem, String> {

@Override
public String convertToDatabaseColumn(TagItem attribute) {
return JsonUtil.toJson(attribute);
}

@Override
public TagItem convertToEntityAttribute(String dbData) {
TypeReference<TagItem> typeReference = new TypeReference<>() {};
return JsonUtil.fromJson(dbData, typeReference);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.dromara.hertzbeat.common.entity.manager;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;

/**
* status page component entity
* @author tom
*/
@Entity
@Table(name = "hzb_status_page_component")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "status page component entity")
@EntityListeners(AuditingEntityListener.class)
public class StatusPageComponent {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Schema(title = "ID", example = "87584674384")
private Long id;

@Schema(title = "org id", example = "1234")
private Long orgId;

@Schema(title = "component name", example = "Gateway")
@NotBlank
private String name;

@Schema(title = "component desc", example = "TanCloud Gateway")
private String description;

@Schema(title = "component match single tag", example = "{labelName:labelValue}")
@Convert(converter = JsonTagAttributeConverter.class)
private TagItem tag;

@Schema(title = "calculate status method: 0-auto 1-manual", example = "0")
private byte method;

@Schema(title = "config state when use manual method: 0-Normal 1-Abnormal 2-unknown", example = "0")
private byte configState;

@Schema(title = "component current state: 0-Normal 1-Abnormal 2-unknown", example = "0")
private byte state;

@Schema(title = "The creator of this record", example = "tom")
@CreatedBy
private String creator;

@Schema(title = "The modifier of this record", example = "tom")
@LastModifiedBy
private String modifier;

@Schema(title = "Record create time", example = "1612198922000")
@CreatedDate
private LocalDateTime gmtCreate;

@Schema(title = "Record modify time", example = "1612198444000")
@LastModifiedDate
private LocalDateTime gmtUpdate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.dromara.hertzbeat.common.entity.manager;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
* status page history entity
* @author tom
*/
@Entity
@Table(name = "hzb_status_page_history")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "status page component history entity")
@EntityListeners(AuditingEntityListener.class)
public class StatusPageHistory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Schema(title = "ID", example = "87584674384")
private Long id;

@Schema(title = "component id", example = "1234")
private Long componentId;

@Schema(title = "component state: 0-Normal 1-Abnormal 2-unknown", example = "0")
private byte state;

@Schema(title = "state calculate timestamp", example = "4248574985744")
private Long timestamp;

@Schema(title = "state uptime percentage", example = "99.99")
private Double uptime;

@Schema(title = "state abnormal time(s)", example = "1000")
private Integer abnormal;

@Schema(title = "state unknown time(s)", example = "1000")
@Column(name = "`unknown`")
private Integer unknown;

@Schema(title = "state normal tim(s)", example = "1000")
private Integer normal;

@Schema(title = "The creator of this record", example = "tom")
@CreatedBy
private String creator;

@Schema(title = "The modifier of this record", example = "tom")
@LastModifiedBy
private String modifier;

@Schema(title = "Record create time", example = "1612198922000")
@CreatedDate
private LocalDateTime gmtCreate;

@Schema(title = "Record modify time", example = "1612198444000")
@LastModifiedDate
private LocalDateTime gmtUpdate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.dromara.hertzbeat.common.entity.manager;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;

import java.time.LocalDateTime;

/**
* status page org entity
* @author tom
*/
@Entity
@Table(name = "hzb_status_page_org")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "status page org entity")
@EntityListeners(AuditingEntityListener.class)
public class StatusPageOrg {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Schema(title = "ID", example = "87584674384")
private Long id;

@Schema(title = "org name", example = "TanCloud")
@NotBlank
private String name;

@Schema(title = "org desc", example = "TanCloud inc")
@NotBlank
private String description;

@Schema(title = "org home url", example = "https://tancloud.com")
@NotBlank
private String home;

@Schema(title = "org logo url", example = "logo.svg url")
@NotBlank
private String logo;

@Schema(title = "org feedback issue url", example = "contact@email.com")
private String feedback;

@Schema(title = "org theme background color", example = "#ffffff")
private String color;

@Schema(title = "org current state: 0-All Systems Operational 1-Some Systems Abnormal 2-All Systems Abnormal ", example = "0")
private byte state;

@Schema(title = "The creator of this record", example = "tom")
@CreatedBy
private String creator;

@Schema(title = "The modifier of this record", example = "tom")
@LastModifiedBy
private String modifier;

@Schema(title = "Record create time", example = "1612198922000")
@CreatedDate
private LocalDateTime gmtCreate;

@Schema(title = "Record modify time", example = "1612198444000")
@LastModifiedDate
private LocalDateTime gmtUpdate;
}
2 changes: 1 addition & 1 deletion home/docs/start/mysql-change.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MYSQL is a reliable relational database. In addition to default built-in H2 data
1. Enter MYSQL or use the client to connect MYSQL service
`mysql -uroot -p123456`
2. Create database named hertzbeat
`create database hertzbeat;`
`create database hertzbeat default charset utf8mb4 collate utf8mb4_general_ci;`
3. Check if hertzbeat database has been successfully created
`show databases;`

Expand Down
Loading
Loading