Support all metrics from MAL engine in alarm core (#8547)
* Support all metrics from MAL engine in alarm core
This commit is contained in:
parent
7c94f65772
commit
d83144bddd
|
|
@ -58,6 +58,7 @@ Release Notes.
|
|||
* Support datasource metric analysis.
|
||||
* [Break Change] Keep the endpoint avg resp time meter name the same with others scope. (This may break 3rd party integration and existing alarm rule settings)
|
||||
* Add Python FastApi component ID(7014).
|
||||
* Support all metrics from MAL engine in alarm core, including Prometheus, OC receiver, meter receiver.
|
||||
|
||||
#### UI
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* 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.analysis.meter;
|
||||
|
||||
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
|
||||
import org.apache.skywalking.oap.server.core.analysis.metrics.MetricsMetaInfo;
|
||||
import org.apache.skywalking.oap.server.core.analysis.metrics.WithMetadata;
|
||||
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
|
||||
|
||||
/**
|
||||
* Meter is the abstract parent for all {@link org.apache.skywalking.oap.server.core.analysis.meter.function.MeterFunction} annotated functions.
|
||||
* It provides the {@link WithMetadata} implementation for alarm kernal.
|
||||
*
|
||||
* @since 9.0.0
|
||||
*/
|
||||
public abstract class Meter extends Metrics implements WithMetadata {
|
||||
private MetricsMetaInfo metadata = new MetricsMetaInfo("UNKNOWN", DefaultScopeDefine.UNKNOWN);
|
||||
|
||||
/**
|
||||
* @return entity ID to represent this metric object. Typically, meter function should have a String type field, named entityId.
|
||||
* See {@link org.apache.skywalking.oap.server.core.analysis.meter.function.avg.AvgFunction#getEntityId()} as an example.
|
||||
*/
|
||||
public abstract String getEntityId();
|
||||
|
||||
/**
|
||||
* This method is called in {@link MeterSystem#create} process through dynamic Java codes.
|
||||
*
|
||||
* @param metricName metric name
|
||||
* @param scopeId scope Id defined in {@link DefaultScopeDefine}
|
||||
*/
|
||||
public void initMeta(String metricName, int scopeId) {
|
||||
this.metadata.setMetricsName(metricName);
|
||||
this.metadata.setScope(scopeId);
|
||||
}
|
||||
|
||||
public MetricsMetaInfo getMeta() {
|
||||
// Only read the id from the implementation when needed, to avoid uninitialized cases.
|
||||
this.metadata.setId(this.getEntityId());
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
|
@ -225,7 +225,9 @@ public class MeterSystem implements Service {
|
|||
metricsClass.addMethod(CtNewMethod.make(
|
||||
""
|
||||
+ "public org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue createNew() {"
|
||||
+ " return new " + METER_CLASS_PACKAGE + className + "();"
|
||||
+ " org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue meterVar = new " + METER_CLASS_PACKAGE + className + "();"
|
||||
+ " ((org.apache.skywalking.oap.server.core.analysis.meter.Meter)meterVar).initMeta(\"" + metricsName + "\", " + type.getScopeId() + ");"
|
||||
+ " return meterVar;"
|
||||
+ " }"
|
||||
, metricsClass));
|
||||
} catch (CannotCompileException e) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import lombok.ToString;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.UnexpectedException;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.Meter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
|
||||
import org.apache.skywalking.oap.server.core.analysis.metrics.DataTable;
|
||||
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
|
||||
|
|
@ -42,7 +43,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
|||
@MeterFunction(functionName = "histogram")
|
||||
@Slf4j
|
||||
@ToString
|
||||
public abstract class HistogramFunction extends Metrics implements AcceptableValue<BucketedValues> {
|
||||
public abstract class HistogramFunction extends Meter implements AcceptableValue<BucketedValues> {
|
||||
public static final String DATASET = "dataset";
|
||||
|
||||
@Setter
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import lombok.Setter;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.UnexpectedException;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.Meter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
|
||||
import org.apache.skywalking.oap.server.core.analysis.metrics.DataTable;
|
||||
import org.apache.skywalking.oap.server.core.analysis.metrics.IntList;
|
||||
|
|
@ -47,7 +48,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
|||
*/
|
||||
@MeterFunction(functionName = "percentile")
|
||||
@Slf4j
|
||||
public abstract class PercentileFunction extends Metrics implements AcceptableValue<PercentileFunction.PercentileArgument>, MultiIntValuesHolder {
|
||||
public abstract class PercentileFunction extends Meter implements AcceptableValue<PercentileFunction.PercentileArgument>, MultiIntValuesHolder {
|
||||
public static final String DATASET = "dataset";
|
||||
public static final String RANKS = "ranks";
|
||||
public static final String VALUE = "value";
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import lombok.ToString;
|
|||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.UnexpectedException;
|
||||
import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.Meter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.MeterFunction;
|
||||
|
|
@ -42,7 +43,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
|||
|
||||
@MeterFunction(functionName = "avg")
|
||||
@ToString
|
||||
public abstract class AvgFunction extends Metrics implements AcceptableValue<Long>, LongValueHolder {
|
||||
public abstract class AvgFunction extends Meter implements AcceptableValue<Long>, LongValueHolder {
|
||||
protected static final String SUMMATION = "summation";
|
||||
protected static final String COUNT = "count";
|
||||
protected static final String VALUE = "value";
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import lombok.ToString;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.UnexpectedException;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.Meter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.BucketedValues;
|
||||
|
|
@ -52,7 +53,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
|||
@MeterFunction(functionName = "avgHistogram")
|
||||
@Slf4j
|
||||
@ToString
|
||||
public abstract class AvgHistogramFunction extends Metrics implements AcceptableValue<BucketedValues> {
|
||||
public abstract class AvgHistogramFunction extends Meter implements AcceptableValue<BucketedValues> {
|
||||
public static final String DATASET = "dataset";
|
||||
protected static final String SUMMATION = "summation";
|
||||
protected static final String COUNT = "count";
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import lombok.Setter;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.UnexpectedException;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.Meter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.MeterFunction;
|
||||
|
|
@ -63,7 +64,7 @@ import static java.util.stream.Collectors.mapping;
|
|||
*/
|
||||
@MeterFunction(functionName = "avgHistogramPercentile")
|
||||
@Slf4j
|
||||
public abstract class AvgHistogramPercentileFunction extends Metrics implements AcceptableValue<PercentileArgument>, MultiIntValuesHolder {
|
||||
public abstract class AvgHistogramPercentileFunction extends Meter implements AcceptableValue<PercentileArgument>, MultiIntValuesHolder {
|
||||
private static final String DEFAULT_GROUP = "pD";
|
||||
public static final String DATASET = "dataset";
|
||||
public static final String RANKS = "ranks";
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import lombok.ToString;
|
|||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.UnexpectedException;
|
||||
import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.Meter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.MeterFunction;
|
||||
|
|
@ -40,7 +41,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
|||
|
||||
@MeterFunction(functionName = "avgLabeled")
|
||||
@ToString
|
||||
public abstract class AvgLabeledFunction extends Metrics implements AcceptableValue<DataTable>, LabeledValueHolder {
|
||||
public abstract class AvgLabeledFunction extends Meter implements AcceptableValue<DataTable>, LabeledValueHolder {
|
||||
protected static final String SUMMATION = "summation";
|
||||
protected static final String COUNT = "count";
|
||||
protected static final String VALUE = "value";
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import lombok.ToString;
|
|||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.UnexpectedException;
|
||||
import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.Meter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.MeterFunction;
|
||||
|
|
@ -41,7 +42,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
|||
|
||||
@MeterFunction(functionName = "latest")
|
||||
@ToString
|
||||
public abstract class LatestFunction extends Metrics implements AcceptableValue<Long>, LongValueHolder {
|
||||
public abstract class LatestFunction extends Meter implements AcceptableValue<Long>, LongValueHolder {
|
||||
protected static final String VALUE = "value";
|
||||
|
||||
@Setter
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import lombok.ToString;
|
|||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.UnexpectedException;
|
||||
import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.Meter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue;
|
||||
import org.apache.skywalking.oap.server.core.analysis.meter.function.MeterFunction;
|
||||
|
|
@ -41,7 +42,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
|||
|
||||
@ToString
|
||||
@MeterFunction(functionName = "sum")
|
||||
public abstract class SumFunction extends Metrics implements AcceptableValue<Long>, LongValueHolder {
|
||||
public abstract class SumFunction extends Meter implements AcceptableValue<Long>, LongValueHolder {
|
||||
protected static final String VALUE = "value";
|
||||
|
||||
@Setter
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ public class DefaultScopeDefine {
|
|||
* <p>
|
||||
* If you want to extend the scope, recommend to start with 10,000.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 9.0.0
|
||||
*/
|
||||
public static final int UNKNOWN = 0;
|
||||
public static final int ALL = 0;
|
||||
public static final int SERVICE = 1;
|
||||
public static final int SERVICE_INSTANCE = 2;
|
||||
|
|
@ -58,7 +63,9 @@ public class DefaultScopeDefine {
|
|||
public static final int SERVICE_INSTANCE_CLR_THREAD = 21;
|
||||
public static final int ENVOY_INSTANCE_METRIC = 22;
|
||||
public static final int ZIPKIN_SPAN = 23;
|
||||
@Deprecated
|
||||
public static final int JAEGER_SPAN = 24;
|
||||
@Deprecated
|
||||
public static final int HTTP_ACCESS_LOG = 25;
|
||||
public static final int PROFILE_TASK = 26;
|
||||
public static final int PROFILE_TASK_LOG = 27;
|
||||
|
|
|
|||
Loading…
Reference in New Issue