未验证 提交 749af3e0 编写于 作者: 静夜思朝颜's avatar 静夜思朝颜 提交者: GitHub

Alarm support multiple scope (#4769)

* Support service relation and database access alarm

* support service instance relation alarm

* support endpoint relation alarm

* document and format the name

* resolve issues

* add database access and endpoint relation rule example

* resolve code format

* remove unnecessary getter and setter package declare

* remove unnecessary fields
Co-authored-by: NMrproliu <mrproliu@lagou.com>
上级 50c4911a
......@@ -54,6 +54,20 @@ rules:
count: 2
silence-period: 5
message: Response time of service instance {name} is more than 1000ms in 2 minutes of last 10 minutes
database_access_resp_time_rule:
metrics-name: database_access_resp_time
threshold: 1000
op: ">"
period: 10
count: 2
message: Response time of database access {name} is more than 1000ms in 2 minutes of last 10 minutes
endpoint_relation_resp_time_rule:
metrics-name: endpoint_relation_resp_time
threshold: 1000
op: ">"
period: 10
count: 2
message: Response time of endpoint relation {name} is more than 1000ms in 2 minutes of last 10 minutes
# Active endpoint related metrics alarm will cost more memory than service and service instance metrics alarm.
# Because the number of endpoint is much more than service and instance.
#
......
......@@ -5,15 +5,23 @@ There are three parts in alarm rule definition.
1. [Webhooks](#webhook). The list of web service endpoint, which should be called after the alarm is triggered.
1. [gRPCHook](#gRPCHook). The host and port of remote gRPC method, which should be called after the alarm is triggered.
## Entity name
Define the relation between scope and entity name.
- **Service**: Service name
- **Instance**: {Instance name} of {Service name}
- **Endpoint**: {Endpoint name} in {Service name}
- **Database**: Database service name
- **Service Relation**: {Source service name} to {Dest service name}
- **Instance Relation**: {Source instance name} of {Source service name} to {Dest instance name} of {Dest service name}
- **Endpoint Relation**: {Source endpoint name} in {Source Service name} to {Dest endpoint name} in {Dest service name}
## Rules
Alarm rule is constituted by following keys
- **Rule name**. Unique name, show in alarm message. Must end with `_rule`.
- **Metrics name**. A.K.A. metrics name in oal script. Only long, double, int types are supported. See
[List of all potential metrics name](#list-of-all-potential-metrics-name).
- **Include names**. The following entity names are included in this rule. Such as Service name,
endpoint name.
- **Exclude names**. The following entity names are excluded in this rule. Such as Service name,
endpoint name.
- **Include names**. The following entity names are included in this rule. Please follow [Entity name define](#entity-name).
- **Exclude names**. The following entity names are excluded in this rule. Please follow [Entity name define](#entity-name).
- **Threshold**. The target value.
For multiple values metrics, such as **percentile**, the threshold is an array. Described like `value1, value2, value3, value4, value5`.
Each value could the threshold for each value of the metrics. Set the value to `-` if don't want to trigger alarm by this or some of the values.
......@@ -74,19 +82,21 @@ We provided a default `alarm-setting.yml` in our distribution only for convenien
1. Percentile of service response time is over 1s in last 3 minutes
1. Service Instance average response time over 1s in last 2 minutes.
1. Endpoint average response time over 1s in last 2 minutes.
1. Database access average response time over 1s in last 2 minutes.
1. Endpoint relation average response time over 1s in last 2 minutes.
### List of all potential metrics name
The metrics names are defined in official [OAL scripts](../../guides/backend-oal-scripts.md), right now
metrics from **Service**, **Service Instance**, **Endpoint** scopes could be used in Alarm, we will extend in further versions.
metrics from **Service**, **Service Instance**, **Endpoint**, **Service Relation**, **Service Instance Relation**, **Endpoint Relation** scopes could be used in Alarm, and the **Database access** same with **Service** scope.
Submit issue or pull request if you want to support any other scope in alarm.
## Webhook
Webhook requires the peer is a web container. The alarm message will send through HTTP post by `application/json` content type. The JSON format is based on `List<org.apache.skywalking.oap.server.core.alarm.AlarmMessage` with following key information.
Webhook requires the peer is a web container. The alarm message will send through HTTP post by `application/json` content type. The JSON format is based on `List<org.apache.skywalking.oap.server.core.alarm.AlarmMessage>` with following key information.
- **scopeId**, **scope**. All scopes are defined in org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.
- **name**. Target scope entity name.
- **id0**. The ID of scope entity, matched the name.
- **id1**. Not used today.
- **name**. Target scope entity name. Please follow [Entity name define](#entity-name).
- **id0**. The ID of the scope entity matched the name. When using relation scope, it is the source entity ID.
- **id1**. When using relation scope, it will be the dest entity ID. Otherwise, it is empty.
- **ruleName**. The rule name you configured in `alarm-settings.yml`.
- **alarmMessage**. Alarm text message.
- **startTime**. Alarm time measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
......@@ -95,20 +105,20 @@ Example as following
```json
[{
"scopeId": 1,
"scope": "SERVICE",
"name": "serviceA",
"scope": "SERVICE",
"name": "serviceA",
"id0": "12",
"id1": "",
"ruleName": "service_resp_time_rule",
"ruleName": "service_resp_time_rule",
"alarmMessage": "alarmMessage xxxx",
"startTime": 1560524171000
}, {
"scopeId": 1,
"scope": "SERVICE",
"name": "serviceB",
"scope": "SERVICE",
"name": "serviceB",
"id0": "23",
"id1": "",
"ruleName": "service_resp_time_rule",
"ruleName": "service_resp_time_rule",
"alarmMessage": "alarmMessage yyy",
"startTime": 1560524171000
}]
......
......@@ -42,6 +42,39 @@ public class MetricFormatter {
final IDManager.EndpointID.EndpointIDDefinition endpointIDDefinition = IDManager.EndpointID.analysisId(
endpointId);
return endpointIDDefinition.getEndpointName();
} else if (DefaultScopeDefine.inServiceRelationCatalog(scope)) {
final String serviceRelationId = meta.getId();
final IDManager.ServiceID.ServiceRelationDefine serviceRelationDefine = IDManager.ServiceID.analysisRelationId(
serviceRelationId);
final IDManager.ServiceID.ServiceIDDefinition sourceIdDefinition = IDManager.ServiceID.analysisId(
serviceRelationDefine.getSourceId());
final IDManager.ServiceID.ServiceIDDefinition destIdDefinition = IDManager.ServiceID.analysisId(
serviceRelationDefine.getDestId());
return sourceIdDefinition.getName() + " to " + destIdDefinition.getName();
} else if (DefaultScopeDefine.inServiceInstanceRelationCatalog(scope)) {
final String instanceRelationId = meta.getId();
final IDManager.ServiceInstanceID.ServiceInstanceRelationDefine serviceRelationDefine = IDManager.ServiceInstanceID.analysisRelationId(
instanceRelationId);
final IDManager.ServiceInstanceID.InstanceIDDefinition sourceIdDefinition = IDManager.ServiceInstanceID.analysisId(
serviceRelationDefine.getSourceId());
final IDManager.ServiceID.ServiceIDDefinition sourceServiceId = IDManager.ServiceID.analysisId(
sourceIdDefinition.getServiceId());
final IDManager.ServiceInstanceID.InstanceIDDefinition destIdDefinition = IDManager.ServiceInstanceID.analysisId(
serviceRelationDefine.getDestId());
final IDManager.ServiceID.ServiceIDDefinition destServiceId = IDManager.ServiceID.analysisId(
destIdDefinition.getServiceId());
return sourceIdDefinition.getName() + " of " + sourceServiceId.getName()
+ " to " + destIdDefinition.getName() + " of " + destServiceId.getName();
} else if (DefaultScopeDefine.inEndpointRelationCatalog(scope)) {
final String endpointRelationId = meta.getId();
final IDManager.EndpointID.EndpointRelationDefine endpointRelationDefine = IDManager.EndpointID.analysisRelationId(
endpointRelationId);
final IDManager.ServiceID.ServiceIDDefinition sourceService = IDManager.ServiceID.analysisId(
endpointRelationDefine.getSourceServiceId());
final IDManager.ServiceID.ServiceIDDefinition destService = IDManager.ServiceID.analysisId(
endpointRelationDefine.getDestServiceId());
return endpointRelationDefine.getSource() + " in " + sourceService.getName()
+ " to " + endpointRelationDefine.getDest() + " in " + destService.getName();
} else if (scope == DefaultScopeDefine.ALL) {
return "";
} else {
......
......@@ -18,12 +18,11 @@
package org.apache.skywalking.oal.rt.parser;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
@Getter
@Setter
public class ConditionExpression {
// original from script
private String expressionType;
......
......@@ -18,13 +18,12 @@
package org.apache.skywalking.oal.rt.parser;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oal.rt.util.ClassMethodUtil;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
@Getter
@Setter
public class DataColumn {
private String fieldName;
private String columnName;
......
......@@ -20,13 +20,12 @@ package org.apache.skywalking.oal.rt.parser;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oal.rt.util.ClassMethodUtil;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
@Getter
@Setter
public class EntryMethod {
static final int LITERAL_TYPE = 1;
static final int IDENTIFIER_TYPE = 2;
......
......@@ -18,12 +18,11 @@
package org.apache.skywalking.oal.rt.parser;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
@Getter
@Setter
public class Expression {
private String expressionObject;
private String left;
......
......@@ -18,13 +18,12 @@
package org.apache.skywalking.oal.rt.parser;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oal.rt.util.ClassMethodUtil;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
@Getter
@Setter
public class PersistenceField {
private String fieldName;
private String setter;
......
......@@ -19,13 +19,12 @@
package org.apache.skywalking.oal.rt.parser;
import java.util.Objects;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oal.rt.util.ClassMethodUtil;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
@Getter
@Setter
public class SourceColumn {
private String fieldName;
private String columnName;
......
......@@ -20,7 +20,6 @@ package org.apache.skywalking.oap.server.core.alarm.provider;
import java.util.ArrayList;
import java.util.Objects;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
......@@ -31,8 +30,8 @@ import lombok.ToString;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Setter(AccessLevel.PUBLIC)
@Getter(AccessLevel.PUBLIC)
@Setter
@Getter
@ToString
public class AlarmRule {
private String alarmRuleName;
......
......@@ -23,6 +23,9 @@ import java.util.Arrays;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.oap.server.core.alarm.AlarmCallback;
import org.apache.skywalking.oap.server.core.alarm.EndpointRelationMetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.ServiceInstanceRelationMetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.ServiceRelationMetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.EndpointMetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.MetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.MetricsNotify;
......@@ -51,9 +54,9 @@ public class NotifyHandler implements MetricsNotify {
MetricsMetaInfo meta = withMetadata.getMeta();
int scope = meta.getScope();
if (!DefaultScopeDefine.inServiceCatalog(scope) && !DefaultScopeDefine.inServiceInstanceCatalog(
scope) && !DefaultScopeDefine
.inEndpointCatalog(scope)) {
if (!DefaultScopeDefine.inServiceCatalog(scope) && !DefaultScopeDefine.inServiceInstanceCatalog(scope)
&& !DefaultScopeDefine.inEndpointCatalog(scope) && !DefaultScopeDefine.inServiceRelationCatalog(scope)
&& !DefaultScopeDefine.inServiceInstanceRelationCatalog(scope) && !DefaultScopeDefine.inEndpointRelationCatalog(scope)) {
return;
}
......@@ -91,6 +94,54 @@ public class NotifyHandler implements MetricsNotify {
endpointMetaInAlarm.setName(
endpointIDDefinition.getEndpointName() + " in " + serviceIDDefinition.getName());
metaInAlarm = endpointMetaInAlarm;
} else if (DefaultScopeDefine.inServiceRelationCatalog(scope)) {
final String serviceRelationId = meta.getId();
final IDManager.ServiceID.ServiceRelationDefine serviceRelationDefine = IDManager.ServiceID.analysisRelationId(
serviceRelationId);
final IDManager.ServiceID.ServiceIDDefinition sourceIdDefinition = IDManager.ServiceID.analysisId(
serviceRelationDefine.getSourceId());
final IDManager.ServiceID.ServiceIDDefinition destIdDefinition = IDManager.ServiceID.analysisId(
serviceRelationDefine.getDestId());
ServiceRelationMetaInAlarm serviceRelationMetaInAlarm = new ServiceRelationMetaInAlarm();
serviceRelationMetaInAlarm.setMetricsName(meta.getMetricsName());
serviceRelationMetaInAlarm.setId(serviceRelationId);
serviceRelationMetaInAlarm.setName(sourceIdDefinition.getName() + " to " + destIdDefinition.getName());
metaInAlarm = serviceRelationMetaInAlarm;
} else if (DefaultScopeDefine.inServiceInstanceRelationCatalog(scope)) {
final String instanceRelationId = meta.getId();
final IDManager.ServiceInstanceID.ServiceInstanceRelationDefine serviceRelationDefine = IDManager.ServiceInstanceID.analysisRelationId(
instanceRelationId);
final IDManager.ServiceInstanceID.InstanceIDDefinition sourceIdDefinition = IDManager.ServiceInstanceID.analysisId(
serviceRelationDefine.getSourceId());
final IDManager.ServiceID.ServiceIDDefinition sourceServiceId = IDManager.ServiceID.analysisId(
sourceIdDefinition.getServiceId());
final IDManager.ServiceInstanceID.InstanceIDDefinition destIdDefinition = IDManager.ServiceInstanceID.analysisId(
serviceRelationDefine.getDestId());
final IDManager.ServiceID.ServiceIDDefinition destServiceId = IDManager.ServiceID.analysisId(
destIdDefinition.getServiceId());
ServiceInstanceRelationMetaInAlarm instanceRelationMetaInAlarm = new ServiceInstanceRelationMetaInAlarm();
instanceRelationMetaInAlarm.setMetricsName(meta.getMetricsName());
instanceRelationMetaInAlarm.setId(instanceRelationId);
instanceRelationMetaInAlarm.setName(sourceIdDefinition.getName() + " of " + sourceServiceId.getName()
+ " to " + destIdDefinition.getName() + " of " + destServiceId.getName());
metaInAlarm = instanceRelationMetaInAlarm;
} else if (DefaultScopeDefine.inEndpointRelationCatalog(scope)) {
final String endpointRelationId = meta.getId();
final IDManager.EndpointID.EndpointRelationDefine endpointRelationDefine = IDManager.EndpointID.analysisRelationId(
endpointRelationId);
final IDManager.ServiceID.ServiceIDDefinition sourceService = IDManager.ServiceID.analysisId(
endpointRelationDefine.getSourceServiceId());
final IDManager.ServiceID.ServiceIDDefinition destService = IDManager.ServiceID.analysisId(
endpointRelationDefine.getDestServiceId());
EndpointRelationMetaInAlarm endpointRelationMetaInAlarm = new EndpointRelationMetaInAlarm();
endpointRelationMetaInAlarm.setMetricsName(meta.getMetricsName());
endpointRelationMetaInAlarm.setId(endpointRelationId);
endpointRelationMetaInAlarm.setName(endpointRelationDefine.getSource() + " in " + sourceService.getName()
+ " to " + endpointRelationDefine.getDest() + " in " + destService.getName());
metaInAlarm = endpointRelationMetaInAlarm;
} else {
return;
}
......
......@@ -20,14 +20,13 @@ package org.apache.skywalking.oap.server.core.alarm.provider;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.skywalking.oap.server.core.alarm.provider.grpc.GRPCAlarmSetting;
@Setter(AccessLevel.PUBLIC)
@Getter(AccessLevel.PUBLIC)
@Setter
@Getter
@ToString
public class Rules {
private List<AlarmRule> rules;
......
......@@ -21,6 +21,9 @@ package org.apache.skywalking.oap.server.core.alarm.provider;
import com.google.common.collect.Lists;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.alarm.AlarmMessage;
import org.apache.skywalking.oap.server.core.alarm.EndpointRelationMetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.ServiceInstanceRelationMetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.ServiceRelationMetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.EndpointMetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.MetaInAlarm;
import org.apache.skywalking.oap.server.core.alarm.ServiceInstanceMetaInAlarm;
......@@ -163,6 +166,93 @@ public class NotifyHandlerTest {
assertEquals(DefaultScopeDefine.SERVICE, metaInAlarm.getScopeId());
}
@Test
public void testNotifyWithServiceRelationCatalog() {
prepareNotify();
String metricsName = "service-relation-metrics";
when(metadata.getMetricsName()).thenReturn(metricsName);
when(DefaultScopeDefine.inServiceRelationCatalog(0)).thenReturn(true);
final String serviceRelationId = IDManager.ServiceID.buildRelationId(new IDManager.ServiceID.ServiceRelationDefine(
IDManager.ServiceID.buildId("from-service", true),
IDManager.ServiceID.buildId("dest-service", true)
));
when(metadata.getId()).thenReturn(serviceRelationId);
ArgumentCaptor<MetaInAlarm> metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class);
notifyHandler.notify(metrics);
verify(rule).in(metaCaptor.capture(), any());
MetaInAlarm metaInAlarm = metaCaptor.getValue();
assertTrue(metaInAlarm instanceof ServiceRelationMetaInAlarm);
assertEquals(metricsName, metaInAlarm.getMetricsName());
assertEquals("ZnJvbS1zZXJ2aWNl.1", metaInAlarm.getId0());
assertEquals("ZGVzdC1zZXJ2aWNl.1", metaInAlarm.getId1());
assertEquals(DefaultScopeDefine.SERVICE_RELATION_CATALOG_NAME, metaInAlarm.getScope());
assertEquals("from-service to dest-service", metaInAlarm.getName());
assertEquals(DefaultScopeDefine.SERVICE_RELATION, metaInAlarm.getScopeId());
}
@Test
public void testNotifyWithServiceInstanceRelationCatalog() {
prepareNotify();
String metricsName = "service-instance-relation-metrics";
when(metadata.getMetricsName()).thenReturn(metricsName);
when(DefaultScopeDefine.inServiceInstanceRelationCatalog(0)).thenReturn(true);
final String serviceInstanceRelationId = IDManager.ServiceInstanceID.buildRelationId(new IDManager.ServiceInstanceID.ServiceInstanceRelationDefine(
IDManager.ServiceInstanceID.buildId(IDManager.ServiceID.buildId("from-service", true), "from-service-instance"),
IDManager.ServiceInstanceID.buildId(IDManager.ServiceID.buildId("dest-service", true), "dest-service-instance")
));
when(metadata.getId()).thenReturn(serviceInstanceRelationId);
ArgumentCaptor<MetaInAlarm> metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class);
notifyHandler.notify(metrics);
verify(rule).in(metaCaptor.capture(), any());
MetaInAlarm metaInAlarm = metaCaptor.getValue();
assertTrue(metaInAlarm instanceof ServiceInstanceRelationMetaInAlarm);
assertEquals(metricsName, metaInAlarm.getMetricsName());
assertEquals("ZnJvbS1zZXJ2aWNl.1_ZnJvbS1zZXJ2aWNlLWluc3RhbmNl", metaInAlarm.getId0());
assertEquals("ZGVzdC1zZXJ2aWNl.1_ZGVzdC1zZXJ2aWNlLWluc3RhbmNl", metaInAlarm.getId1());
assertEquals(DefaultScopeDefine.SERVICE_INSTANCE_RELATION_CATALOG_NAME, metaInAlarm.getScope());
assertEquals("from-service-instance of from-service to dest-service-instance of dest-service", metaInAlarm.getName());
assertEquals(DefaultScopeDefine.SERVICE_INSTANCE_RELATION, metaInAlarm.getScopeId());
}
@Test
public void testNotifyWithEndpointRelationCatalog() {
prepareNotify();
String metricsName = "endpoint-relation-metrics";
when(metadata.getMetricsName()).thenReturn(metricsName);
when(DefaultScopeDefine.inEndpointRelationCatalog(0)).thenReturn(true);
final String serviceInstanceRelationId = IDManager.EndpointID.buildRelationId(new IDManager.EndpointID.EndpointRelationDefine(
IDManager.ServiceID.buildId("from-service", true), "/source-path",
IDManager.ServiceID.buildId("dest-service", true), "/dest-path"
));
when(metadata.getId()).thenReturn(serviceInstanceRelationId);
ArgumentCaptor<MetaInAlarm> metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class);
notifyHandler.notify(metrics);
verify(rule).in(metaCaptor.capture(), any());
MetaInAlarm metaInAlarm = metaCaptor.getValue();
assertTrue(metaInAlarm instanceof EndpointRelationMetaInAlarm);
assertEquals(metricsName, metaInAlarm.getMetricsName());
assertEquals("ZnJvbS1zZXJ2aWNl.1_L3NvdXJjZS1wYXRo", metaInAlarm.getId0());
assertEquals("ZGVzdC1zZXJ2aWNl.1_L2Rlc3QtcGF0aA==", metaInAlarm.getId1());
assertEquals(DefaultScopeDefine.ENDPOINT_RELATION_CATALOG_NAME, metaInAlarm.getScope());
assertEquals("/source-path in from-service to /dest-path in dest-service", metaInAlarm.getName());
assertEquals(DefaultScopeDefine.ENDPOINT_RELATION, metaInAlarm.getScopeId());
}
private void prepareNotify() {
metadata = mock(MetricsMetaInfo.class);
when(metadata.getScope()).thenReturn(DefaultScopeDefine.ALL);
......
......@@ -18,15 +18,14 @@
package org.apache.skywalking.oap.server.core.alarm;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
/**
* Alarm message represents the details of each alarm.
*/
@Setter(AccessLevel.PUBLIC)
@Getter(AccessLevel.PUBLIC)
@Setter
@Getter
public class AlarmMessage {
public static AlarmMessage NONE = new NoAlarm();
......
......@@ -18,21 +18,18 @@
package org.apache.skywalking.oap.server.core.alarm;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
@Getter
@Setter
public class EndpointMetaInAlarm extends MetaInAlarm {
private String metricsName;
private String id;
private String name;
private String[] tags;
private String[] properties;
@Override
public String getScope() {
......
/*
* 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.apache.skywalking.oap.server.core.alarm;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@Getter
@Setter
public class EndpointRelationMetaInAlarm extends MetaInAlarm {
private String metricsName;
private String id;
private String name;
@Override
public String getScope() {
return DefaultScopeDefine.ENDPOINT_RELATION_CATALOG_NAME;
}
@Override
public int getScopeId() {
return DefaultScopeDefine.ENDPOINT_RELATION;
}
@Override
public String getId0() {
final IDManager.EndpointID.EndpointRelationDefine endpointRelationDefine =
IDManager.EndpointID.analysisRelationId(id);
return IDManager.EndpointID.buildId(endpointRelationDefine.getSourceServiceId(), endpointRelationDefine.getSource());
}
@Override
public String getId1() {
final IDManager.EndpointID.EndpointRelationDefine endpointRelationDefine =
IDManager.EndpointID.analysisRelationId(id);
return IDManager.EndpointID.buildId(endpointRelationDefine.getDestServiceId(), endpointRelationDefine.getDest());
}
}
......@@ -18,21 +18,18 @@
package org.apache.skywalking.oap.server.core.alarm;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
@Getter
@Setter
public class ServiceInstanceMetaInAlarm extends MetaInAlarm {
private String metricsName;
private String id;
private String name;
private String[] tags;
private String[] properties;
@Override
public String getScope() {
......
/*
* 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.apache.skywalking.oap.server.core.alarm;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@Getter
@Setter
public class ServiceInstanceRelationMetaInAlarm extends MetaInAlarm {
private String metricsName;
private String id;
private String name;
@Override
public String getScope() {
return DefaultScopeDefine.SERVICE_INSTANCE_RELATION_CATALOG_NAME;
}
@Override
public int getScopeId() {
return DefaultScopeDefine.SERVICE_INSTANCE_RELATION;
}
@Override
public String getId0() {
final IDManager.ServiceInstanceID.ServiceInstanceRelationDefine instanceRelationDefine =
IDManager.ServiceInstanceID.analysisRelationId(id);
return instanceRelationDefine.getSourceId();
}
@Override
public String getId1() {
final IDManager.ServiceInstanceID.ServiceInstanceRelationDefine instanceRelationDefine =
IDManager.ServiceInstanceID.analysisRelationId(id);
return instanceRelationDefine.getDestId();
}
}
......@@ -18,21 +18,18 @@
package org.apache.skywalking.oap.server.core.alarm;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
@Getter
@Setter
public class ServiceMetaInAlarm extends MetaInAlarm {
private String metricsName;
private String id;
private String name;
private String[] tags;
private String[] properties;
@Override
public String getScope() {
......
/*
* 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.apache.skywalking.oap.server.core.alarm;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
@Getter
@Setter
public class ServiceRelationMetaInAlarm extends MetaInAlarm {
private String metricsName;
private String id;
private String name;
@Override
public String getScope() {
return DefaultScopeDefine.SERVICE_RELATION_CATALOG_NAME;
}
@Override
public int getScopeId() {
return DefaultScopeDefine.SERVICE_RELATION;
}
@Override
public String getId0() {
final IDManager.ServiceID.ServiceRelationDefine relationDefine = IDManager.ServiceID.analysisRelationId(id);
return relationDefine.getSourceId();
}
@Override
public String getId1() {
final IDManager.ServiceID.ServiceRelationDefine relationDefine = IDManager.ServiceID.analysisRelationId(id);
return relationDefine.getDestId();
}
}
......@@ -24,8 +24,9 @@ import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.NodeType;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.DATABASE_ACCESS;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_CATALOG_NAME;
@ScopeDeclaration(id = DATABASE_ACCESS, name = "DatabaseAccess")
@ScopeDeclaration(id = DATABASE_ACCESS, name = "DatabaseAccess", catalog = SERVICE_CATALOG_NAME)
@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
public class DatabaseAccess extends Source {
......
......@@ -73,10 +73,16 @@ public class DefaultScopeDefine {
public static final String SERVICE_CATALOG_NAME = "SERVICE";
public static final String SERVICE_INSTANCE_CATALOG_NAME = "SERVICE_INSTANCE";
public static final String ENDPOINT_CATALOG_NAME = "ENDPOINT";
public static final String SERVICE_RELATION_CATALOG_NAME = "SERVICE_RELATION";
public static final String SERVICE_INSTANCE_RELATION_CATALOG_NAME = "SERVICE_INSTANCE_RELATION";
public static final String ENDPOINT_RELATION_CATALOG_NAME = "ENDPOINT_RELATION";
private static final Map<Integer, Boolean> SERVICE_CATALOG = new HashMap<>();
private static final Map<Integer, Boolean> SERVICE_INSTANCE_CATALOG = new HashMap<>();
private static final Map<Integer, Boolean> ENDPOINT_CATALOG = new HashMap<>();
private static final Map<Integer, Boolean> SERVICE_RELATION_CATALOG = new HashMap<>();
private static final Map<Integer, Boolean> SERVICE_INSTANCE_RELATION_CATALOG = new HashMap<>();
private static final Map<Integer, Boolean> ENDPOINT_RELATION_CATALOG = new HashMap<>();
@Setter
private static boolean ACTIVE_EXTRA_MODEL_COLUMNS = false;
......@@ -169,6 +175,15 @@ public class DefaultScopeDefine {
case ENDPOINT_CATALOG_NAME:
ENDPOINT_CATALOG.put(id, Boolean.TRUE);
break;
case SERVICE_RELATION_CATALOG_NAME:
SERVICE_RELATION_CATALOG.put(id, Boolean.TRUE);
break;
case SERVICE_INSTANCE_RELATION_CATALOG_NAME:
SERVICE_INSTANCE_RELATION_CATALOG.put(id, Boolean.TRUE);
break;
case ENDPOINT_RELATION_CATALOG_NAME:
ENDPOINT_RELATION_CATALOG.put(id, Boolean.TRUE);
break;
}
}
......@@ -239,6 +254,36 @@ public class DefaultScopeDefine {
return ENDPOINT_CATALOG.containsKey(scopeId);
}
/**
* Check whether current service belongs service relation catalog
*
* @param scopeId represents an existing scope id.
* @return true is current scope set {@link ScopeDeclaration#catalog()} == {@link #SERVICE_RELATION_CATALOG_NAME}
*/
public static boolean inServiceRelationCatalog(int scopeId) {
return SERVICE_RELATION_CATALOG.containsKey(scopeId);
}
/**
* Check whether current service belongs service instance relation catalog
*
* @param scopeId represents an existing scope id.
* @return true is current scope set {@link ScopeDeclaration#catalog()} == {@link #SERVICE_INSTANCE_RELATION_CATALOG_NAME}
*/
public static boolean inServiceInstanceRelationCatalog(int scopeId) {
return SERVICE_INSTANCE_RELATION_CATALOG.containsKey(scopeId);
}
/**
* Check whether current service belongs endpoint relation catalog
*
* @param scopeId represents an existing scope id.
* @return true is current scope set {@link ScopeDeclaration#catalog()} == {@link #ENDPOINT_RELATION_CATALOG_NAME}
*/
public static boolean inEndpointRelationCatalog(int scopeId) {
return ENDPOINT_RELATION_CATALOG.containsKey(scopeId);
}
/**
* Get the default columns defined in Scope. All those columns will forward to persistent entity.
*
......
......@@ -24,8 +24,9 @@ import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.NodeType;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.ENDPOINT_RELATION;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.ENDPOINT_RELATION_CATALOG_NAME;
@ScopeDeclaration(id = ENDPOINT_RELATION, name = "EndpointRelation")
@ScopeDeclaration(id = ENDPOINT_RELATION, name = "EndpointRelation", catalog = ENDPOINT_RELATION_CATALOG_NAME)
@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
public class EndpointRelation extends Source {
......
......@@ -22,14 +22,13 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import lombok.AccessLevel;
import lombok.Getter;
/**
* Define the default columns of source scope. These columns pass down into the persistent entity(OAL metrics entity)
* automatically.
*/
@Getter(AccessLevel.PUBLIC)
@Getter
public class ScopeDefaultColumn {
private String fieldName;
private String columnName;
......
......@@ -25,8 +25,9 @@ import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.NodeType;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_INSTANCE_RELATION;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_INSTANCE_RELATION_CATALOG_NAME;
@ScopeDeclaration(id = SERVICE_INSTANCE_RELATION, name = "ServiceInstanceRelation")
@ScopeDeclaration(id = SERVICE_INSTANCE_RELATION, name = "ServiceInstanceRelation", catalog = SERVICE_INSTANCE_RELATION_CATALOG_NAME)
@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
public class ServiceInstanceRelation extends Source {
private String entityId;
......
......@@ -25,8 +25,9 @@ import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.NodeType;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_RELATION;
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_RELATION_CATALOG_NAME;
@ScopeDeclaration(id = SERVICE_RELATION, name = "ServiceRelation")
@ScopeDeclaration(id = SERVICE_RELATION, name = "ServiceRelation", catalog = SERVICE_RELATION_CATALOG_NAME)
@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
public class ServiceRelation extends Source {
private String entityId;
......
......@@ -27,7 +27,7 @@ import org.apache.skywalking.oap.server.library.module.ModuleConfig;
* The config of {@code query.graphql}.
*/
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PUBLIC)
@Setter
public class GraphQLQueryConfig extends ModuleConfig {
private String path;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册