You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2026/03/03 12:56:04 UTC
(skywalking) 19/27: Improve MAL bytecode: single-variable run(), LocalVariableTable, and v1-v2 checker data
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch groovy-replace
in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit c884b00680a8fe0969849cf62a6818e1df21402e
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Mon Mar 2 21:36:52 2026 +0800
Improve MAL bytecode: single-variable run(), LocalVariableTable, and v1-v2 checker data
Rewrite MAL run() code generation to use a single reassigned 'sf' variable
instead of multiple intermediate variables, producing cleaner decompiled output.
Add LocalVariableTable attribute so decompilers show 'samples' and 'sf' instead
of 'var1' and 'var2'. Integrate v2 compilers with runtime wiring, add checker
test data files, and clean up unused code across MAL/LAL/Hierarchy modules.
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.gitignore | 3 +
CLAUDE.md | 22 +
.../provider/meter/config/MeterConfig.java | 1 -
.../v2/compiler/HierarchyRuleClassGenerator.java | 74 +-
.../analyzer/v2/compiler/LALClassGenerator.java | 414 +++++++----
.../oap/log/analyzer/v2/dsl/Binding.java | 2 +-
.../oap/log/analyzer/v2/dsl/LalExpression.java | 2 +-
.../analyzer/v2/dsl/spec/filter/FilterSpec.java | 67 +-
.../v2/dsl/spec/parser/TextParserSpec.java | 5 -
.../log/analyzer/v2/provider/log/LogAnalyzer.java | 10 +-
.../provider/log/listener/LogFilterListener.java | 6 +-
.../skywalking/oap/meter/analyzer/v2/Analyzer.java | 2 +-
.../oap/meter/analyzer/v2/MetricConvert.java | 17 -
.../oap/meter/analyzer/v2/MetricRuleConfig.java | 5 -
.../analyzer/v2/compiler/MALClassGenerator.java | 377 +++++++++-
.../analyzer/v2/compiler/MALScriptParser.java | 4 +-
.../oap/meter/analyzer/v2/dsl/Expression.java | 2 +-
.../oap/meter/analyzer/v2/dsl/Result.java | 10 +-
.../meter/analyzer/v2/prometheus/rule/Rule.java | 1 -
.../v2/compiler/MALClassGeneratorTest.java | 53 +-
.../zabbix/provider/config/ZabbixConfig.java | 1 -
.../hierarchy-v1-v2-checker/pom.xml | 18 +
.../core/config/HierarchyRuleComparisonTest.java | 176 +++--
.../mal-lal-v1-v2-checker/pom.xml | 18 +
.../oap/server/checker/lal/LalComparisonTest.java | 21 +-
.../oap/server/checker/mal/MalComparisonTest.java | 265 ++++++-
.../server/checker/mal/MalInputDataGenerator.java | 679 ++++++++++++++++++
.../checker/mal/MalInputDataGeneratorTest.java | 63 ++
.../test-hierarchy-definition.data.yaml | 111 +++
.../envoy-ca.data.yaml} | 25 +-
.../envoy-svc-relation.data.yaml} | 22 +-
.../mal/test-envoy-metrics-rules/envoy.data.yaml | 96 +++
.../{placeholder.yaml => nginx.data.yaml} | 13 +-
.../continuous-profiling.data.yaml | 64 ++
.../datasource.data.yaml} | 12 +-
.../test-meter-analyzer-config/go-agent.data.yaml | 91 +++
.../go-runtime.data.yaml | 238 ++++++
.../java-agent.data.yaml | 92 +++
.../network-profiling.data.yaml | 164 +++++
.../python-runtime.data.yaml | 80 +++
.../ruby-runtime.data.yaml | 108 +++
.../satellite-tag-prefix.data.yaml | 75 ++
.../test-meter-analyzer-config/satellite.data.yaml | 75 ++
.../spring-micrometer.data.yaml | 178 +++++
.../threadpool.data.yaml} | 12 +-
.../activemq/activemq-broker.data.yaml | 173 +++++
.../activemq/activemq-cluster.data.yaml | 144 ++++
.../activemq/activemq-destination.data.yaml | 131 ++++
.../scripts/mal/test-otel-rules/apisix.data.yaml | 76 ++
.../aws-dynamodb/dynamodb-endpoint.data.yaml | 65 ++
.../aws-dynamodb/dynamodb-service.data.yaml | 83 +++
.../aws-eks/eks-cluster.data.yaml} | 34 +-
.../mal/test-otel-rules/aws-eks/eks-node.data.yaml | 64 ++
.../aws-eks/eks-service.data.yaml} | 30 +-
.../aws-gateway/gateway-endpoint.data.yaml | 163 +++++
.../aws-gateway/gateway-service.data.yaml | 135 ++++
.../test-otel-rules/aws-s3/s3-service.data.yaml | 97 +++
.../banyandb/banyandb-instance.data.yaml | 195 +++++
.../banyandb/banyandb-service.data.yaml | 195 +++++
.../bookkeeper/bookkeeper-cluster.data.yaml | 87 +++
.../bookkeeper/bookkeeper-node.data.yaml | 186 +++++
.../clickhouse/clickhouse-instance.data.yaml | 327 +++++++++
.../clickhouse/clickhouse-service.data.yaml | 287 ++++++++
.../elasticsearch/elasticsearch-cluster.data.yaml | 110 +++
.../elasticsearch/elasticsearch-index.data.yaml | 314 ++++++++
.../elasticsearch/elasticsearch-node.data.yaml | 354 +++++++++
.../mal/test-otel-rules/flink/flink-job.data.yaml | 127 ++++
.../flink/flink-jobManager.data.yaml | 149 ++++
.../flink/flink-taskManager.data.yaml | 190 +++++
.../test-otel-rules/istio-controlplane.data.yaml | 250 +++++++
.../mal/test-otel-rules/k8s/k8s-cluster.data.yaml | 174 +++++
.../k8s/k8s-instance.data.yaml} | 12 +-
.../mal/test-otel-rules/k8s/k8s-node.data.yaml | 100 +++
.../mal/test-otel-rules/k8s/k8s-service.data.yaml | 95 +++
.../test-otel-rules/kafka/kafka-broker.data.yaml | 209 ++++++
.../test-otel-rules/kafka/kafka-cluster.data.yaml | 73 ++
.../test-otel-rules/kong/kong-endpoint.data.yaml | 117 +++
.../test-otel-rules/kong/kong-instance.data.yaml | 172 +++++
.../test-otel-rules/kong/kong-service.data.yaml | 155 ++++
.../mongodb/mongodb-cluster.data.yaml | 125 ++++
.../test-otel-rules/mongodb/mongodb-node.data.yaml | 298 ++++++++
.../test-otel-rules/mysql/mysql-instance.data.yaml | 120 ++++
.../test-otel-rules/mysql/mysql-service.data.yaml | 99 +++
.../nginx/nginx-endpoint.data.yaml} | 21 +-
.../nginx/nginx-instance.data.yaml} | 23 +-
.../nginx/nginx-service.data.yaml} | 23 +-
.../scripts/mal/test-otel-rules/oap.data.yaml | 798 +++++++++++++++++++++
.../postgresql/postgresql-instance.data.yaml | 305 ++++++++
.../postgresql/postgresql-service.data.yaml | 178 +++++
.../test-otel-rules/pulsar/pulsar-broker.data.yaml | 133 ++++
.../pulsar/pulsar-cluster.data.yaml | 101 +++
.../rabbitmq/rabbitmq-cluster.data.yaml | 186 +++++
.../rabbitmq/rabbitmq-node.data.yaml | 141 ++++
.../test-otel-rules/redis/redis-instance.data.yaml | 117 +++
.../test-otel-rules/redis/redis-service.data.yaml | 119 +++
.../rocketmq/rocketmq-broker.data.yaml} | 31 +-
.../rocketmq/rocketmq-cluster.data.yaml | 110 +++
.../rocketmq/rocketmq-topic.data.yaml | 78 ++
.../service-decorate-attributes.data.yaml} | 12 +-
.../service-gstring-regex-split.data.yaml} | 12 +-
.../scripts/mal/test-otel-rules/vm.data.yaml | 151 ++++
.../scripts/mal/test-otel-rules/windows.data.yaml | 78 ++
102 files changed, 11707 insertions(+), 399 deletions(-)
diff --git a/.gitignore b/.gitignore
index 38241c2e1b..ccfb27257a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,6 @@ oap-server/server-starter/src/main/resources/version.properties
# Benchmark reports and downloaded tools
benchmarks/reports/
benchmarks/.istio/
+
+# Generated .class files from v2 compiler (created during v1-v2 checker tests)
+test/script-cases/scripts/**/*.generated-classes/
diff --git a/CLAUDE.md b/CLAUDE.md
index dfa342ad0b..dc6f946e15 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -81,6 +81,28 @@ git submodule init && git submodule update
- `dist` (default): Creates distribution packages
- `all`: Builds everything including submodule initialization
+### CI-Friendly `${revision}` Property
+
+SkyWalking uses Maven's CI-friendly `${revision}` property (defined in the root `pom.xml`) instead of hardcoded version numbers. The `flatten-maven-plugin` resolves `${revision}` at install time, but POMs installed to `~/.m2/repository` may retain the unresolved `${revision}` literal. This causes `Could not find artifact org.apache.skywalking:...:pom:${revision}` errors when building individual modules with `-pl` (without `-am` to rebuild all ancestors from source).
+
+**Prevention**: When building individual modules, always include their ancestor modules via `-am`:
+```bash
+# GOOD: -am builds all ancestor modules from source, avoiding cached POM issues
+./mvnw install -pl oap-server/analyzer/meter-analyzer -am -DskipTests
+
+# RISKY: without -am, Maven resolves ancestors from ~/.m2 which may have broken ${revision}
+./mvnw install -pl oap-server/analyzer/meter-analyzer -DskipTests
+```
+
+**Fix if it happens**: Remove and reinstall the broken cached artifacts:
+```bash
+# Delete all SkyWalking SNAPSHOT artifacts from local cache
+rm -rf ~/.m2/repository/org/apache/skywalking/*/10.4.0-SNAPSHOT
+
+# Rebuild and install from source
+./mvnw install -DskipTests -q
+```
+
## Architecture & Key Concepts
### Module System
diff --git a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/config/MeterConfig.java b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/config/MeterConfig.java
index 9e5c8641ca..8e13ab8c2c 100644
--- a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/config/MeterConfig.java
+++ b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/config/MeterConfig.java
@@ -32,7 +32,6 @@ public class MeterConfig implements MetricRuleConfig {
private String expPrefix;
private String filter;
private List<Rule> metricsRules;
- private String initExp;
@Data
@NoArgsConstructor
diff --git a/oap-server/analyzer/hierarchy/src/main/java/org/apache/skywalking/oap/server/core/config/v2/compiler/HierarchyRuleClassGenerator.java b/oap-server/analyzer/hierarchy/src/main/java/org/apache/skywalking/oap/server/core/config/v2/compiler/HierarchyRuleClassGenerator.java
index faefe698b5..23ddf5d7c0 100644
--- a/oap-server/analyzer/hierarchy/src/main/java/org/apache/skywalking/oap/server/core/config/v2/compiler/HierarchyRuleClassGenerator.java
+++ b/oap-server/analyzer/hierarchy/src/main/java/org/apache/skywalking/oap/server/core/config/v2/compiler/HierarchyRuleClassGenerator.java
@@ -17,6 +17,9 @@
package org.apache.skywalking.oap.server.core.config.v2.compiler;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiFunction;
@@ -40,7 +43,12 @@ public final class HierarchyRuleClassGenerator {
private static final String PACKAGE_PREFIX =
"org.apache.skywalking.oap.server.core.config.v2.compiler.hierarchy.rule.rt.";
+ private static final java.util.Set<String> USED_CLASS_NAMES =
+ java.util.Collections.synchronizedSet(new java.util.HashSet<>());
+
private final ClassPool classPool;
+ private File classOutputDir;
+ private String classNameHint;
public HierarchyRuleClassGenerator() {
this(ClassPool.getDefault());
@@ -50,6 +58,59 @@ public final class HierarchyRuleClassGenerator {
this.classPool = classPool;
}
+ public void setClassOutputDir(final File dir) {
+ this.classOutputDir = dir;
+ }
+
+ public void setClassNameHint(final String hint) {
+ this.classNameHint = hint;
+ }
+
+ private String makeClassName(final String defaultPrefix) {
+ if (classNameHint != null) {
+ return dedupClassName(PACKAGE_PREFIX + sanitizeName(classNameHint));
+ }
+ return PACKAGE_PREFIX + defaultPrefix + CLASS_COUNTER.getAndIncrement();
+ }
+
+ private String dedupClassName(final String base) {
+ if (USED_CLASS_NAMES.add(base)) {
+ return base;
+ }
+ for (int i = 2; ; i++) {
+ final String candidate = base + "_" + i;
+ if (USED_CLASS_NAMES.add(candidate)) {
+ return candidate;
+ }
+ }
+ }
+
+ private static String sanitizeName(final String name) {
+ final StringBuilder sb = new StringBuilder(name.length());
+ for (int i = 0; i < name.length(); i++) {
+ final char c = name.charAt(i);
+ sb.append(i == 0
+ ? (Character.isJavaIdentifierStart(c) ? c : '_')
+ : (Character.isJavaIdentifierPart(c) ? c : '_'));
+ }
+ return sb.length() == 0 ? "Generated" : sb.toString();
+ }
+
+ private void writeClassFile(final CtClass ctClass) {
+ if (classOutputDir == null) {
+ return;
+ }
+ if (!classOutputDir.exists()) {
+ classOutputDir.mkdirs();
+ }
+ final File file = new File(classOutputDir, ctClass.getSimpleName() + ".class");
+ try (DataOutputStream out = new DataOutputStream(new FileOutputStream(file))) {
+ ctClass.toBytecode(out);
+ } catch (Exception e) {
+ log.warn("Failed to write class file {}: {}", file, e.getMessage());
+ }
+ }
+
/**
* Compiles a hierarchy rule expression into a BiFunction class.
*
@@ -61,8 +122,16 @@ public final class HierarchyRuleClassGenerator {
public BiFunction<Service, Service, Boolean> compile(
final String ruleName, final String expression) throws Exception {
final HierarchyRuleModel model = HierarchyRuleScriptParser.parse(expression);
- final String className = PACKAGE_PREFIX + "HierarchyRule_"
- + CLASS_COUNTER.getAndIncrement();
+ final String saved = classNameHint;
+ if (classNameHint == null) {
+ classNameHint = ruleName;
+ }
+ final String className;
+ try {
+ className = makeClassName("HierarchyRule_");
+ } finally {
+ classNameHint = saved;
+ }
final CtClass ctClass = classPool.makeClass(className);
ctClass.addInterface(classPool.get("java.util.function.BiFunction"));
@@ -78,6 +147,7 @@ public final class HierarchyRuleClassGenerator {
ctClass.addMethod(CtNewMethod.make(applyBody, ctClass));
+ writeClassFile(ctClass);
final Class<?> clazz = ctClass.toClass(HierarchyRulePackageHolder.class);
ctClass.detach();
return (BiFunction<Service, Service, Boolean>) clazz.getDeclaredConstructor().newInstance();
diff --git a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALClassGenerator.java b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALClassGenerator.java
index 6accaae619..eddb98155d 100644
--- a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALClassGenerator.java
+++ b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALClassGenerator.java
@@ -17,6 +17,9 @@
package org.apache.skywalking.oap.log.analyzer.v2.compiler;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -69,7 +72,12 @@ public final class LALClassGenerator {
private static final String PROCESS_REGISTRY =
"org.apache.skywalking.oap.meter.analyzer.v2.dsl.registry.ProcessRegistry";
+ private static final java.util.Set<String> USED_CLASS_NAMES =
+ java.util.Collections.synchronizedSet(new java.util.HashSet<>());
+
private final ClassPool classPool;
+ private File classOutputDir;
+ private String classNameHint;
public LALClassGenerator() {
this(ClassPool.getDefault());
@@ -79,6 +87,60 @@ public final class LALClassGenerator {
this.classPool = classPool;
}
+ public void setClassOutputDir(final File dir) {
+ this.classOutputDir = dir;
+ }
+
+ public void setClassNameHint(final String hint) {
+ this.classNameHint = hint;
+ }
+
+ private String makeClassName(final String defaultPrefix) {
+ if (classNameHint != null) {
+ return dedupClassName(PACKAGE_PREFIX + sanitizeName(classNameHint));
+ }
+ return PACKAGE_PREFIX + defaultPrefix + CLASS_COUNTER.getAndIncrement();
+ }
+
+ private String dedupClassName(final String base) {
+ if (USED_CLASS_NAMES.add(base)) {
+ return base;
+ }
+ for (int i = 2; ; i++) {
+ final String candidate = base + "_" + i;
+ if (USED_CLASS_NAMES.add(candidate)) {
+ return candidate;
+ }
+ }
+ }
+
+ static String sanitizeName(final String name) {
+ final StringBuilder sb = new StringBuilder(name.length());
+ for (int i = 0; i < name.length(); i++) {
+ final char c = name.charAt(i);
+ sb.append(i == 0
+ ? (Character.isJavaIdentifierStart(c) ? c : '_')
+ : (Character.isJavaIdentifierPart(c) ? c : '_'));
+ }
+ return sb.length() == 0 ? "Generated" : sb.toString();
+ }
+
+ private void writeClassFile(final CtClass ctClass) {
+ if (classOutputDir == null) {
+ return;
+ }
+ if (!classOutputDir.exists()) {
+ classOutputDir.mkdirs();
+ }
+ final File file = new File(classOutputDir, ctClass.getSimpleName() + ".class");
+ try (DataOutputStream out = new DataOutputStream(new FileOutputStream(file))) {
+ ctClass.toBytecode(out);
+ } catch (Exception e) {
+ log.warn("Failed to write class file {}: {}", file, e.getMessage());
+ }
+ }
+
+
/**
* Compiles a LAL DSL script into a LalExpression implementation.
*/
@@ -91,30 +153,41 @@ public final class LALClassGenerator {
* Compiles from a pre-parsed model.
*/
public LalExpression compileFromModel(final LALScriptModel model) throws Exception {
- final String className = PACKAGE_PREFIX + "LalExpr_"
- + CLASS_COUNTER.getAndIncrement();
+ final String className = makeClassName("LalExpr_");
// Phase 1: Collect all consumer info in traversal order
final List<ConsumerInfo> consumers = new ArrayList<>();
collectConsumers(model.getStatements(), consumers);
- // Phase 2: Compile consumer classes (recursively handles sub-consumers)
+ // Phase 2: Compile consumer classes, named by purpose (extractor/sink/etc.)
+ // Defer detach until after main class is compiled so types remain in ClassPool
+ final List<CtClass> pendingDetach = new ArrayList<>();
final List<Object> consumerInstances = new ArrayList<>();
+ final List<String> consumerFieldNames = new ArrayList<>();
+ final List<String> consumerClassNames = new ArrayList<>();
+ final java.util.Map<String, Integer> consumerNameCounts = new java.util.HashMap<>();
for (int i = 0; i < consumers.size(); i++) {
- final String consumerName = className + "_C" + i;
+ final String label = consumers.get(i).label();
+ final int count = consumerNameCounts.getOrDefault(label, 0);
+ consumerNameCounts.put(label, count + 1);
+ final String suffix = count == 0 ? label : label + "_" + (count + 1);
+ consumerFieldNames.add("_" + suffix);
+ final String consumerName = dedupClassName(className + "$" + suffix);
+ consumerClassNames.add(consumerName);
final Object instance = compileConsumerClass(
- consumerName, consumers.get(i));
+ consumerName, consumers.get(i), pendingDetach);
consumerInstances.add(instance);
}
- // Phase 3: Build main class with consumer fields
+ // Phase 3: Build main class with consumer fields (actual types)
final CtClass ctClass = classPool.makeClass(className);
ctClass.addInterface(classPool.get(
"org.apache.skywalking.oap.log.analyzer.v2.dsl.LalExpression"));
for (int i = 0; i < consumers.size(); i++) {
ctClass.addField(CtField.make(
- "public java.util.function.Consumer _consumer" + i + ";",
+ "public " + consumerClassNames.get(i) + " "
+ + consumerFieldNames.get(i) + ";",
ctClass));
}
@@ -123,7 +196,8 @@ public final class LALClassGenerator {
// Phase 4: Generate execute method referencing consumer fields
final int[] counter = {0};
- final String executeBody = generateExecuteMethod(model, counter);
+ final String executeBody = generateExecuteMethod(
+ model, counter, consumerFieldNames);
if (log.isDebugEnabled()) {
log.debug("LAL compile AST: {}", model);
@@ -132,14 +206,20 @@ public final class LALClassGenerator {
ctClass.addMethod(CtNewMethod.make(executeBody, ctClass));
+ writeClassFile(ctClass);
+
final Class<?> clazz = ctClass.toClass(LalExpressionPackageHolder.class);
ctClass.detach();
+ for (final CtClass ct : pendingDetach) {
+ ct.detach();
+ }
final LalExpression instance = (LalExpression) clazz
.getDeclaredConstructor().newInstance();
// Phase 5: Wire consumer fields
for (int i = 0; i < consumerInstances.size(); i++) {
- clazz.getField("_consumer" + i).set(instance, consumerInstances.get(i));
+ clazz.getField(consumerFieldNames.get(i))
+ .set(instance, consumerInstances.get(i));
}
return instance;
@@ -151,18 +231,60 @@ public final class LALClassGenerator {
final String body;
final String castType;
final List<ConsumerInfo> subConsumers;
+ final List<String> subFieldNames;
ConsumerInfo(final String body, final String castType) {
this.body = body;
this.castType = castType;
this.subConsumers = new ArrayList<>();
+ this.subFieldNames = new ArrayList<>();
}
ConsumerInfo(final String body, final String castType,
- final List<ConsumerInfo> subConsumers) {
+ final List<ConsumerInfo> subConsumers,
+ final List<String> subFieldNames) {
this.body = body;
this.castType = castType;
this.subConsumers = new ArrayList<>(subConsumers);
+ this.subFieldNames = new ArrayList<>(subFieldNames);
+ }
+
+ String nextSubFieldName(final ConsumerInfo sub) {
+ final String subLabel = sub.label();
+ int count = 0;
+ for (final ConsumerInfo existing : subConsumers) {
+ if (existing.label().equals(subLabel)) {
+ count++;
+ }
+ }
+ final String fieldName = count == 0
+ ? "_" + subLabel : "_" + subLabel + "_" + (count + 1);
+ subConsumers.add(sub);
+ subFieldNames.add(fieldName);
+ return fieldName;
+ }
+
+ String label() {
+ if (castType.endsWith("ExtractorSpec")) {
+ return "extractor";
+ } else if (castType.endsWith("SinkSpec")) {
+ return "sink";
+ } else if (castType.endsWith("SamplerSpec")) {
+ return "sampler";
+ } else if (castType.endsWith("SlowSqlSpec")) {
+ return "slowSql";
+ } else if (castType.endsWith("SampledTraceSpec")) {
+ return "sampledTrace";
+ } else if (castType.endsWith("SampleBuilder")) {
+ return "sample";
+ } else if (castType.endsWith("RateLimitingSampler")) {
+ return "rateLimiter";
+ }
+ final int dot = castType.lastIndexOf('.');
+ final int dollar = castType.lastIndexOf('$');
+ final int start = Math.max(dot, dollar) + 1;
+ return Character.toLowerCase(castType.charAt(start))
+ + castType.substring(start + 1);
}
}
@@ -209,27 +331,25 @@ public final class LALClassGenerator {
(LALScriptModel.ExtractorBlock) stmt;
final ConsumerInfo info = new ConsumerInfo("", EXTRACTOR_SPEC);
final StringBuilder sb = new StringBuilder();
- final int[] subCounter = {0};
final List<LALScriptModel.FilterStatement> extractorStmts = new ArrayList<>();
for (final LALScriptModel.ExtractorStatement es : block.getStatements()) {
extractorStmts.add((LALScriptModel.FilterStatement) es);
}
- generateExtractorBody(sb, extractorStmts, info, subCounter);
+ generateExtractorBody(sb, extractorStmts, info);
consumers.add(new ConsumerInfo(sb.toString(), EXTRACTOR_SPEC,
- info.subConsumers));
+ info.subConsumers, info.subFieldNames));
} else if (stmt instanceof LALScriptModel.SinkBlock) {
final LALScriptModel.SinkBlock sink = (LALScriptModel.SinkBlock) stmt;
if (!sink.getStatements().isEmpty()) {
final ConsumerInfo info = new ConsumerInfo("", SINK_SPEC);
final StringBuilder sb = new StringBuilder();
- final int[] subCounter = {0};
final List<LALScriptModel.FilterStatement> sinkStmts = new ArrayList<>();
for (final LALScriptModel.SinkStatement ss : sink.getStatements()) {
sinkStmts.add((LALScriptModel.FilterStatement) ss);
}
- generateSinkBody(sb, sinkStmts, info, subCounter);
+ generateSinkBody(sb, sinkStmts, info);
consumers.add(new ConsumerInfo(sb.toString(), SINK_SPEC,
- info.subConsumers));
+ info.subConsumers, info.subFieldNames));
}
} else if (stmt instanceof LALScriptModel.IfBlock) {
final LALScriptModel.IfBlock ifBlock = (LALScriptModel.IfBlock) stmt;
@@ -245,8 +365,7 @@ public final class LALClassGenerator {
private void generateExtractorBody(
final StringBuilder sb,
final List<? extends LALScriptModel.FilterStatement> stmts,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
+ final ConsumerInfo parentInfo) {
for (final LALScriptModel.FilterStatement stmt : stmts) {
if (stmt instanceof LALScriptModel.FieldAssignment) {
final LALScriptModel.FieldAssignment field =
@@ -265,17 +384,17 @@ public final class LALClassGenerator {
generateTagAssignment(sb, (LALScriptModel.TagAssignment) stmt);
} else if (stmt instanceof LALScriptModel.IfBlock) {
generateIfBlockInBody(sb, (LALScriptModel.IfBlock) stmt,
- parentInfo, subCounter, true);
+ parentInfo, true);
} else if (stmt instanceof LALScriptModel.MetricsBlock) {
generateMetricsSubConsumer(sb, (LALScriptModel.MetricsBlock) stmt,
- parentInfo, subCounter);
+ parentInfo);
} else if (stmt instanceof LALScriptModel.SlowSqlBlock) {
generateSlowSqlSubConsumer(sb, (LALScriptModel.SlowSqlBlock) stmt,
- parentInfo, subCounter);
+ parentInfo);
} else if (stmt instanceof LALScriptModel.SampledTraceBlock) {
generateSampledTraceSubConsumer(sb,
(LALScriptModel.SampledTraceBlock) stmt,
- parentInfo, subCounter);
+ parentInfo);
}
}
}
@@ -284,23 +403,22 @@ public final class LALClassGenerator {
final StringBuilder sb,
final LALScriptModel.IfBlock ifBlock,
final ConsumerInfo parentInfo,
- final int[] subCounter,
final boolean isExtractorContext) {
sb.append(" if (");
generateCondition(sb, ifBlock.getCondition());
sb.append(") {\n");
if (isExtractorContext) {
- generateExtractorBody(sb, ifBlock.getThenBranch(), parentInfo, subCounter);
+ generateExtractorBody(sb, ifBlock.getThenBranch(), parentInfo);
} else {
- generateSinkBody(sb, ifBlock.getThenBranch(), parentInfo, subCounter);
+ generateSinkBody(sb, ifBlock.getThenBranch(), parentInfo);
}
sb.append(" }\n");
if (!ifBlock.getElseBranch().isEmpty()) {
sb.append(" else {\n");
if (isExtractorContext) {
- generateExtractorBody(sb, ifBlock.getElseBranch(), parentInfo, subCounter);
+ generateExtractorBody(sb, ifBlock.getElseBranch(), parentInfo);
} else {
- generateSinkBody(sb, ifBlock.getElseBranch(), parentInfo, subCounter);
+ generateSinkBody(sb, ifBlock.getElseBranch(), parentInfo);
}
sb.append(" }\n");
}
@@ -311,9 +429,7 @@ public final class LALClassGenerator {
private void generateMetricsSubConsumer(
final StringBuilder sb,
final LALScriptModel.MetricsBlock block,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
- final int idx = subCounter[0]++;
+ final ConsumerInfo parentInfo) {
final StringBuilder body = new StringBuilder();
if (block.getName() != null) {
body.append(" _t.name(\"")
@@ -361,11 +477,10 @@ public final class LALClassGenerator {
}
final ConsumerInfo sub = new ConsumerInfo(body.toString(), SAMPLE_BUILDER);
- parentInfo.subConsumers.add(sub);
- sb.append(" ((").append(PACKAGE_PREFIX)
- .append("BindingAware) this._sub").append(idx)
- .append(").setBinding(this.binding);\n");
- sb.append(" _t.metrics(this._sub").append(idx).append(");\n");
+ final String fieldName = parentInfo.nextSubFieldName(sub);
+ sb.append(" this.").append(fieldName)
+ .append(".setBinding(this.binding);\n");
+ sb.append(" _t.metrics(this.").append(fieldName).append(");\n");
}
// ==================== SlowSql sub-consumer ====================
@@ -373,9 +488,7 @@ public final class LALClassGenerator {
private void generateSlowSqlSubConsumer(
final StringBuilder sb,
final LALScriptModel.SlowSqlBlock block,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
- final int idx = subCounter[0]++;
+ final ConsumerInfo parentInfo) {
final StringBuilder body = new StringBuilder();
if (block.getId() != null) {
body.append(" _t.id(");
@@ -395,11 +508,10 @@ public final class LALClassGenerator {
}
final ConsumerInfo sub = new ConsumerInfo(body.toString(), SLOW_SQL_SPEC);
- parentInfo.subConsumers.add(sub);
- sb.append(" ((").append(PACKAGE_PREFIX)
- .append("BindingAware) this._sub").append(idx)
- .append(").setBinding(this.binding);\n");
- sb.append(" _t.slowSql(this._sub").append(idx).append(");\n");
+ final String fieldName = parentInfo.nextSubFieldName(sub);
+ sb.append(" this.").append(fieldName)
+ .append(".setBinding(this.binding);\n");
+ sb.append(" _t.slowSql(this.").append(fieldName).append(");\n");
}
// ==================== SampledTrace sub-consumer ====================
@@ -407,34 +519,30 @@ public final class LALClassGenerator {
private void generateSampledTraceSubConsumer(
final StringBuilder sb,
final LALScriptModel.SampledTraceBlock block,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
- final int idx = subCounter[0]++;
+ final ConsumerInfo parentInfo) {
final StringBuilder body = new StringBuilder();
final ConsumerInfo sub = new ConsumerInfo("", SAMPLED_TRACE_SPEC);
- final int[] innerSubCounter = {0};
- generateSampledTraceBody(body, block.getStatements(), sub, innerSubCounter);
+ generateSampledTraceBody(body, block.getStatements(), sub);
// Propagate any sub-sub-consumers
- parentInfo.subConsumers.add(new ConsumerInfo(body.toString(),
- SAMPLED_TRACE_SPEC, sub.subConsumers));
- sb.append(" ((").append(PACKAGE_PREFIX)
- .append("BindingAware) this._sub").append(idx)
- .append(").setBinding(this.binding);\n");
- sb.append(" _t.sampledTrace(this._sub").append(idx).append(");\n");
+ final ConsumerInfo propagated = new ConsumerInfo(body.toString(),
+ SAMPLED_TRACE_SPEC, sub.subConsumers, sub.subFieldNames);
+ final String fieldName = parentInfo.nextSubFieldName(propagated);
+ sb.append(" this.").append(fieldName)
+ .append(".setBinding(this.binding);\n");
+ sb.append(" _t.sampledTrace(this.").append(fieldName).append(");\n");
}
private void generateSampledTraceBody(
final StringBuilder sb,
final List<LALScriptModel.SampledTraceStatement> stmts,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
+ final ConsumerInfo parentInfo) {
for (final LALScriptModel.SampledTraceStatement stmt : stmts) {
if (stmt instanceof LALScriptModel.SampledTraceField) {
generateSampledTraceField(sb, (LALScriptModel.SampledTraceField) stmt);
} else if (stmt instanceof LALScriptModel.IfBlock) {
generateSampledTraceIfBlock(sb, (LALScriptModel.IfBlock) stmt,
- parentInfo, subCounter);
+ parentInfo);
}
}
}
@@ -485,18 +593,17 @@ public final class LALClassGenerator {
private void generateSampledTraceIfBlock(
final StringBuilder sb,
final LALScriptModel.IfBlock ifBlock,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
+ final ConsumerInfo parentInfo) {
sb.append(" if (");
generateCondition(sb, ifBlock.getCondition());
sb.append(") {\n");
generateSampledTraceBodyFromFilterStmts(sb, ifBlock.getThenBranch(),
- parentInfo, subCounter);
+ parentInfo);
sb.append(" }\n");
if (!ifBlock.getElseBranch().isEmpty()) {
sb.append(" else {\n");
generateSampledTraceBodyFromFilterStmts(sb, ifBlock.getElseBranch(),
- parentInfo, subCounter);
+ parentInfo);
sb.append(" }\n");
}
}
@@ -504,8 +611,7 @@ public final class LALClassGenerator {
private void generateSampledTraceBodyFromFilterStmts(
final StringBuilder sb,
final List<? extends LALScriptModel.FilterStatement> stmts,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
+ final ConsumerInfo parentInfo) {
for (final LALScriptModel.FilterStatement stmt : stmts) {
if (stmt instanceof LALScriptModel.SampledTraceField) {
generateSampledTraceField(sb,
@@ -515,7 +621,7 @@ public final class LALClassGenerator {
(LALScriptModel.FieldAssignment) stmt);
} else if (stmt instanceof LALScriptModel.IfBlock) {
generateSampledTraceIfBlock(sb, (LALScriptModel.IfBlock) stmt,
- parentInfo, subCounter);
+ parentInfo);
}
}
}
@@ -544,8 +650,7 @@ public final class LALClassGenerator {
private void generateSinkBody(
final StringBuilder sb,
final List<? extends LALScriptModel.FilterStatement> stmts,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
+ final ConsumerInfo parentInfo) {
for (final LALScriptModel.FilterStatement stmt : stmts) {
if (stmt instanceof LALScriptModel.EnforcerStatement) {
sb.append(" _t.enforcer();\n");
@@ -553,10 +658,10 @@ public final class LALClassGenerator {
sb.append(" _t.dropper();\n");
} else if (stmt instanceof LALScriptModel.SamplerBlock) {
generateSamplerSubConsumer(sb, (LALScriptModel.SamplerBlock) stmt,
- parentInfo, subCounter);
+ parentInfo);
} else if (stmt instanceof LALScriptModel.IfBlock) {
generateIfBlockInBody(sb, (LALScriptModel.IfBlock) stmt,
- parentInfo, subCounter, false);
+ parentInfo, false);
}
}
}
@@ -566,34 +671,30 @@ public final class LALClassGenerator {
private void generateSamplerSubConsumer(
final StringBuilder sb,
final LALScriptModel.SamplerBlock block,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
- final int idx = subCounter[0]++;
+ final ConsumerInfo parentInfo) {
final StringBuilder body = new StringBuilder();
final ConsumerInfo sub = new ConsumerInfo("", SAMPLER_SPEC);
- final int[] innerSubCounter = {0};
- generateSamplerBody(body, block.getContents(), sub, innerSubCounter);
-
- parentInfo.subConsumers.add(new ConsumerInfo(body.toString(),
- SAMPLER_SPEC, sub.subConsumers));
- sb.append(" ((").append(PACKAGE_PREFIX)
- .append("BindingAware) this._sub").append(idx)
- .append(").setBinding(this.binding);\n");
- sb.append(" _t.sampler(this._sub").append(idx).append(");\n");
+ generateSamplerBody(body, block.getContents(), sub);
+
+ final ConsumerInfo propagated = new ConsumerInfo(body.toString(),
+ SAMPLER_SPEC, sub.subConsumers, sub.subFieldNames);
+ final String fieldName = parentInfo.nextSubFieldName(propagated);
+ sb.append(" this.").append(fieldName)
+ .append(".setBinding(this.binding);\n");
+ sb.append(" _t.sampler(this.").append(fieldName).append(");\n");
}
private void generateSamplerBody(
final StringBuilder sb,
final List<LALScriptModel.SamplerContent> contents,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
+ final ConsumerInfo parentInfo) {
for (final LALScriptModel.SamplerContent content : contents) {
if (content instanceof LALScriptModel.RateLimitBlock) {
generateRateLimitSubConsumer(sb, (LALScriptModel.RateLimitBlock) content,
- parentInfo, subCounter);
+ parentInfo);
} else if (content instanceof LALScriptModel.IfBlock) {
generateSamplerIfBlock(sb, (LALScriptModel.IfBlock) content,
- parentInfo, subCounter);
+ parentInfo);
}
}
}
@@ -601,18 +702,17 @@ public final class LALClassGenerator {
private void generateSamplerIfBlock(
final StringBuilder sb,
final LALScriptModel.IfBlock ifBlock,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
+ final ConsumerInfo parentInfo) {
sb.append(" if (");
generateCondition(sb, ifBlock.getCondition());
sb.append(") {\n");
generateSamplerBodyFromFilterStmts(sb, ifBlock.getThenBranch(),
- parentInfo, subCounter);
+ parentInfo);
sb.append(" }\n");
if (!ifBlock.getElseBranch().isEmpty()) {
sb.append(" else {\n");
generateSamplerBodyFromFilterStmts(sb, ifBlock.getElseBranch(),
- parentInfo, subCounter);
+ parentInfo);
sb.append(" }\n");
}
}
@@ -620,48 +720,32 @@ public final class LALClassGenerator {
private void generateSamplerBodyFromFilterStmts(
final StringBuilder sb,
final List<? extends LALScriptModel.FilterStatement> stmts,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
+ final ConsumerInfo parentInfo) {
for (final LALScriptModel.FilterStatement stmt : stmts) {
if (stmt instanceof LALScriptModel.SamplerBlock) {
- // SamplerBlock appears in if-branches inside a sampler
- generateSamplerSubConsumerInline(sb,
- (LALScriptModel.SamplerBlock) stmt,
- parentInfo, subCounter);
+ // SamplerBlock appears in if-branches inside a sampler,
+ // generate its contents inline
+ generateSamplerBody(sb,
+ ((LALScriptModel.SamplerBlock) stmt).getContents(),
+ parentInfo);
} else if (stmt instanceof LALScriptModel.IfBlock) {
generateSamplerIfBlock(sb, (LALScriptModel.IfBlock) stmt,
- parentInfo, subCounter);
+ parentInfo);
}
}
}
- private void generateSamplerSubConsumerInline(
- final StringBuilder sb,
- final LALScriptModel.SamplerBlock block,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
- // When a sampler block appears inside an if branch of a sampler,
- // generate its contents inline
- generateSamplerBody(sb, block.getContents(), parentInfo, subCounter);
- }
-
private void generateRateLimitSubConsumer(
final StringBuilder sb,
final LALScriptModel.RateLimitBlock block,
- final ConsumerInfo parentInfo,
- final int[] subCounter) {
- final int idx = subCounter[0]++;
+ final ConsumerInfo parentInfo) {
final String body = " _t.rpm(" + block.getRpm() + ");\n";
final ConsumerInfo sub = new ConsumerInfo(body, RATE_LIMITING_SAMPLER);
- parentInfo.subConsumers.add(sub);
- sb.append(" ((").append(PACKAGE_PREFIX)
- .append("BindingAware) this._sub").append(idx)
- .append(").setBinding(this.binding);\n");
+ final String fieldName = parentInfo.nextSubFieldName(sub);
+ sb.append(" this.").append(fieldName)
+ .append(".setBinding(this.binding);\n");
if (block.isIdInterpolated()) {
- // Emit string concatenation for interpolated IDs
- // e.g. "${log.service}:${parsed?.field}" →
- // "" + String.valueOf(binding.log().getService()) + ":" + String.valueOf(...)
sb.append(" _t.rateLimit(\"\"");
for (final LALScriptModel.InterpolationPart part : block.getIdParts()) {
sb.append(" + ");
@@ -673,11 +757,11 @@ public final class LALClassGenerator {
sb.append(")");
}
}
- sb.append(", this._sub").append(idx).append(");\n");
+ sb.append(", this.").append(fieldName).append(");\n");
} else {
sb.append(" _t.rateLimit(\"")
- .append(escapeJava(block.getId())).append("\", this._sub")
- .append(idx).append(");\n");
+ .append(escapeJava(block.getId())).append("\", this.")
+ .append(fieldName).append(");\n");
}
}
@@ -712,7 +796,23 @@ public final class LALClassGenerator {
// ==================== Phase 2: Compile consumer classes ====================
private Object compileConsumerClass(final String className,
- final ConsumerInfo info) throws Exception {
+ final ConsumerInfo info,
+ final List<CtClass> pendingDetach) throws Exception {
+ // Pre-compile sub-consumers so their types are available in ClassPool
+ final List<Object> subInstances = new ArrayList<>();
+ final List<String> subClassNames = new ArrayList<>();
+ final java.util.Map<String, Integer> subNameCounts = new java.util.HashMap<>();
+ for (int i = 0; i < info.subConsumers.size(); i++) {
+ final String subLabel = info.subConsumers.get(i).label();
+ final int cnt = subNameCounts.getOrDefault(subLabel, 0);
+ subNameCounts.put(subLabel, cnt + 1);
+ final String subSuffix = cnt == 0 ? subLabel : subLabel + "_" + (cnt + 1);
+ final String subName = dedupClassName(className + "$" + subSuffix);
+ subClassNames.add(subName);
+ subInstances.add(compileConsumerClass(
+ subName, info.subConsumers.get(i), pendingDetach));
+ }
+
final CtClass ctClass = classPool.makeClass(className);
ctClass.addInterface(classPool.get("java.util.function.Consumer"));
ctClass.addInterface(classPool.get(
@@ -729,10 +829,11 @@ public final class LALClassGenerator {
"public " + BINDING + " getBinding() {"
+ " return this.binding; }", ctClass));
- // Add sub-consumer fields
+ // Add sub-consumer fields with actual types
for (int i = 0; i < info.subConsumers.size(); i++) {
ctClass.addField(CtField.make(
- "public java.util.function.Consumer _sub" + i + ";",
+ "public " + subClassNames.get(i) + " "
+ + info.subFieldNames.get(i) + ";",
ctClass));
}
@@ -749,16 +850,15 @@ public final class LALClassGenerator {
ctClass.addMethod(CtNewMethod.make(method, ctClass));
+ writeClassFile(ctClass);
+
final Class<?> clazz = ctClass.toClass(LalExpressionPackageHolder.class);
- ctClass.detach();
+ pendingDetach.add(ctClass);
final Object instance = clazz.getDeclaredConstructor().newInstance();
- // Compile and wire sub-consumers
- for (int i = 0; i < info.subConsumers.size(); i++) {
- final String subName = className + "_S" + i;
- final Object subInstance = compileConsumerClass(
- subName, info.subConsumers.get(i));
- clazz.getField("_sub" + i).set(instance, subInstance);
+ // Wire pre-compiled sub-consumer fields
+ for (int i = 0; i < subInstances.size(); i++) {
+ clazz.getField(info.subFieldNames.get(i)).set(instance, subInstances.get(i));
}
return instance;
@@ -767,14 +867,15 @@ public final class LALClassGenerator {
// ==================== Phase 4: Generate execute method ====================
private String generateExecuteMethod(final LALScriptModel model,
- final int[] counter) {
+ final int[] counter,
+ final List<String> fieldNames) {
final StringBuilder sb = new StringBuilder();
sb.append("public void execute(").append(FILTER_SPEC)
.append(" filterSpec, ").append(BINDING).append(" binding) {\n");
for (final LALScriptModel.FilterStatement stmt
: model.getStatements()) {
- generateFilterStatement(sb, stmt, counter);
+ generateFilterStatement(sb, stmt, counter, fieldNames);
}
sb.append("}\n");
@@ -783,68 +884,71 @@ public final class LALClassGenerator {
private void generateFilterStatement(final StringBuilder sb,
final LALScriptModel.FilterStatement stmt,
- final int[] counter) {
+ final int[] counter,
+ final List<String> fieldNames) {
if (stmt instanceof LALScriptModel.TextParser) {
final LALScriptModel.TextParser tp = (LALScriptModel.TextParser) stmt;
if (tp.getRegexpPattern() != null) {
- emitConsumerCall(sb, "filterSpec.text", counter);
+ emitConsumerCall(sb, "filterSpec.text", counter, fieldNames);
} else {
sb.append(" filterSpec.text();\n");
}
} else if (stmt instanceof LALScriptModel.JsonParser) {
if (((LALScriptModel.JsonParser) stmt).isAbortOnFailure()) {
- emitConsumerCall(sb, "filterSpec.json", counter);
+ emitConsumerCall(sb, "filterSpec.json", counter, fieldNames);
} else {
sb.append(" filterSpec.json();\n");
}
} else if (stmt instanceof LALScriptModel.YamlParser) {
if (((LALScriptModel.YamlParser) stmt).isAbortOnFailure()) {
- emitConsumerCall(sb, "filterSpec.yaml", counter);
+ emitConsumerCall(sb, "filterSpec.yaml", counter, fieldNames);
} else {
sb.append(" filterSpec.yaml();\n");
}
} else if (stmt instanceof LALScriptModel.AbortStatement) {
sb.append(" filterSpec.abort();\n");
} else if (stmt instanceof LALScriptModel.ExtractorBlock) {
- emitConsumerCall(sb, "filterSpec.extractor", counter);
+ emitConsumerCall(sb, "filterSpec.extractor", counter, fieldNames);
} else if (stmt instanceof LALScriptModel.SinkBlock) {
final LALScriptModel.SinkBlock sink = (LALScriptModel.SinkBlock) stmt;
if (sink.getStatements().isEmpty()) {
sb.append(" filterSpec.sink();\n");
} else {
- emitConsumerCall(sb, "filterSpec.sink", counter);
+ emitConsumerCall(sb, "filterSpec.sink", counter, fieldNames);
}
} else if (stmt instanceof LALScriptModel.IfBlock) {
- generateIfBlock(sb, (LALScriptModel.IfBlock) stmt, counter);
+ generateIfBlock(sb, (LALScriptModel.IfBlock) stmt,
+ counter, fieldNames);
}
}
private void emitConsumerCall(final StringBuilder sb,
final String methodPrefix,
- final int[] counter) {
- final int idx = counter[0]++;
- sb.append(" ((")
- .append(PACKAGE_PREFIX).append("BindingAware) this._consumer")
- .append(idx).append(").setBinding(binding);\n");
+ final int[] counter,
+ final List<String> fieldNames) {
+ final String fieldName = fieldNames.get(counter[0]++);
+ sb.append(" this.").append(fieldName)
+ .append(".setBinding(binding);\n");
sb.append(" ").append(methodPrefix)
- .append("(this._consumer").append(idx).append(");\n");
+ .append("(this.").append(fieldName).append(");\n");
}
private void generateIfBlock(final StringBuilder sb,
final LALScriptModel.IfBlock ifBlock,
- final int[] counter) {
+ final int[] counter,
+ final List<String> fieldNames) {
sb.append(" if (");
generateCondition(sb, ifBlock.getCondition());
sb.append(") {\n");
for (final LALScriptModel.FilterStatement s : ifBlock.getThenBranch()) {
- generateFilterStatement(sb, s, counter);
+ generateFilterStatement(sb, s, counter, fieldNames);
}
sb.append(" }\n");
if (!ifBlock.getElseBranch().isEmpty()) {
sb.append(" else {\n");
for (final LALScriptModel.FilterStatement s
: ifBlock.getElseBranch()) {
- generateFilterStatement(sb, s, counter);
+ generateFilterStatement(sb, s, counter, fieldNames);
}
sb.append(" }\n");
}
@@ -860,9 +964,7 @@ public final class LALClassGenerator {
+ " return ((" + BINDING_PARSED + ") obj).getAt(key);"
+ " if (obj instanceof java.util.Map)"
+ " return ((java.util.Map) obj).get(key);"
- + " Object protoResult = " + BINDING_PARSED + ".getField(obj, key);"
- + " if (protoResult != null) return protoResult;"
- + " return null;"
+ + " return " + BINDING_PARSED + ".getField(obj, key);"
+ "}", ctClass));
ctClass.addMethod(CtNewMethod.make(
@@ -1229,7 +1331,19 @@ public final class LALClassGenerator {
*/
public String generateSource(final String dsl) {
final LALScriptModel model = LALScriptParser.parse(dsl);
+ final List<ConsumerInfo> consumers = new ArrayList<>();
+ collectConsumers(model.getStatements(), consumers);
+ // Build field names for source generation
+ final List<String> fieldNames = new ArrayList<>();
+ final java.util.Map<String, Integer> nameCounts = new java.util.HashMap<>();
+ for (final ConsumerInfo ci : consumers) {
+ final String label = ci.label();
+ final int count = nameCounts.getOrDefault(label, 0);
+ nameCounts.put(label, count + 1);
+ final String suffix = count == 0 ? label : label + "_" + (count + 1);
+ fieldNames.add("_" + suffix);
+ }
final int[] counter = {0};
- return generateExecuteMethod(model, counter);
+ return generateExecuteMethod(model, counter, fieldNames);
}
}
diff --git a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/Binding.java b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/Binding.java
index 442ccaac08..93bfe1d895 100644
--- a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/Binding.java
+++ b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/Binding.java
@@ -46,7 +46,7 @@ import org.apache.skywalking.oap.server.core.source.Log;
* <li>{@code log_container} — optional container for the built {@code Log} source object</li>
* </ul>
*
- * <p>The Binding is injected into {@link org.apache.skywalking.oap.log.analyzer.dsl.spec.AbstractSpec}
+ * <p>The Binding is injected into {@link org.apache.skywalking.oap.log.analyzer.v2.dsl.spec.AbstractSpec}
* via a ThreadLocal ({@code BINDING}), so all Spec methods ({@code FilterSpec}, {@code ExtractorSpec},
* {@code SinkSpec}) can access the current log data without explicit parameter passing.
*/
diff --git a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/LalExpression.java b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/LalExpression.java
index bcb8811c34..624a9d74bd 100644
--- a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/LalExpression.java
+++ b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/LalExpression.java
@@ -24,7 +24,7 @@ import org.apache.skywalking.oap.log.analyzer.v2.dsl.spec.filter.FilterSpec;
* Functional interface implemented by each compiled LAL class.
*
* <p>Generated at startup by
- * {@link org.apache.skywalking.oap.log.analyzer.compiler.LALClassGenerator}
+ * {@link org.apache.skywalking.oap.log.analyzer.v2.compiler.LALClassGenerator}
* via ANTLR4 parsing and Javassist bytecode generation.
* The generated {@code execute} method calls {@link FilterSpec} methods
* (json/text/yaml, extractor, sink) in the order defined by the LAL script.
diff --git a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/spec/filter/FilterSpec.java b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/spec/filter/FilterSpec.java
index a8cd6365fd..260b29fdf4 100644
--- a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/spec/filter/FilterSpec.java
+++ b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/spec/filter/FilterSpec.java
@@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
/**
* The top-level runtime API that compiled LAL expressions invoke.
*
- * <p>A compiled {@link org.apache.skywalking.oap.log.analyzer.dsl.LalExpression}
+ * <p>A compiled {@link org.apache.skywalking.oap.log.analyzer.v2.dsl.LalExpression}
* calls methods on this class in the order defined by the LAL script:
* <ol>
* <li><b>Parser</b>: {@code json()}, {@code text()}, or {@code yaml()} — parses the log body
@@ -64,7 +64,7 @@ import org.slf4j.LoggerFactory;
*
* <p>All methods read the current log data from the ThreadLocal {@code BINDING}
* (inherited from {@link AbstractSpec}), which is set by
- * {@link org.apache.skywalking.oap.log.analyzer.dsl.DSL#bind(Binding)} before each execution.
+ * {@link org.apache.skywalking.oap.log.analyzer.v2.dsl.DSL#bind(Binding)} before each execution.
* Every method checks {@code shouldAbort()} first and short-circuits if a previous
* step aborted the pipeline.
*/
@@ -124,25 +124,17 @@ public class FilterSpec extends AbstractSpec {
return;
}
consumer.accept(jsonParser);
-
- final LogData.Builder logData = BINDING.get().log();
- try {
- final Map<String, Object> parsed = jsonParser.create().readValue(
- logData.getBody().getJson().getJson(), parsedType
- );
- BINDING.get().parsed(parsed);
- } catch (final Exception e) {
- if (jsonParser.abortOnFailure()) {
- BINDING.get().abort();
- }
- }
+ doJson();
}
public void json() {
if (BINDING.get().shouldAbort()) {
return;
}
+ doJson();
+ }
+ private void doJson() {
final LogData.Builder logData = BINDING.get().log();
try {
final Map<String, Object> parsed = jsonParser.create().readValue(
@@ -161,25 +153,17 @@ public class FilterSpec extends AbstractSpec {
return;
}
consumer.accept(yamlParser);
-
- final LogData.Builder logData = BINDING.get().log();
- try {
- final Map<String, Object> parsed = yamlParser.create().load(
- logData.getBody().getYaml().getYaml()
- );
- BINDING.get().parsed(parsed);
- } catch (final Exception e) {
- if (yamlParser.abortOnFailure()) {
- BINDING.get().abort();
- }
- }
+ doYaml();
}
public void yaml() {
if (BINDING.get().shouldAbort()) {
return;
}
+ doYaml();
+ }
+ private void doYaml() {
final LogData.Builder logData = BINDING.get().log();
try {
final Map<String, Object> parsed = yamlParser.create().load(
@@ -205,40 +189,17 @@ public class FilterSpec extends AbstractSpec {
return;
}
consumer.accept(sink);
-
- final Binding b = BINDING.get();
- final LogData.Builder logData = b.log();
- final Message extraLog = b.extraLog();
-
- if (!b.shouldSave()) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Log is dropped: {}", TextFormat.shortDebugString(logData));
- }
- return;
- }
-
- final Optional<AtomicReference<Log>> container = BINDING.get().logContainer();
- if (container.isPresent()) {
- sinkListenerFactories.stream()
- .map(LogSinkListenerFactory::create)
- .filter(it -> it instanceof RecordSinkListener)
- .map(it -> it.parse(logData, extraLog))
- .map(it -> (RecordSinkListener) it)
- .map(RecordSinkListener::getLog)
- .findFirst()
- .ifPresent(log -> container.get().set(log));
- } else {
- sinkListenerFactories.stream()
- .map(LogSinkListenerFactory::create)
- .forEach(it -> it.parse(logData, extraLog).build());
- }
+ doSink();
}
public void sink() {
if (BINDING.get().shouldAbort()) {
return;
}
+ doSink();
+ }
+ private void doSink() {
final Binding b = BINDING.get();
final LogData.Builder logData = b.log();
final Message extraLog = b.extraLog();
diff --git a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/spec/parser/TextParserSpec.java b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/spec/parser/TextParserSpec.java
index 4f6866d674..8d20281479 100644
--- a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/spec/parser/TextParserSpec.java
+++ b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/spec/parser/TextParserSpec.java
@@ -49,9 +49,4 @@ public class TextParserSpec extends AbstractParserSpec {
}
}
- public boolean grok(final String grok) {
- // TODO
- return false;
- }
-
}
diff --git a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/LogAnalyzer.java b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/LogAnalyzer.java
index 8acdb58de2..6ae2c312ec 100644
--- a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/LogAnalyzer.java
+++ b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/LogAnalyzer.java
@@ -39,16 +39,16 @@ import org.apache.skywalking.oap.server.library.module.ModuleManager;
* <ol>
* <li>Validates the incoming log (service name must be non-empty, layer must be valid).</li>
* <li>Calls {@code createAnalysisListeners(layer)} — asks all registered
- * {@link org.apache.skywalking.oap.log.analyzer.provider.log.listener.LogAnalysisListenerFactory}
+ * {@link org.apache.skywalking.oap.log.analyzer.v2.provider.log.listener.LogAnalysisListenerFactory}
* instances to create listeners for the log's layer. For LAL, this is
- * {@link org.apache.skywalking.oap.log.analyzer.provider.log.listener.LogFilterListener.Factory},
- * which returns a listener wrapping all compiled {@link org.apache.skywalking.oap.log.analyzer.dsl.DSL}
+ * {@link org.apache.skywalking.oap.log.analyzer.v2.provider.log.listener.LogFilterListener.Factory},
+ * which returns a listener wrapping all compiled {@link org.apache.skywalking.oap.log.analyzer.v2.dsl.DSL}
* instances for that layer.</li>
* <li>{@code notifyAnalysisListener(builder, extraLog)} — calls
- * {@link org.apache.skywalking.oap.log.analyzer.provider.log.listener.LogAnalysisListener#parse}
+ * {@link org.apache.skywalking.oap.log.analyzer.v2.provider.log.listener.LogAnalysisListener#parse}
* on each listener, which binds the log data to the compiled LAL scripts.</li>
* <li>{@code notifyAnalysisListenerToBuild()} — calls
- * {@link org.apache.skywalking.oap.log.analyzer.provider.log.listener.LogAnalysisListener#build}
+ * {@link org.apache.skywalking.oap.log.analyzer.v2.provider.log.listener.LogAnalysisListener#build}
* on each listener, which evaluates the compiled LAL scripts (extractors, sinks).</li>
* </ol>
*/
diff --git a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/listener/LogFilterListener.java b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/listener/LogFilterListener.java
index 6e02c3a13c..979026d931 100644
--- a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/listener/LogFilterListener.java
+++ b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/listener/LogFilterListener.java
@@ -44,17 +44,17 @@ import org.apache.skywalking.oap.server.library.module.ModuleStartException;
* <p>Each instance wraps a collection of {@link DSL} objects — one per LAL rule
* defined for a specific {@link Layer}. Created per-log by {@link Factory#create(Layer)}.
*
- * <p>Two-phase execution (called by {@link org.apache.skywalking.oap.log.analyzer.provider.log.LogAnalyzer}):
+ * <p>Two-phase execution (called by {@link org.apache.skywalking.oap.log.analyzer.v2.provider.log.LogAnalyzer}):
* <ol>
* <li>{@link #parse} — creates a fresh {@link Binding} with the current log data
* and binds it to every DSL instance (sets the ThreadLocal in each Spec).</li>
* <li>{@link #build} — calls {@link DSL#evaluate()} on every DSL instance,
- * which invokes the compiled {@link org.apache.skywalking.oap.log.analyzer.dsl.LalExpression}
+ * which invokes the compiled {@link org.apache.skywalking.oap.log.analyzer.v2.dsl.LalExpression}
* to run the filter/extractor/sink pipeline.</li>
* </ol>
*
* <p>The inner {@link Factory} is created once at startup by
- * {@link org.apache.skywalking.oap.log.analyzer.provider.LogAnalyzerModuleProvider#start()}.
+ * {@link org.apache.skywalking.oap.log.analyzer.v2.provider.LogAnalyzerModuleProvider#start()}.
* It loads all {@code .yaml} LAL config files, compiles each rule's DSL string
* into a {@link DSL} instance via
* {@link DSL#of(org.apache.skywalking.oap.server.library.module.ModuleManager,
diff --git a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/Analyzer.java b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/Analyzer.java
index 4d028cfb90..3e501c1f95 100644
--- a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/Analyzer.java
+++ b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/Analyzer.java
@@ -75,7 +75,7 @@ import static java.util.stream.Collectors.toList;
* <p>Initialization ({@link #build}):
* <ol>
* <li>Compiles the MAL expression string into a
- * {@link org.apache.skywalking.oap.meter.analyzer.dsl.MalExpression MalExpression}
+ * {@link org.apache.skywalking.oap.meter.analyzer.v2.dsl.MalExpression MalExpression}
* via ANTLR4 + Javassist.</li>
* <li>Extracts compile-time {@link ExpressionMetadata} from the AST (sample names, scope type,
* aggregation labels, downsampling, histogram/percentile info).</li>
diff --git a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/MetricConvert.java b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/MetricConvert.java
index 67cb242fb1..a68ac4855d 100644
--- a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/MetricConvert.java
+++ b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/MetricConvert.java
@@ -27,10 +27,6 @@ import java.util.StringJoiner;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.apache.skywalking.oap.meter.analyzer.v2.dsl.DSL;
-import org.apache.skywalking.oap.meter.analyzer.v2.dsl.Expression;
-import org.apache.skywalking.oap.meter.analyzer.v2.dsl.ExpressionParsingException;
-import org.apache.skywalking.oap.meter.analyzer.v2.dsl.Result;
import org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily;
import org.apache.skywalking.oap.server.core.analysis.meter.MeterSystem;
@@ -77,10 +73,6 @@ public class MetricConvert {
public MetricConvert(MetricRuleConfig rule, MeterSystem service) {
Preconditions.checkState(!Strings.isNullOrEmpty(rule.getMetricPrefix()));
- // init expression script
- if (StringUtils.isNotEmpty(rule.getInitExp())) {
- handleInitExp(rule.getInitExp());
- }
this.analyzers = rule.getMetricsRules().stream().map(
r -> buildAnalyzer(
formatMetricName(rule, r.getName()),
@@ -147,13 +139,4 @@ public class MetricConvert {
metricName.add(rule.getMetricPrefix()).add(meterRuleName);
return metricName.toString();
}
-
- private void handleInitExp(String exp) {
- Expression e = DSL.parse(null, exp);
- final Result result = e.run(ImmutableMap.of());
- if (!result.isSuccess() && result.isThrowable()) {
- throw new ExpressionParsingException(
- "failed to execute init expression: " + exp + ", error:" + result.getError());
- }
- }
}
diff --git a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/MetricRuleConfig.java b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/MetricRuleConfig.java
index a67f7ed250..2593915270 100644
--- a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/MetricRuleConfig.java
+++ b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/MetricRuleConfig.java
@@ -47,11 +47,6 @@ public interface MetricRuleConfig {
String getFilter();
- /**
- * Get the init expression script
- */
- String getInitExp();
-
interface RuleConfig {
/**
* Get definition metrics name
diff --git a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALClassGenerator.java b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALClassGenerator.java
index a057020d2e..e5f74bc919 100644
--- a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALClassGenerator.java
+++ b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALClassGenerator.java
@@ -17,6 +17,9 @@
package org.apache.skywalking.oap.meter.analyzer.v2.compiler;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
@@ -80,8 +83,14 @@ public final class MALClassGenerator {
"org.apache.skywalking.oap.meter.analyzer.v2.dsl.registry.ProcessRegistry");
}
+ private static final Set<String> USED_CLASS_NAMES =
+ java.util.Collections.synchronizedSet(new java.util.HashSet<>());
+
private final ClassPool classPool;
- private int closureCounter;
+ private List<String> closureFieldNames;
+ private int closureFieldIndex;
+ private File classOutputDir;
+ private String classNameHint;
public MALClassGenerator() {
this(createClassPool());
@@ -99,6 +108,94 @@ public final class MALClassGenerator {
this.classPool = classPool;
}
+ public void setClassOutputDir(final File dir) {
+ this.classOutputDir = dir;
+ }
+
+ public void setClassNameHint(final String hint) {
+ this.classNameHint = hint;
+ }
+
+ private String makeClassName(final String defaultPrefix) {
+ if (classNameHint != null) {
+ return dedupClassName(PACKAGE_PREFIX + sanitizeName(classNameHint));
+ }
+ return PACKAGE_PREFIX + defaultPrefix + CLASS_COUNTER.getAndIncrement();
+ }
+
+ private String dedupClassName(final String base) {
+ if (USED_CLASS_NAMES.add(base)) {
+ return base;
+ }
+ for (int i = 2; ; i++) {
+ final String candidate = base + "_" + i;
+ if (USED_CLASS_NAMES.add(candidate)) {
+ return candidate;
+ }
+ }
+ }
+
+ static String sanitizeName(final String name) {
+ final StringBuilder sb = new StringBuilder(name.length());
+ for (int i = 0; i < name.length(); i++) {
+ final char c = name.charAt(i);
+ sb.append(i == 0
+ ? (Character.isJavaIdentifierStart(c) ? c : '_')
+ : (Character.isJavaIdentifierPart(c) ? c : '_'));
+ }
+ return sb.length() == 0 ? "Generated" : sb.toString();
+ }
+
+ private void writeClassFile(final CtClass ctClass) {
+ if (classOutputDir == null) {
+ return;
+ }
+ if (!classOutputDir.exists()) {
+ classOutputDir.mkdirs();
+ }
+ final File file = new File(classOutputDir, ctClass.getSimpleName() + ".class");
+ try (DataOutputStream out = new DataOutputStream(new FileOutputStream(file))) {
+ ctClass.toBytecode(out);
+ } catch (Exception e) {
+ log.warn("Failed to write class file {}: {}", file, e.getMessage());
+ }
+ }
+
+ private void addRunLocalVariableTable(final javassist.CtMethod method,
+ final String className,
+ final int tempCount) {
+ try {
+ final javassist.bytecode.MethodInfo mi = method.getMethodInfo();
+ final javassist.bytecode.CodeAttribute code = mi.getCodeAttribute();
+ if (code == null) {
+ return;
+ }
+ final javassist.bytecode.ConstPool cp = mi.getConstPool();
+ final int len = code.getCodeLength();
+ final String sfDesc = "L" + SF.replace('.', '/') + ";";
+
+ final javassist.bytecode.LocalVariableAttribute lva =
+ new javassist.bytecode.LocalVariableAttribute(cp);
+ lva.addEntry(0, len,
+ cp.addUtf8Info("this"),
+ cp.addUtf8Info("L" + className.replace('.', '/') + ";"), 0);
+ lva.addEntry(0, len,
+ cp.addUtf8Info("samples"),
+ cp.addUtf8Info("Ljava/util/Map;"), 1);
+ lva.addEntry(0, len,
+ cp.addUtf8Info(RUN_VAR),
+ cp.addUtf8Info(sfDesc), 2);
+ for (int i = 0; i < tempCount; i++) {
+ lva.addEntry(0, len,
+ cp.addUtf8Info("_t" + i),
+ cp.addUtf8Info(sfDesc), 3 + i);
+ }
+ code.getAttributes().add(lva);
+ } catch (Exception e) {
+ log.warn("Failed to add LocalVariableTable: {}", e.getMessage());
+ }
+ }
+
/**
* Compiles a MAL expression into a MalExpression implementation.
*
@@ -109,7 +206,15 @@ public final class MALClassGenerator {
public MalExpression compile(final String metricName,
final String expression) throws Exception {
final MALExpressionModel.Expr ast = MALScriptParser.parse(expression);
- return compileFromModel(metricName, ast);
+ final String saved = classNameHint;
+ if (classNameHint == null) {
+ classNameHint = metricName;
+ }
+ try {
+ return compileFromModel(metricName, ast);
+ } finally {
+ classNameHint = saved;
+ }
}
/**
@@ -123,8 +228,7 @@ public final class MALClassGenerator {
final MALExpressionModel.ClosureArgument closure =
MALScriptParser.parseFilter(filterExpression);
- final String className = PACKAGE_PREFIX + "MalFilter_"
- + CLASS_COUNTER.getAndIncrement();
+ final String className = makeClassName("MalFilter_");
final CtClass ctClass = classPool.makeClass(className);
ctClass.addInterface(classPool.get(
@@ -174,6 +278,8 @@ public final class MALClassGenerator {
ctClass.addMethod(CtNewMethod.make(filterBody, ctClass));
+ writeClassFile(ctClass);
+
final Class<?> clazz = ctClass.toClass(MalExpressionPackageHolder.class);
ctClass.detach();
return (MalFilter) clazz.getDeclaredConstructor().newInstance();
@@ -184,19 +290,29 @@ public final class MALClassGenerator {
*/
public MalExpression compileFromModel(final String metricName,
final MALExpressionModel.Expr ast) throws Exception {
- final String className = PACKAGE_PREFIX + "MalExpr_"
- + CLASS_COUNTER.getAndIncrement();
+ final String className = makeClassName("MalExpr_");
- closureCounter = 0;
+ closureFieldIndex = 0;
final List<ClosureInfo> closures = new ArrayList<>();
collectClosures(ast, closures);
- // Generate closure classes first
+ // Generate closure classes first, named by purpose (tag/forEach/instance/decorate)
+ // Defer detach until after main class is compiled so types remain in ClassPool
+ final List<CtClass> pendingDetach = new ArrayList<>();
final List<Object> closureInstances = new ArrayList<>();
+ final List<String> closureFieldNames = new ArrayList<>();
+ final List<String> closureClassNames = new ArrayList<>();
+ final java.util.Map<String, Integer> closureNameCounts = new java.util.HashMap<>();
for (int i = 0; i < closures.size(); i++) {
- final String closureName = className + "_Closure" + i;
+ final String purpose = closures.get(i).methodName;
+ final int count = closureNameCounts.getOrDefault(purpose, 0);
+ closureNameCounts.put(purpose, count + 1);
+ final String suffix = count == 0 ? purpose : purpose + "_" + (count + 1);
+ closureFieldNames.add("_" + suffix);
+ final String closureName = dedupClassName(className + "$" + suffix);
+ closureClassNames.add(closureName);
final Object instance = compileClosureClass(
- closureName, closures.get(i));
+ closureName, closures.get(i), pendingDetach);
closureInstances.add(instance);
}
@@ -204,15 +320,17 @@ public final class MALClassGenerator {
ctClass.addInterface(classPool.get(
"org.apache.skywalking.oap.meter.analyzer.v2.dsl.MalExpression"));
- // Add closure fields
+ // Add closure fields with actual types
for (int i = 0; i < closures.size(); i++) {
- final String fieldType = closures.get(i).interfaceType;
ctClass.addField(javassist.CtField.make(
- "public " + fieldType + " _closure" + i + ";", ctClass));
+ "public " + closureClassNames.get(i) + " "
+ + closureFieldNames.get(i) + ";", ctClass));
}
ctClass.addConstructor(CtNewConstructor.defaultConstructor(ctClass));
+ this.closureFieldNames = closureFieldNames;
+ this.closureFieldIndex = 0;
final String runBody = generateRunMethod(ast);
final ExpressionMetadata metadata = extractMetadata(ast);
final String metadataBody = generateMetadataMethod(metadata);
@@ -223,18 +341,25 @@ public final class MALClassGenerator {
log.debug("MAL compile [{}] metadata():\n{}", metricName, metadataBody);
}
- ctClass.addMethod(CtNewMethod.make(runBody, ctClass));
+ final javassist.CtMethod runMethod = CtNewMethod.make(runBody, ctClass);
+ ctClass.addMethod(runMethod);
+ addRunLocalVariableTable(runMethod, className, runTempCounter);
ctClass.addMethod(CtNewMethod.make(metadataBody, ctClass));
+ writeClassFile(ctClass);
+
final Class<?> clazz = ctClass.toClass(MalExpressionPackageHolder.class);
ctClass.detach();
+ for (final CtClass ct : pendingDetach) {
+ ct.detach();
+ }
final MalExpression instance = (MalExpression) clazz.getDeclaredConstructor()
.newInstance();
// Set closure fields via reflection
for (int i = 0; i < closureInstances.size(); i++) {
final java.lang.reflect.Field field =
- clazz.getField("_closure" + i);
+ clazz.getField(closureFieldNames.get(i));
field.set(instance, closureInstances.get(i));
}
@@ -244,12 +369,15 @@ public final class MALClassGenerator {
private static final class ClosureInfo {
final MALExpressionModel.ClosureArgument closure;
final String interfaceType;
+ final String methodName;
int fieldIndex;
ClosureInfo(final MALExpressionModel.ClosureArgument closure,
- final String interfaceType) {
+ final String interfaceType,
+ final String methodName) {
this.closure = closure;
this.interfaceType = interfaceType;
+ this.methodName = methodName;
}
}
@@ -306,7 +434,7 @@ public final class MALClassGenerator {
}
final ClosureInfo info = new ClosureInfo(
(MALExpressionModel.ClosureArgument) arg,
- interfaceType);
+ interfaceType, methodName);
info.fieldIndex = closures.size();
closures.add(info);
} else if (arg instanceof MALExpressionModel.ExprArgument) {
@@ -332,7 +460,8 @@ public final class MALClassGenerator {
"org.apache.skywalking.oap.meter.analyzer.v2.compiler.rt.MalRuntimeHelper";
private Object compileClosureClass(final String className,
- final ClosureInfo info) throws Exception {
+ final ClosureInfo info,
+ final List<CtClass> pendingDetach) throws Exception {
final CtClass ctClass = classPool.makeClass(className);
ctClass.addInterface(classPool.get(info.interfaceType));
ctClass.addConstructor(CtNewConstructor.defaultConstructor(ctClass));
@@ -439,21 +568,208 @@ public final class MALClassGenerator {
ctClass));
}
+ writeClassFile(ctClass);
+
final Class<?> clazz = ctClass.toClass(MalExpressionPackageHolder.class);
- ctClass.detach();
+ pendingDetach.add(ctClass);
return clazz.getDeclaredConstructor().newInstance();
}
+ private static final String RUN_VAR = "sf";
+
+ private int runTempCounter;
+
private String generateRunMethod(final MALExpressionModel.Expr ast) {
+ runTempCounter = 0;
final StringBuilder sb = new StringBuilder();
sb.append("public ").append(SF).append(" run(java.util.Map samples) {\n");
- sb.append(" return ");
- generateExpr(sb, ast);
- sb.append(";\n");
+ sb.append(" ").append(SF).append(" ").append(RUN_VAR).append(";\n");
+ generateExprStatements(sb, ast);
+ sb.append(" return ").append(RUN_VAR).append(";\n");
sb.append("}\n");
return sb.toString();
}
+ private String nextTemp() {
+ return "_t" + runTempCounter++;
+ }
+
+ /**
+ * Emits the expression as a series of {@code sf = ...;} reassignment statements,
+ * one per chain call. All results are stored in the single {@code sf} variable.
+ * For binary SF op SF expressions, a temporary variable saves the left operand.
+ */
+ private void generateExprStatements(final StringBuilder sb,
+ final MALExpressionModel.Expr expr) {
+ if (expr instanceof MALExpressionModel.MetricExpr) {
+ generateMetricExprStatements(
+ sb, (MALExpressionModel.MetricExpr) expr);
+ } else if (expr instanceof MALExpressionModel.NumberExpr) {
+ final double val = ((MALExpressionModel.NumberExpr) expr).getValue();
+ sb.append(" ").append(RUN_VAR).append(" = ")
+ .append(SF).append(".EMPTY.plus(Double.valueOf(")
+ .append(val).append("));\n");
+ } else if (expr instanceof MALExpressionModel.BinaryExpr) {
+ generateBinaryExprStatements(
+ sb, (MALExpressionModel.BinaryExpr) expr);
+ } else if (expr instanceof MALExpressionModel.UnaryNegExpr) {
+ generateExprStatements(
+ sb, ((MALExpressionModel.UnaryNegExpr) expr).getOperand());
+ sb.append(" ").append(RUN_VAR).append(" = ")
+ .append(RUN_VAR).append(".negative();\n");
+ } else if (expr instanceof MALExpressionModel.FunctionCallExpr) {
+ generateFunctionCallStatements(
+ sb, (MALExpressionModel.FunctionCallExpr) expr);
+ } else if (expr instanceof MALExpressionModel.ParenChainExpr) {
+ generateParenChainStatements(
+ sb, (MALExpressionModel.ParenChainExpr) expr);
+ } else {
+ throw new IllegalArgumentException("Unknown expr type: " + expr);
+ }
+ }
+
+ private void generateMetricExprStatements(
+ final StringBuilder sb, final MALExpressionModel.MetricExpr expr) {
+ sb.append(" ").append(RUN_VAR).append(" = ((").append(SF)
+ .append(") samples.getOrDefault(\"")
+ .append(escapeJava(expr.getMetricName()))
+ .append("\", ").append(SF).append(".EMPTY));\n");
+ emitChainStatements(sb, expr.getMethodChain());
+ }
+
+ private void generateParenChainStatements(
+ final StringBuilder sb, final MALExpressionModel.ParenChainExpr expr) {
+ generateExprStatements(sb, expr.getInner());
+ emitChainStatements(sb, expr.getMethodChain());
+ }
+
+ private void generateFunctionCallStatements(
+ final StringBuilder sb, final MALExpressionModel.FunctionCallExpr expr) {
+ final String fn = expr.getFunctionName();
+ final List<MALExpressionModel.Argument> args = expr.getArguments();
+
+ if (("count".equals(fn) || "topN".equals(fn)) && !args.isEmpty()) {
+ final MALExpressionModel.Argument firstArg = args.get(0);
+ if (firstArg instanceof MALExpressionModel.ExprArgument) {
+ generateExprStatements(
+ sb, ((MALExpressionModel.ExprArgument) firstArg).getExpr());
+ }
+ sb.append(" ").append(RUN_VAR).append(" = ")
+ .append(RUN_VAR).append('.').append(fn).append('(');
+ for (int i = 1; i < args.size(); i++) {
+ if (i > 1) {
+ sb.append(", ");
+ }
+ generateArgument(sb, args.get(i));
+ }
+ sb.append(");\n");
+ } else {
+ sb.append(" ").append(RUN_VAR).append(" = ")
+ .append(fn).append('(');
+ for (int i = 0; i < args.size(); i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ generateArgument(sb, args.get(i));
+ }
+ sb.append(");\n");
+ }
+ emitChainStatements(sb, expr.getMethodChain());
+ }
+
+ private void generateBinaryExprStatements(
+ final StringBuilder sb, final MALExpressionModel.BinaryExpr expr) {
+ final MALExpressionModel.Expr left = expr.getLeft();
+ final MALExpressionModel.Expr right = expr.getRight();
+ final MALExpressionModel.ArithmeticOp op = expr.getOp();
+
+ final boolean leftIsNumber = left instanceof MALExpressionModel.NumberExpr
+ || isScalarFunction(left);
+ final boolean rightIsNumber = right instanceof MALExpressionModel.NumberExpr
+ || isScalarFunction(right);
+
+ if (leftIsNumber && !rightIsNumber) {
+ generateExprStatements(sb, right);
+ sb.append(" ").append(RUN_VAR).append(" = ");
+ switch (op) {
+ case ADD:
+ sb.append(RUN_VAR).append(".plus(Double.valueOf(");
+ generateScalarExpr(sb, left);
+ sb.append("))");
+ break;
+ case SUB:
+ sb.append(RUN_VAR).append(".minus(Double.valueOf(");
+ generateScalarExpr(sb, left);
+ sb.append(")).negative()");
+ break;
+ case MUL:
+ sb.append(RUN_VAR).append(".multiply(Double.valueOf(");
+ generateScalarExpr(sb, left);
+ sb.append("))");
+ break;
+ case DIV:
+ sb.append("org.apache.skywalking.oap.meter.analyzer.v2.compiler.rt")
+ .append(".MalRuntimeHelper.divReverse(");
+ generateScalarExpr(sb, left);
+ sb.append(", ").append(RUN_VAR).append(")");
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported op: " + op);
+ }
+ sb.append(";\n");
+ } else if (!leftIsNumber && rightIsNumber) {
+ generateExprStatements(sb, left);
+ sb.append(" ").append(RUN_VAR).append(" = ")
+ .append(RUN_VAR).append(".").append(opMethodName(op))
+ .append("(Double.valueOf(");
+ generateScalarExpr(sb, right);
+ sb.append("));\n");
+ } else {
+ // SF op SF: compute left to sf, save to temp, compute right to sf, combine
+ generateExprStatements(sb, left);
+ final String temp = nextTemp();
+ sb.append(" ").append(SF).append(" ").append(temp)
+ .append(" = ").append(RUN_VAR).append(";\n");
+ generateExprStatements(sb, right);
+ sb.append(" ").append(RUN_VAR).append(" = ")
+ .append(temp).append(".").append(opMethodName(op))
+ .append("(").append(RUN_VAR).append(");\n");
+ }
+ }
+
+ /**
+ * Emits each method chain call as a reassignment of {@code sf}.
+ */
+ private void emitChainStatements(final StringBuilder sb,
+ final List<MALExpressionModel.MethodCall> chain) {
+ for (final MALExpressionModel.MethodCall mc : chain) {
+ sb.append(" ").append(RUN_VAR).append(" = ")
+ .append(RUN_VAR).append('.').append(mc.getName()).append('(');
+ final List<MALExpressionModel.Argument> args = mc.getArguments();
+ if (VARARGS_STRING_METHODS.contains(mc.getName()) && !args.isEmpty()
+ && allStringArgs(args)) {
+ sb.append("new String[]{");
+ for (int i = 0; i < args.size(); i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ generateArgument(sb, args.get(i));
+ }
+ sb.append('}');
+ } else {
+ final boolean primitiveDouble =
+ PRIMITIVE_DOUBLE_METHODS.contains(mc.getName());
+ for (int i = 0; i < args.size(); i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ generateMethodCallArg(sb, args.get(i), primitiveDouble);
+ }
+ }
+ sb.append(");\n");
+ }
+ }
+
private void generateExpr(final StringBuilder sb,
final MALExpressionModel.Expr expr) {
if (expr instanceof MALExpressionModel.MetricExpr) {
@@ -745,7 +1061,7 @@ public final class MALClassGenerator {
private void generateClosureArgument(final StringBuilder sb,
final MALExpressionModel.ClosureArgument closure) {
// Reference pre-compiled closure field
- sb.append("this._closure").append(closureCounter++);
+ sb.append("this.").append(closureFieldNames.get(closureFieldIndex++));
}
private void generateClosureStatement(final StringBuilder sb,
@@ -1538,8 +1854,21 @@ public final class MALClassGenerator {
* Generates the Java source body of the run method for debugging/testing.
*/
public String generateSource(final String expression) {
- closureCounter = 0;
final MALExpressionModel.Expr ast = MALScriptParser.parse(expression);
+ final List<ClosureInfo> closures = new ArrayList<>();
+ collectClosures(ast, closures);
+ // Build field names for source generation
+ final List<String> fieldNames = new ArrayList<>();
+ final java.util.Map<String, Integer> nameCounts = new java.util.HashMap<>();
+ for (final ClosureInfo ci : closures) {
+ final String purpose = ci.methodName;
+ final int count = nameCounts.getOrDefault(purpose, 0);
+ nameCounts.put(purpose, count + 1);
+ final String suffix = count == 0 ? purpose : purpose + "_" + (count + 1);
+ fieldNames.add("_" + suffix);
+ }
+ this.closureFieldNames = fieldNames;
+ this.closureFieldIndex = 0;
return generateRunMethod(ast);
}
diff --git a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALScriptParser.java b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALScriptParser.java
index d154e1f031..c541aaf636 100644
--- a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALScriptParser.java
+++ b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALScriptParser.java
@@ -101,7 +101,9 @@ public final class MALScriptParser {
final StringBuffer sb = new StringBuffer();
m.reset();
while (m.find()) {
- final String body = m.group(1);
+ // Escape backslashes: regex literal \| must become string literal \\|
+ // because the MAL lexer only recognizes \\, \", \' etc. as escape sequences
+ final String body = m.group(1).replace("\\", "\\\\");
// Preserve leading whitespace from the match
final String leading = m.group().substring(0, m.group().indexOf('/'));
m.appendReplacement(sb,
diff --git a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/dsl/Expression.java b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/dsl/Expression.java
index d3c0ab3f52..85e1c6a3f6 100644
--- a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/dsl/Expression.java
+++ b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/dsl/Expression.java
@@ -27,7 +27,7 @@ import lombok.extern.slf4j.Slf4j;
* <p>Two-phase usage:
* <ul>
* <li>{@link #parse()} — returns compile-time {@link ExpressionMetadata} extracted from the AST.
- * Called once at startup by {@link org.apache.skywalking.oap.meter.analyzer.Analyzer#build}
+ * Called once at startup by {@link org.apache.skywalking.oap.meter.analyzer.v2.Analyzer#build}
* to discover sample names, scope type, aggregation labels, and metric type.</li>
* <li>{@link #run(Map)} — executes the compiled expression on actual sample data.
* Called at every ingestion cycle. Pure computation, no side effects.</li>
diff --git a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/dsl/Result.java b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/dsl/Result.java
index 005f2d4815..1154499ebb 100644
--- a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/dsl/Result.java
+++ b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/dsl/Result.java
@@ -40,7 +40,7 @@ public class Result {
* @return failed result.
*/
public static Result fail(final Throwable throwable) {
- return new Result(false, true, throwable.getMessage(), SampleFamily.EMPTY);
+ return new Result(false, throwable.getMessage(), SampleFamily.EMPTY);
}
/**
@@ -50,7 +50,7 @@ public class Result {
* @return failed result.
*/
public static Result fail(String message) {
- return new Result(false, false, message, SampleFamily.EMPTY);
+ return new Result(false, message, SampleFamily.EMPTY);
}
/**
@@ -59,7 +59,7 @@ public class Result {
* @return failed result.
*/
public static Result fail() {
- return new Result(false, false, null, SampleFamily.EMPTY);
+ return new Result(false, null, SampleFamily.EMPTY);
}
/**
@@ -69,13 +69,11 @@ public class Result {
* @return successful result.
*/
public static Result success(SampleFamily sf) {
- return new Result(true, false, null, sf);
+ return new Result(true, null, sf);
}
private final boolean success;
- private final boolean isThrowable;
-
private final String error;
private final SampleFamily data;
diff --git a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/prometheus/rule/Rule.java b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/prometheus/rule/Rule.java
index 977aa6d011..ffea0db59a 100644
--- a/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/prometheus/rule/Rule.java
+++ b/oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/prometheus/rule/Rule.java
@@ -35,6 +35,5 @@ public class Rule implements MetricRuleConfig {
private String expSuffix;
private String expPrefix;
private String filter;
- private String initExp;
private List<MetricsRule> metricsRules;
}
diff --git a/oap-server/analyzer/meter-analyzer/src/test/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALClassGeneratorTest.java b/oap-server/analyzer/meter-analyzer/src/test/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALClassGeneratorTest.java
index 66835f2f53..a850977a01 100644
--- a/oap-server/analyzer/meter-analyzer/src/test/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALClassGeneratorTest.java
+++ b/oap-server/analyzer/meter-analyzer/src/test/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALClassGeneratorTest.java
@@ -197,7 +197,7 @@ class MALClassGeneratorTest {
assertNotNull(expr);
final String source = generator.generateSource(
"metric.tag({tags -> tags.cluster = 'activemq::' + tags.cluster})");
- assertTrue(source.contains("this._closure0"),
+ assertTrue(source.contains("this._tag"),
"Generated source should reference pre-compiled closure");
}
@@ -399,4 +399,55 @@ class MALClassGeneratorTest {
assertTrue(expr.metadata().getSamples().contains("metric"));
assertTrue(expr.metadata().getSamples().size() == 1);
}
+
+ @Test
+ void runMethodHasLocalVariableTable() throws Exception {
+ // Compile a class that writes its .class file for inspection
+ final java.io.File tmpDir = java.nio.file.Files.createTempDirectory("mal-lvt").toFile();
+ try {
+ final ClassPool pool = new ClassPool(true);
+ final MALClassGenerator gen = new MALClassGenerator(pool);
+ gen.setClassOutputDir(tmpDir);
+ final MalExpression expr = gen.compile(
+ "test_lvt", "instance_jvm_cpu.sum(['service', 'instance'])");
+ assertNotNull(expr);
+ // Read the .class file bytecode and verify LVT
+ final java.io.File[] classFiles = tmpDir.listFiles((d, n) -> n.endsWith(".class"));
+ assertNotNull(classFiles);
+ assertTrue(classFiles.length > 0, "Should have generated .class file");
+ // Use javassist to read back and check for LocalVariableTable
+ final javassist.bytecode.ClassFile cf =
+ new javassist.bytecode.ClassFile(
+ new java.io.DataInputStream(
+ new java.io.FileInputStream(classFiles[0])));
+ final javassist.bytecode.MethodInfo runMi = cf.getMethod("run");
+ assertNotNull(runMi, "Should have run() method");
+ final javassist.bytecode.CodeAttribute code = runMi.getCodeAttribute();
+ assertNotNull(code, "run() should have CodeAttribute");
+ final javassist.bytecode.LocalVariableAttribute lva =
+ (javassist.bytecode.LocalVariableAttribute)
+ code.getAttribute(javassist.bytecode.LocalVariableAttribute.tag);
+ assertNotNull(lva, "run() should have LocalVariableTable attribute");
+ // Check that slot 1 has name "samples"
+ boolean foundSamples = false;
+ boolean foundSf = false;
+ for (int i = 0; i < lva.tableLength(); i++) {
+ final String name = lva.variableName(i);
+ if ("samples".equals(name)) {
+ foundSamples = true;
+ }
+ if ("sf".equals(name)) {
+ foundSf = true;
+ }
+ }
+ assertTrue(foundSamples, "LVT should contain 'samples'");
+ assertTrue(foundSf, "LVT should contain 'sf'");
+ } finally {
+ for (final java.io.File f : tmpDir.listFiles()) {
+ f.delete();
+ }
+ tmpDir.delete();
+ }
+ }
+
}
diff --git a/oap-server/server-receiver-plugin/skywalking-zabbix-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zabbix/provider/config/ZabbixConfig.java b/oap-server/server-receiver-plugin/skywalking-zabbix-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zabbix/provider/config/ZabbixConfig.java
index 382c965596..6081212f88 100644
--- a/oap-server/server-receiver-plugin/skywalking-zabbix-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zabbix/provider/config/ZabbixConfig.java
+++ b/oap-server/server-receiver-plugin/skywalking-zabbix-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zabbix/provider/config/ZabbixConfig.java
@@ -30,7 +30,6 @@ public class ZabbixConfig implements MetricRuleConfig {
private String expSuffix;
private String expPrefix;
private String filter;
- private String initExp;
private Entities entities;
private List<String> requiredZabbixItemKeys;
private List<Metric> metrics;
diff --git a/test/script-cases/script-runtime-with-groovy/hierarchy-v1-v2-checker/pom.xml b/test/script-cases/script-runtime-with-groovy/hierarchy-v1-v2-checker/pom.xml
index 8ecbf8d55e..9bb7fcfe33 100644
--- a/test/script-cases/script-runtime-with-groovy/hierarchy-v1-v2-checker/pom.xml
+++ b/test/script-cases/script-runtime-with-groovy/hierarchy-v1-v2-checker/pom.xml
@@ -50,4 +50,22 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${project.basedir}/../../scripts</directory>
+ <includes>
+ <include>**/*.generated-classes/**</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/test/script-cases/script-runtime-with-groovy/hierarchy-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/core/config/HierarchyRuleComparisonTest.java b/test/script-cases/script-runtime-with-groovy/hierarchy-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/core/config/HierarchyRuleComparisonTest.java
index b410b66b28..1f6a7a3e3a 100644
--- a/test/script-cases/script-runtime-with-groovy/hierarchy-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/core/config/HierarchyRuleComparisonTest.java
+++ b/test/script-cases/script-runtime-with-groovy/hierarchy-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/core/config/HierarchyRuleComparisonTest.java
@@ -17,6 +17,7 @@
package org.apache.skywalking.oap.server.core.config;
+import java.io.File;
import java.io.FileReader;
import java.io.Reader;
import java.nio.file.Files;
@@ -29,7 +30,7 @@ import java.util.function.BiFunction;
import org.apache.skywalking.oap.server.core.query.type.Service;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;
-import org.apache.skywalking.oap.server.core.config.v2.compiler.CompiledHierarchyRuleProvider;
+import org.apache.skywalking.oap.server.core.config.v2.compiler.HierarchyRuleClassGenerator;
import org.yaml.snakeyaml.Yaml;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -38,6 +39,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* Dual-path comparison test for hierarchy matching rules.
* Verifies that Groovy-based rules (v1) produce identical results
* to pure Java rules (v2) for all service pair combinations.
+ *
+ * <p>Test pairs are loaded from a companion {@code .data.yaml} file
+ * alongside the hierarchy definition YAML.
*/
class HierarchyRuleComparisonTest {
@@ -48,36 +52,53 @@ class HierarchyRuleComparisonTest {
return s;
}
- /**
- * Test case: upper service, lower service, and a human-readable description.
- */
private static class TestPair {
final String description;
final Service upper;
final Service lower;
+ final Boolean expected;
- TestPair(final String description, final Service upper, final Service lower) {
+ TestPair(final String description, final Service upper,
+ final Service lower, final Boolean expected) {
this.description = description;
this.upper = upper;
this.lower = lower;
+ this.expected = expected;
}
}
@SuppressWarnings("unchecked")
@TestFactory
Collection<DynamicTest> allRulesProduceIdenticalResults() throws Exception {
- final Reader reader = new FileReader(findHierarchyDefinition().toFile());
+ final Path hierarchyYml = findHierarchyDefinition();
+ final Reader reader = new FileReader(hierarchyYml.toFile());
final Yaml yaml = new Yaml();
final Map<String, Map> config = yaml.loadAs(reader, Map.class);
- final Map<String, String> ruleExpressions = (Map<String, String>) config.get("auto-matching-rules");
+ final Map<String, String> ruleExpressions =
+ (Map<String, String>) config.get("auto-matching-rules");
+
+ // Load companion .data.yaml
+ final Map<String, List<TestPair>> testPairsByRule = loadInputData(hierarchyYml);
final GroovyHierarchyRuleProvider groovyProvider = new GroovyHierarchyRuleProvider();
- final CompiledHierarchyRuleProvider javaProvider = new CompiledHierarchyRuleProvider();
final Map<String, BiFunction<Service, Service, Boolean>> v1Rules =
groovyProvider.buildRules(ruleExpressions);
- final Map<String, BiFunction<Service, Service, Boolean>> v2Rules =
- javaProvider.buildRules(ruleExpressions);
+
+ // Build v2 rules with class output
+ final String baseName = hierarchyYml.getFileName().toString()
+ .replaceFirst("\\.(yaml|yml)$", "");
+ final File classBaseDir = new File(hierarchyYml.getParent().toFile(),
+ baseName + ".generated-classes");
+ final HierarchyRuleClassGenerator generator = new HierarchyRuleClassGenerator();
+ generator.setClassOutputDir(classBaseDir);
+ final java.util.Map<String, BiFunction<Service, Service, Boolean>> v2Rules =
+ new java.util.HashMap<>();
+ for (final Map.Entry<String, String> entry : ruleExpressions.entrySet()) {
+ final String ruleName = entry.getKey();
+ generator.setClassNameHint(ruleName);
+ v2Rules.put(ruleName, generator.compile(ruleName, entry.getValue()));
+ }
final List<DynamicTest> tests = new ArrayList<>();
for (final Map.Entry<String, String> entry : ruleExpressions.entrySet()) {
@@ -85,7 +106,11 @@ class HierarchyRuleComparisonTest {
final BiFunction<Service, Service, Boolean> v1 = v1Rules.get(ruleName);
final BiFunction<Service, Service, Boolean> v2 = v2Rules.get(ruleName);
- for (final TestPair pair : testPairsFor(ruleName)) {
+ final List<TestPair> pairs = testPairsByRule.get(ruleName);
+ if (pairs == null || pairs.isEmpty()) {
+ continue;
+ }
+ for (final TestPair pair : pairs) {
tests.add(DynamicTest.dynamicTest(
ruleName + " | " + pair.description,
() -> {
@@ -94,6 +119,12 @@ class HierarchyRuleComparisonTest {
assertEquals(v1Result, v2Result,
"Rule '" + ruleName + "' diverged for " + pair.description
+ ": v1=" + v1Result + ", v2=" + v2Result);
+ if (pair.expected != null) {
+ assertEquals(pair.expected, v1Result,
+ "Rule '" + ruleName + "' expected " + pair.expected
+ + " for " + pair.description
+ + " but v1=" + v1Result);
+ }
}
));
}
@@ -101,91 +132,46 @@ class HierarchyRuleComparisonTest {
return tests;
}
- private static List<TestPair> testPairsFor(final String ruleName) {
- final List<TestPair> pairs = new ArrayList<>();
- switch (ruleName) {
- case "name":
- pairs.add(new TestPair("exact match",
- svc("my-service", "my-service"),
- svc("my-service", "my-service")));
- pairs.add(new TestPair("mismatch",
- svc("svc-a", "svc-a"),
- svc("svc-b", "svc-b")));
- pairs.add(new TestPair("same shortName different name",
- svc("svc-a", "same"),
- svc("svc-b", "same")));
- pairs.add(new TestPair("empty names",
- svc("", ""),
- svc("", "")));
- break;
-
- case "short-name":
- pairs.add(new TestPair("exact shortName match",
- svc("full-a", "svc"),
- svc("full-b", "svc")));
- pairs.add(new TestPair("shortName mismatch",
- svc("a", "svc-1"),
- svc("b", "svc-2")));
- pairs.add(new TestPair("same name different shortName",
- svc("same", "short-a"),
- svc("same", "short-b")));
- pairs.add(new TestPair("empty shortNames",
- svc("a", ""),
- svc("b", "")));
- break;
-
- case "lower-short-name-remove-ns":
- pairs.add(new TestPair("match: svc == svc.namespace",
- svc("a", "svc"),
- svc("b", "svc.namespace")));
- pairs.add(new TestPair("match: app == app.default",
- svc("a", "app"),
- svc("b", "app.default")));
- pairs.add(new TestPair("no dot in lower",
- svc("a", "svc"),
- svc("b", "svc")));
- pairs.add(new TestPair("mismatch prefix",
- svc("a", "other"),
- svc("b", "svc.namespace")));
- pairs.add(new TestPair("dot at position 0",
- svc("a", ""),
- svc("b", ".namespace")));
- pairs.add(new TestPair("multiple dots - uses last",
- svc("a", "svc.ns1"),
- svc("b", "svc.ns1.ns2")));
- pairs.add(new TestPair("empty lower",
- svc("a", "svc"),
- svc("b", "")));
- break;
-
- case "lower-short-name-with-fqdn":
- pairs.add(new TestPair("match: db.svc.cluster.local:3306 vs db",
- svc("a", "db.svc.cluster.local:3306"),
- svc("b", "db")));
- pairs.add(new TestPair("match: redis.svc.cluster.local:6379 vs redis",
- svc("a", "redis.svc.cluster.local:6379"),
- svc("b", "redis")));
- pairs.add(new TestPair("no colon in upper",
- svc("a", "db"),
- svc("b", "db")));
- pairs.add(new TestPair("wrong fqdn suffix",
- svc("a", "db:3306"),
- svc("b", "other")));
- pairs.add(new TestPair("upper without fqdn",
- svc("a", "db:3306"),
- svc("b", "db")));
- pairs.add(new TestPair("empty upper",
- svc("a", ""),
- svc("b", "db")));
- pairs.add(new TestPair("colon at end",
- svc("a", "db.svc.cluster.local:"),
- svc("b", "db")));
- break;
-
- default:
- throw new IllegalArgumentException("Unknown rule: " + ruleName);
+ @SuppressWarnings("unchecked")
+ private Map<String, List<TestPair>> loadInputData(final Path hierarchyYml) throws Exception {
+ final String baseName = hierarchyYml.getFileName().toString()
+ .replaceFirst("\\.(yaml|yml)$", "");
+ final Path inputPath = hierarchyYml.getParent().resolve(baseName + ".data.yaml");
+
+ final Map<String, List<TestPair>> result = new java.util.HashMap<>();
+ if (!Files.isRegularFile(inputPath)) {
+ return result;
+ }
+
+ final Yaml yaml = new Yaml();
+ final String content = Files.readString(inputPath);
+ final Map<String, Object> inputConfig = yaml.load(content);
+ if (inputConfig == null || !inputConfig.containsKey("input")) {
+ return result;
+ }
+
+ final Map<String, List<Map<String, Object>>> input =
+ (Map<String, List<Map<String, Object>>>) inputConfig.get("input");
+ for (final Map.Entry<String, List<Map<String, Object>>> entry : input.entrySet()) {
+ final String ruleName = entry.getKey();
+ final List<TestPair> pairs = new ArrayList<>();
+ for (final Map<String, Object> pairDef : entry.getValue()) {
+ final String description = (String) pairDef.getOrDefault("description", "");
+ final Map<String, String> upperDef = (Map<String, String>) pairDef.get("upper");
+ final Map<String, String> lowerDef = (Map<String, String>) pairDef.get("lower");
+ final Boolean expected = pairDef.containsKey("expected")
+ ? (Boolean) pairDef.get("expected") : null;
+ final Service upper = svc(
+ upperDef.getOrDefault("name", ""),
+ upperDef.getOrDefault("shortName", ""));
+ final Service lower = svc(
+ lowerDef.getOrDefault("name", ""),
+ lowerDef.getOrDefault("shortName", ""));
+ pairs.add(new TestPair(description, upper, lower, expected));
+ }
+ result.put(ruleName, pairs);
}
- return pairs;
+ return result;
}
private Path findHierarchyDefinition() {
diff --git a/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/pom.xml b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/pom.xml
index 9233b0828a..b830126139 100644
--- a/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/pom.xml
+++ b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/pom.xml
@@ -69,4 +69,22 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${project.basedir}/../../scripts</directory>
+ <includes>
+ <include>**/*.generated-classes/**</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/lal/LalComparisonTest.java b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/lal/LalComparisonTest.java
index 3d87ea2807..a847cd3072 100644
--- a/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/lal/LalComparisonTest.java
+++ b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/lal/LalComparisonTest.java
@@ -75,7 +75,7 @@ class LalComparisonTest {
for (final LalRule rule : entry.getValue()) {
tests.add(DynamicTest.dynamicTest(
yamlFile + " | " + rule.name,
- () -> compareExecution(rule.name, rule.dsl)
+ () -> compareExecution(rule)
));
}
}
@@ -83,8 +83,9 @@ class LalComparisonTest {
return tests;
}
- private void compareExecution(final String ruleName,
- final String dsl) throws Exception {
+ private void compareExecution(final LalRule rule) throws Exception {
+ final String ruleName = rule.name;
+ final String dsl = rule.dsl;
final ModuleManager manager = buildMockModuleManager();
final LogData testLog = buildTestLogData(dsl);
@@ -112,6 +113,14 @@ class LalComparisonTest {
String v2Error = null;
try {
final LALClassGenerator generator = new LALClassGenerator();
+ if (rule.sourceFile != null) {
+ final String baseName = rule.sourceFile.getName()
+ .replaceFirst("\\.(yaml|yml)$", "");
+ generator.setClassOutputDir(new java.io.File(
+ rule.sourceFile.getParent(),
+ baseName + ".generated-classes"));
+ generator.setClassNameHint(baseName + "_" + ruleName);
+ }
final org.apache.skywalking.oap.log.analyzer.v2.dsl.LalExpression v2Expr =
generator.compile(dsl);
@@ -309,7 +318,7 @@ class LalComparisonTest {
if (name == null || dslStr == null) {
continue;
}
- lalRules.add(new LalRule(name, dslStr));
+ lalRules.add(new LalRule(name, dslStr, file));
}
if (!lalRules.isEmpty()) {
final String relative = lalDir.relativize(file.toPath()).toString();
@@ -352,10 +361,12 @@ class LalComparisonTest {
private static class LalRule {
final String name;
final String dsl;
+ final File sourceFile;
- LalRule(final String name, final String dsl) {
+ LalRule(final String name, final String dsl, final File sourceFile) {
this.name = name;
this.dsl = dsl;
+ this.sourceFile = sourceFile;
}
}
}
diff --git a/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalComparisonTest.java b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalComparisonTest.java
index b1885c008c..6a1a60e931 100644
--- a/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalComparisonTest.java
+++ b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalComparisonTest.java
@@ -46,6 +46,10 @@ import static org.junit.jupiter.api.Assertions.fail;
* <li>Path B (v2): ANTLR4 + Javassist via {@link MALClassGenerator}</li>
* </ul>
*
+ * <p>When a companion {@code .data.yaml} file exists alongside a MAL YAML script,
+ * it provides realistic mock data (sample names, labels, values) for runtime
+ * execution comparison and expected output validation.
+ *
* <p>v1 classes use original package {@code org.apache.skywalking.oap.meter.analyzer.dsl.*},
* v2 classes use {@code org.apache.skywalking.oap.meter.analyzer.v2.dsl.*}.
* Both are called via hard-coded typed references (no reflection).
@@ -71,7 +75,7 @@ class MalComparisonTest {
for (final MalRule rule : entry.getValue()) {
tests.add(DynamicTest.dynamicTest(
yamlFile + " | " + rule.name,
- () -> compareExpression(rule.name, rule.fullExpression)
+ () -> compareExpression(rule)
));
}
}
@@ -79,8 +83,11 @@ class MalComparisonTest {
return tests;
}
- private void compareExpression(final String metricName,
- final String expression) throws Exception {
+ @SuppressWarnings("unchecked")
+ private void compareExpression(final MalRule rule) throws Exception {
+ final String metricName = rule.name;
+ final String expression = rule.fullExpression;
+
// ---- V1: Groovy path (original packages) ----
org.apache.skywalking.oap.meter.analyzer.dsl.Expression v1Expr = null;
org.apache.skywalking.oap.meter.analyzer.dsl.ExpressionParsingContext v1Ctx = null;
@@ -98,6 +105,14 @@ class MalComparisonTest {
String v2Error = null;
try {
final MALClassGenerator generator = new MALClassGenerator();
+ if (rule.sourceFile != null) {
+ final String baseName = rule.sourceFile.getName()
+ .replaceFirst("\\.(yaml|yml)$", "");
+ generator.setClassOutputDir(new java.io.File(
+ rule.sourceFile.getParent(),
+ baseName + ".generated-classes"));
+ generator.setClassNameHint(metricName);
+ }
v2MalExpr = generator.compile(metricName, expression);
v2Meta = v2MalExpr.metadata();
} catch (Exception e) {
@@ -132,9 +147,221 @@ class MalComparisonTest {
metricName + ": aggregationLabels mismatch");
// ---- Runtime execution comparison ----
+ if (rule.inputConfig != null) {
+ final Map<String, Object> inputSection =
+ (Map<String, Object>) rule.inputConfig.get("input");
+ final Map<String, Object> expectedSection =
+ (Map<String, Object>) rule.inputConfig.get("expected");
+ if (inputSection != null) {
+ compareExecutionWithInput(
+ rule, v1Expr, v2MalExpr, v2Meta, inputSection, expectedSection);
+ return;
+ }
+ }
compareExecution(metricName, expression, v1Expr, v2MalExpr, v2Meta);
}
+ // ==================== Input-driven runtime comparison ====================
+
+ @SuppressWarnings("unchecked")
+ private void compareExecutionWithInput(
+ final MalRule rule,
+ final org.apache.skywalking.oap.meter.analyzer.dsl.Expression v1Expr,
+ final org.apache.skywalking.oap.meter.analyzer.v2.dsl.MalExpression v2MalExpr,
+ final ExpressionMetadata v2Meta,
+ final Map<String, Object> inputSection,
+ final Map<String, Object> expectedSection) {
+ final String metricName = rule.name;
+ final String expression = rule.fullExpression;
+ final boolean hasIncrease = expression.contains(".increase(")
+ || expression.contains(".rate(");
+
+ // For increase()/rate(), prime the CounterWindow with initial data
+ if (hasIncrease) {
+ try {
+ v1Expr.run(buildV1MockDataFromInput(inputSection));
+ } catch (Exception ignored) {
+ }
+ try {
+ final Map<String, org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily> primeData =
+ buildV2MockDataFromInput(inputSection);
+ for (final org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily s : primeData.values()) {
+ if (s != org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily.EMPTY) {
+ s.context.setMetricName(metricName);
+ }
+ }
+ v2MalExpr.run(primeData);
+ } catch (Exception ignored) {
+ }
+ }
+
+ // Build mock data from input YAML
+ final Map<String, org.apache.skywalking.oap.meter.analyzer.dsl.SampleFamily> v1Data =
+ buildV1MockDataFromInput(inputSection);
+ final Map<String, org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily> v2Data =
+ buildV2MockDataFromInput(inputSection);
+
+ // V1 run
+ org.apache.skywalking.oap.meter.analyzer.dsl.Result v1Result;
+ try {
+ v1Result = v1Expr.run(v1Data);
+ } catch (Exception e) {
+ log.warn("{}: v1 runtime failed with input data — {}", metricName, e.getMessage());
+ return;
+ }
+
+ // V2 run
+ org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily v2Sf;
+ try {
+ for (final org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily s : v2Data.values()) {
+ if (s != org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily.EMPTY) {
+ s.context.setMetricName(metricName);
+ }
+ }
+ v2Sf = v2MalExpr.run(v2Data);
+ } catch (Exception e) {
+ if (v1Result.isSuccess()) {
+ fail(metricName + ": v2 runtime failed but v1 succeeded (with input data) — "
+ + e.getClass().getSimpleName() + ": " + e.getMessage());
+ }
+ return;
+ }
+
+ // Compare results
+ final boolean v2Success = v2Sf != null
+ && v2Sf != org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily.EMPTY;
+ assertEquals(v1Result.isSuccess(), v2Success,
+ metricName + ": success mismatch (v1=" + v1Result.isSuccess()
+ + ", v2=" + v2Success + ")");
+
+ if (v1Result.isSuccess() && v2Success) {
+ compareSampleFamilies(metricName, v1Result.getData(), v2Sf);
+ }
+
+ // Validate expected section
+ if (expectedSection != null) {
+ final String qualifiedMetricName = rule.metricPrefix != null
+ ? rule.metricPrefix + "_" + metricName : metricName;
+ final Map<String, Object> metricExpected =
+ (Map<String, Object>) expectedSection.get(qualifiedMetricName);
+ if (metricExpected == null) {
+ // Try without prefix
+ final Map<String, Object> directExpected =
+ (Map<String, Object>) expectedSection.get(metricName);
+ if (directExpected != null) {
+ validateExpected(metricName, v2Sf, v2Success, directExpected);
+ }
+ } else {
+ validateExpected(qualifiedMetricName, v2Sf, v2Success, metricExpected);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void validateExpected(final String metricName,
+ final org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily v2Sf,
+ final boolean v2Success,
+ final Map<String, Object> expected) {
+ if (expected.containsKey("min_samples")) {
+ final int minSamples = ((Number) expected.get("min_samples")).intValue();
+ if (minSamples > 0) {
+ if (!v2Success) {
+ log.warn("{}: expected min_samples={} but v2 returned EMPTY"
+ + " (input data may need enrichment)", metricName, minSamples);
+ } else if (v2Sf.samples.length < minSamples) {
+ log.warn("{}: expected min_samples={} but got {}",
+ metricName, minSamples, v2Sf.samples.length);
+ }
+ }
+ }
+ }
+
+ // ==================== Build mock data from .data.yaml ====================
+
+ @SuppressWarnings("unchecked")
+ private Map<String, org.apache.skywalking.oap.meter.analyzer.dsl.SampleFamily> buildV1MockDataFromInput(
+ final Map<String, Object> inputSection) {
+ final Map<String, org.apache.skywalking.oap.meter.analyzer.dsl.SampleFamily> data =
+ new HashMap<>();
+ final long now = timestampCounter++;
+
+ for (final Map.Entry<String, Object> entry : inputSection.entrySet()) {
+ final String sampleName = entry.getKey();
+ final List<Map<String, Object>> sampleList =
+ (List<Map<String, Object>>) entry.getValue();
+ final List<org.apache.skywalking.oap.meter.analyzer.dsl.Sample> samples =
+ new ArrayList<>();
+
+ for (final Map<String, Object> sampleDef : sampleList) {
+ final Map<String, String> labels = new HashMap<>();
+ final Object rawLabels = sampleDef.get("labels");
+ if (rawLabels instanceof Map) {
+ for (final Map.Entry<String, Object> le :
+ ((Map<String, Object>) rawLabels).entrySet()) {
+ labels.put(le.getKey(), String.valueOf(le.getValue()));
+ }
+ }
+ final double value = ((Number) sampleDef.get("value")).doubleValue();
+ samples.add(org.apache.skywalking.oap.meter.analyzer.dsl.Sample.builder()
+ .name(sampleName)
+ .labels(ImmutableMap.copyOf(labels))
+ .value(value)
+ .timestamp(now)
+ .build());
+ }
+
+ data.put(sampleName,
+ org.apache.skywalking.oap.meter.analyzer.dsl.SampleFamilyBuilder
+ .newBuilder(samples.toArray(
+ new org.apache.skywalking.oap.meter.analyzer.dsl.Sample[0]))
+ .build());
+ }
+ return data;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Map<String, org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily> buildV2MockDataFromInput(
+ final Map<String, Object> inputSection) {
+ final Map<String, org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamily> data =
+ new HashMap<>();
+ final long now = timestampCounter++;
+
+ for (final Map.Entry<String, Object> entry : inputSection.entrySet()) {
+ final String sampleName = entry.getKey();
+ final List<Map<String, Object>> sampleList =
+ (List<Map<String, Object>>) entry.getValue();
+ final List<org.apache.skywalking.oap.meter.analyzer.v2.dsl.Sample> samples =
+ new ArrayList<>();
+
+ for (final Map<String, Object> sampleDef : sampleList) {
+ final Map<String, String> labels = new HashMap<>();
+ final Object rawLabels = sampleDef.get("labels");
+ if (rawLabels instanceof Map) {
+ for (final Map.Entry<String, Object> le :
+ ((Map<String, Object>) rawLabels).entrySet()) {
+ labels.put(le.getKey(), String.valueOf(le.getValue()));
+ }
+ }
+ final double value = ((Number) sampleDef.get("value")).doubleValue();
+ samples.add(org.apache.skywalking.oap.meter.analyzer.v2.dsl.Sample.builder()
+ .name(sampleName)
+ .labels(ImmutableMap.copyOf(labels))
+ .value(value)
+ .timestamp(now)
+ .build());
+ }
+
+ data.put(sampleName,
+ org.apache.skywalking.oap.meter.analyzer.v2.dsl.SampleFamilyBuilder
+ .newBuilder(samples.toArray(
+ new org.apache.skywalking.oap.meter.analyzer.v2.dsl.Sample[0]))
+ .build());
+ }
+ return data;
+ }
+
+ // ==================== Auto-generated mock data (fallback) ====================
+
private void compareExecution(
final String metricName,
final String expression,
@@ -417,7 +644,9 @@ class MalComparisonTest {
final String[] dirs = {
"test-meter-analyzer-config",
- "test-otel-rules"
+ "test-otel-rules",
+ "test-envoy-metrics-rules",
+ "test-log-mal-rules"
};
final Path scriptsDir = findScriptsDir("mal");
@@ -449,6 +678,10 @@ class MalComparisonTest {
if (!file.getName().endsWith(".yaml") && !file.getName().endsWith(".yml")) {
continue;
}
+ // Skip companion .data.yaml files
+ if (file.getName().endsWith(".data.yaml")) {
+ continue;
+ }
final String content = Files.readString(file.toPath());
final Map<String, Object> config = yaml.load(content);
if (config == null || !config.containsKey("metricsRules")) {
@@ -458,12 +691,24 @@ class MalComparisonTest {
final String expSuffix = rawSuffix instanceof String ? (String) rawSuffix : "";
final Object rawPrefix = config.get("expPrefix");
final String expPrefix = rawPrefix instanceof String ? (String) rawPrefix : "";
+ final Object rawMetricPrefix = config.get("metricPrefix");
+ final String metricPrefix = rawMetricPrefix instanceof String
+ ? (String) rawMetricPrefix : null;
final List<Map<String, String>> rules =
(List<Map<String, String>>) config.get("metricsRules");
if (rules == null) {
continue;
}
+ // Load companion .data.yaml if it exists
+ final String baseName = file.getName().replaceFirst("\\.(yaml|yml)$", "");
+ final File inputFile = new File(file.getParent(), baseName + ".data.yaml");
+ Map<String, Object> inputConfig = null;
+ if (inputFile.exists()) {
+ final String inputContent = Files.readString(inputFile.toPath());
+ inputConfig = yaml.load(inputContent);
+ }
+
final String yamlName = prefix + "/" + file.getName();
final List<MalRule> malRules = new ArrayList<>();
for (final Map<String, String> rule : rules) {
@@ -479,7 +724,7 @@ class MalComparisonTest {
if (!expSuffix.isEmpty()) {
fullExp = fullExp + "." + expSuffix;
}
- malRules.add(new MalRule(name, fullExp));
+ malRules.add(new MalRule(name, fullExp, inputConfig, metricPrefix, file));
}
if (!malRules.isEmpty()) {
result.put(yamlName, malRules);
@@ -504,10 +749,18 @@ class MalComparisonTest {
private static class MalRule {
final String name;
final String fullExpression;
+ final Map<String, Object> inputConfig;
+ final String metricPrefix;
+ final File sourceFile;
- MalRule(final String name, final String fullExpression) {
+ MalRule(final String name, final String fullExpression,
+ final Map<String, Object> inputConfig, final String metricPrefix,
+ final File sourceFile) {
this.name = name;
this.fullExpression = fullExpression;
+ this.inputConfig = inputConfig;
+ this.metricPrefix = metricPrefix;
+ this.sourceFile = sourceFile;
}
}
}
diff --git a/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalInputDataGenerator.java b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalInputDataGenerator.java
new file mode 100644
index 0000000000..7265d1fb8f
--- /dev/null
+++ b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalInputDataGenerator.java
@@ -0,0 +1,679 @@
+/*
+ * 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.checker.mal;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.skywalking.oap.meter.analyzer.v2.compiler.MALClassGenerator;
+import org.apache.skywalking.oap.meter.analyzer.v2.dsl.ExpressionMetadata;
+import org.apache.skywalking.oap.meter.analyzer.v2.dsl.MalExpression;
+import lombok.extern.slf4j.Slf4j;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Generates companion {@code .data.yaml} files for all MAL test YAML scripts.
+ * Each generated file contains realistic mock input data (sample names, labels, values)
+ * derived from compiling the MAL expression and parsing filter/tag constraints.
+ *
+ * <p>Run via: {@code main()} or as a JUnit test via {@link MalInputDataGeneratorTest}.
+ */
+@Slf4j
+public final class MalInputDataGenerator {
+
+ private static final String LICENSE_HEADER =
+ "# Licensed to the Apache Software Foundation (ASF) under one or more\n"
+ + "# contributor license agreements. See the NOTICE file distributed with\n"
+ + "# this work for additional information regarding copyright ownership.\n"
+ + "# The ASF licenses this file to You under the Apache License, Version 2.0\n"
+ + "# (the \"License\"); you may not use this file except in compliance with\n"
+ + "# the License. You may obtain a copy of the License at\n"
+ + "#\n"
+ + "# http://www.apache.org/licenses/LICENSE-2.0\n"
+ + "#\n"
+ + "# Unless required by applicable law or agreed to in writing, software\n"
+ + "# distributed under the License is distributed on an \"AS IS\" BASIS,\n"
+ + "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
+ + "# See the License for the specific language governing permissions and\n"
+ + "# limitations under the License.\n\n";
+
+ private static final String[] HISTOGRAM_LE_VALUES =
+ {"50", "100", "250", "500", "1000"};
+
+ // Patterns for extracting constraints from MAL expressions
+ private static final Pattern TAG_EQUAL_PATTERN =
+ Pattern.compile("\\.tagEqual\\s*\\(\\s*'([^']+)'\\s*,\\s*'([^']+)'\\s*\\)");
+ private static final Pattern TAG_NOT_EQUAL_NULL_PATTERN =
+ Pattern.compile("\\.tagNotEqual\\s*\\(\\s*'([^']+)'\\s*,\\s*null\\s*\\)");
+ private static final Pattern TAG_NOT_EQUAL_PATTERN =
+ Pattern.compile("\\.tagNotEqual\\s*\\(\\s*'([^']+)'\\s*,\\s*'([^']+)'\\s*\\)");
+ private static final Pattern TAG_MATCH_PATTERN =
+ Pattern.compile("\\.tagMatch\\s*\\(\\s*'([^']+)'\\s*,\\s*'([^']+)'\\s*\\)");
+ private static final Pattern TAG_NOT_MATCH_PATTERN =
+ Pattern.compile("\\.tagNotMatch\\s*\\(\\s*'([^']+)'\\s*,\\s*'([^']+)'\\s*\\)");
+ private static final Pattern CLOSURE_TAG_ACCESS_PATTERN =
+ Pattern.compile("tags\\.([a-zA-Z_][a-zA-Z0-9_]*)");
+ private static final Pattern CLOSURE_TAG_BRACKET_PATTERN =
+ Pattern.compile("tags\\['([^']+)'\\]");
+ private static final Pattern VALUE_EQUAL_PATTERN =
+ Pattern.compile("\\.valueEqual\\s*\\(\\s*([0-9.]+)\\s*\\)");
+
+ private static final String[] DIRS = {
+ "test-meter-analyzer-config",
+ "test-otel-rules",
+ "test-envoy-metrics-rules",
+ "test-log-mal-rules"
+ };
+
+ private final MALClassGenerator generator = new MALClassGenerator();
+
+ public static void main(final String[] args) throws Exception {
+ final MalInputDataGenerator gen = new MalInputDataGenerator();
+ final Path scriptsDir = gen.findScriptsDir();
+ if (scriptsDir == null) {
+ log.warn("Cannot find scripts/mal directory");
+ return;
+ }
+ int generated = 0;
+ int skipped = 0;
+ for (final String dir : DIRS) {
+ final Path dirPath = scriptsDir.resolve(dir);
+ if (Files.isDirectory(dirPath)) {
+ final int[] counts = gen.processDirectory(dirPath);
+ generated += counts[0];
+ skipped += counts[1];
+ }
+ }
+ log.info("Generated: {}, Skipped (already exists): {}", generated, skipped);
+ }
+
+ /**
+ * Process a directory (recursively) and generate .data.yaml for each MAL YAML.
+ *
+ * @return int[2]: [generated, skipped]
+ */
+ int[] processDirectory(final Path dir) throws Exception {
+ int generated = 0;
+ int skipped = 0;
+ final File[] files = dir.toFile().listFiles();
+ if (files == null) {
+ return new int[]{0, 0};
+ }
+ for (final File file : files) {
+ if (file.isDirectory()) {
+ final int[] sub = processDirectory(file.toPath());
+ generated += sub[0];
+ skipped += sub[1];
+ continue;
+ }
+ if (!file.getName().endsWith(".yaml") && !file.getName().endsWith(".yml")) {
+ continue;
+ }
+ if (file.getName().endsWith(".data.yaml") || file.getName().endsWith(".data.yml")) {
+ continue;
+ }
+ final String baseName = file.getName().replaceAll("\\.(yaml|yml)$", "");
+ final File inputFile = new File(file.getParentFile(), baseName + ".data.yaml");
+ if (inputFile.exists()) {
+ skipped++;
+ continue;
+ }
+ try {
+ final String content = generateInputYaml(file);
+ if (content != null) {
+ Files.writeString(inputFile.toPath(), content);
+ log.info(" Generated: {}", inputFile.getPath());
+ generated++;
+ }
+ } catch (Exception e) {
+ log.warn(" Error processing {}: {}", file.getName(), e.getMessage());
+ }
+ }
+ return new int[]{generated, skipped};
+ }
+
+ @SuppressWarnings("unchecked")
+ String generateInputYaml(final File yamlFile) throws IOException {
+ final Yaml yaml = new Yaml();
+ final String content = Files.readString(yamlFile.toPath());
+ final Map<String, Object> config = yaml.load(content);
+ if (config == null || !config.containsKey("metricsRules")) {
+ return null;
+ }
+
+ final Object rawPrefix = config.get("expPrefix");
+ final String expPrefix = rawPrefix instanceof String ? (String) rawPrefix : "";
+ final Object rawSuffix = config.get("expSuffix");
+ final String expSuffix = rawSuffix instanceof String ? (String) rawSuffix : "";
+
+ final List<Map<String, String>> rules =
+ (List<Map<String, String>>) config.get("metricsRules");
+ if (rules == null || rules.isEmpty()) {
+ return null;
+ }
+
+ // Collect all sample names and labels across all rules in this file
+ final Map<String, Set<String>> sampleLabels = new LinkedHashMap<>();
+ final Map<String, Map<String, String>> tagEqualConstraints = new LinkedHashMap<>();
+ final Map<String, String> tagMatchConstraints = new LinkedHashMap<>();
+ final Set<String> closureAccessedLabels = new LinkedHashSet<>();
+ final List<String> metricNames = new ArrayList<>();
+ boolean anyHistogram = false;
+ double valueForEqual = 100.0;
+
+ for (final Map<String, String> rule : rules) {
+ final String name = rule.get("name");
+ final String exp = rule.get("exp");
+ if (name == null || exp == null) {
+ continue;
+ }
+ String fullExp = exp;
+ if (!expPrefix.isEmpty()) {
+ fullExp = expPrefix + "." + fullExp;
+ }
+ if (!expSuffix.isEmpty()) {
+ fullExp = fullExp + "." + expSuffix;
+ }
+ metricNames.add(name);
+
+ try {
+ final MalExpression compiled = generator.compile(name, fullExp);
+ final ExpressionMetadata meta = compiled.metadata();
+
+ for (final String sample : meta.getSamples()) {
+ final Set<String> labels = sampleLabels.computeIfAbsent(
+ sample, k -> new LinkedHashSet<>());
+ labels.addAll(meta.getAggregationLabels());
+ labels.addAll(meta.getScopeLabels());
+ }
+ if (meta.isHistogram()) {
+ anyHistogram = true;
+ }
+ } catch (Exception e) {
+ // Compilation failed — extract sample names from expression text
+ extractSampleNamesFromText(fullExp, sampleLabels);
+ }
+
+ // Extract constraints from expression text
+ extractTagEqualConstraints(fullExp, tagEqualConstraints);
+ extractTagMatchConstraints(fullExp, tagMatchConstraints);
+ extractClosureAccessedLabels(fullExp, closureAccessedLabels);
+ extractTagNotEqualNullLabels(fullExp, closureAccessedLabels);
+
+ // Check for valueEqual
+ final Matcher veMatch = VALUE_EQUAL_PATTERN.matcher(fullExp);
+ if (veMatch.find()) {
+ valueForEqual = Double.parseDouble(veMatch.group(1));
+ }
+ }
+
+ if (sampleLabels.isEmpty()) {
+ return null;
+ }
+
+ // Add closure-accessed labels to all samples
+ for (final Set<String> labels : sampleLabels.values()) {
+ labels.addAll(closureAccessedLabels);
+ }
+
+ // Build the YAML content
+ final StringBuilder sb = new StringBuilder();
+ sb.append(LICENSE_HEADER);
+ sb.append("input:\n");
+
+ for (final Map.Entry<String, Set<String>> entry : sampleLabels.entrySet()) {
+ final String sampleName = entry.getKey();
+ final Set<String> labels = entry.getValue();
+
+ sb.append(" ").append(yamlKey(sampleName)).append(":\n");
+
+ if (anyHistogram && labels.contains("le")) {
+ // Generate multiple samples with cumulative le bucket values
+ double cumulativeValue = 0;
+ for (final String le : HISTOGRAM_LE_VALUES) {
+ cumulativeValue += 10.0;
+ sb.append(" - labels:\n");
+ for (final String label : labels) {
+ if ("le".equals(label)) {
+ sb.append(" le: '").append(le).append("'\n");
+ } else {
+ final String value = inferLabelValue(
+ label, sampleName, tagEqualConstraints,
+ tagMatchConstraints);
+ sb.append(" ").append(yamlKey(label))
+ .append(": ").append(yamlValue(value)).append("\n");
+ }
+ }
+ sb.append(" value: ").append(cumulativeValue).append("\n");
+ }
+ } else {
+ sb.append(" - labels:\n");
+ for (final String label : labels) {
+ final String value = inferLabelValue(
+ label, sampleName, tagEqualConstraints, tagMatchConstraints);
+ sb.append(" ").append(yamlKey(label))
+ .append(": ").append(yamlValue(value)).append("\n");
+ }
+ sb.append(" value: ").append(valueForEqual).append("\n");
+ }
+ }
+
+ sb.append("expected:\n");
+ for (final String metricName : metricNames) {
+ sb.append(" ").append(yamlKey(metricName)).append(":\n");
+ sb.append(" min_samples: 1\n");
+ }
+
+ return sb.toString();
+ }
+
+ private void extractSampleNamesFromText(final String expression,
+ final Map<String, Set<String>> sampleLabels) {
+ // Heuristic: identifiers at start, after binary ops, or after }).
+ // Also match after dot when preceded by a closing paren/brace
+ final Pattern p = Pattern.compile(
+ "(?:^|[+\\-*/()]\\s*|\\}\\)\\s*\\.\\s*)([a-zA-Z_][a-zA-Z0-9_]*)");
+ final Matcher m = p.matcher(expression);
+ while (m.find()) {
+ final String name = m.group(1);
+ if (!isKeyword(name) && name.length() > 3) {
+ sampleLabels.computeIfAbsent(name, k -> new LinkedHashSet<>());
+ }
+ }
+ }
+
+ private void extractTagEqualConstraints(final String expression,
+ final Map<String, Map<String, String>> constraints) {
+ final Matcher m = TAG_EQUAL_PATTERN.matcher(expression);
+ while (m.find()) {
+ constraints.computeIfAbsent("_global", k -> new LinkedHashMap<>())
+ .put(m.group(1), m.group(2));
+ }
+ }
+
+ private void extractTagMatchConstraints(final String expression,
+ final Map<String, String> constraints) {
+ final Matcher m = TAG_MATCH_PATTERN.matcher(expression);
+ while (m.find()) {
+ constraints.put(m.group(1), m.group(2));
+ }
+ }
+
+ private void extractClosureAccessedLabels(final String expression,
+ final Set<String> labels) {
+ final Matcher m1 = CLOSURE_TAG_ACCESS_PATTERN.matcher(expression);
+ while (m1.find()) {
+ final String label = m1.group(1);
+ if (!"put".equals(label) && !"get".equals(label) && !"trim".equals(label)
+ && !"toString".equals(label) && !"size".equals(label)
+ && !"length".equals(label)) {
+ labels.add(label);
+ }
+ }
+ final Matcher m2 = CLOSURE_TAG_BRACKET_PATTERN.matcher(expression);
+ while (m2.find()) {
+ labels.add(m2.group(1));
+ }
+ }
+
+ private void extractTagNotEqualNullLabels(final String expression,
+ final Set<String> labels) {
+ final Matcher m = TAG_NOT_EQUAL_NULL_PATTERN.matcher(expression);
+ while (m.find()) {
+ labels.add(m.group(1));
+ }
+ }
+
+ String inferLabelValue(final String label,
+ final String sampleName,
+ final Map<String, Map<String, String>> tagEqualConstraints,
+ final Map<String, String> tagMatchConstraints) {
+ // Check tagEqual constraints first
+ final Map<String, String> globals = tagEqualConstraints.get("_global");
+ if (globals != null && globals.containsKey(label)) {
+ return globals.get(label);
+ }
+
+ // Check tagMatch constraints — generate a matching value
+ if (tagMatchConstraints.containsKey(label)) {
+ return generateMatchingValue(label, tagMatchConstraints.get(label), sampleName);
+ }
+
+ // Known label patterns
+ switch (label) {
+ case "service":
+ case "service_name":
+ return "test-service";
+ case "service_namespace":
+ return "test-ns";
+ case "cluster_name":
+ case "cluster":
+ return "test-cluster";
+ case "instance":
+ case "service_instance_id":
+ return "test-instance";
+ case "endpoint":
+ return "/test";
+ case "host_name":
+ case "node_identifier_host_name":
+ return "test-host";
+ case "node":
+ case "node_id":
+ return "test-node";
+ case "app":
+ return "test-app";
+ case "job_name":
+ return "test-monitoring";
+ case "topic":
+ return "test-topic";
+ case "queue":
+ return "test-queue";
+ case "broker":
+ case "brokerName":
+ return "test-broker";
+ case "pod":
+ case "pod_name":
+ return "test-pod";
+ case "namespace":
+ return "test-namespace";
+ case "container":
+ return "test-container";
+ case "mode":
+ return "user";
+ case "mountpoint":
+ return "/";
+ case "device":
+ return "eth0";
+ case "fstype":
+ return "ext4";
+ case "area":
+ return "heap";
+ case "pool":
+ return "PS_Eden_Space";
+ case "gc":
+ return "PS Scavenge";
+ case "le":
+ return "100";
+ case "type":
+ return "cds";
+ case "status":
+ case "state":
+ return "active";
+ case "code":
+ return "200";
+ case "name":
+ return "test-name";
+ case "level":
+ return "ERROR";
+ case "pipe":
+ return "test-pipe";
+ case "pipeline":
+ return "test-pipeline";
+ case "direction":
+ return "in";
+ case "route":
+ return "test-route";
+ case "protocol":
+ return "http";
+ case "is_ssl":
+ return "false";
+ case "component":
+ return "49";
+ case "created_by":
+ return "test-creator";
+ case "source":
+ return "test-source";
+ case "plugin_name":
+ return "test-plugin";
+ case "inter_type":
+ return "test-type";
+ case "metric_type":
+ case "metricName":
+ return "test-metric";
+ case "kind":
+ return "test-kind";
+ case "operation":
+ return "test-op";
+ case "catalog":
+ return "test-catalog";
+ case "listener":
+ return "test-listener";
+ case "event":
+ return "test-event";
+ case "dimensionality":
+ return "minute";
+ case "shared_dict":
+ return "test-dict";
+ case "key":
+ return "test-key";
+ case "color":
+ return "green";
+ case "process_name":
+ return "test-process";
+ case "layer":
+ return "GENERAL";
+ case "uri":
+ return "/test-uri";
+ case "pid":
+ return "12345";
+ case "side":
+ return "client";
+ case "client_local":
+ return "false";
+ case "server_local":
+ return "true";
+ case "client_address":
+ return "10.0.0.1:8080";
+ case "server_address":
+ return "10.0.0.2:9090";
+ case "client_process_id":
+ case "server_process_id":
+ return "test-process-id";
+ case "cloud_account_id":
+ return "123456789";
+ case "cloud_region":
+ return "us-east-1";
+ case "cloud_provider":
+ return "aws";
+ case "Namespace":
+ return "AWS/DynamoDB";
+ case "Operation":
+ return "GetItem";
+ case "TableName":
+ return "test-table";
+ case "destinationName":
+ return "test-destination";
+ case "destinationType":
+ return "Queue";
+ case "tag":
+ return "1.19.0";
+ case "skywalking_service":
+ return "test-sw-service";
+ case "oscal_control_bundle":
+ case "control_bundle":
+ return "nist-800-53";
+ case "oscal_control_name":
+ case "control_name":
+ return "AC-1";
+ case "secret_name":
+ return "test-secret";
+ case "partition":
+ return "0";
+ case "metrics_name":
+ return "test-metrics";
+ case "cmd":
+ return "get";
+ default:
+ return "test-value";
+ }
+ }
+
+ /**
+ * Generate a value that matches the given tagMatch regex pattern.
+ */
+ private String generateMatchingValue(final String label, final String pattern,
+ final String sampleName) {
+ // Handle common patterns
+ if ("metrics_name".equals(label)) {
+ if (pattern.contains("ssl") && pattern.contains("expiration")) {
+ // envoy-ca pattern: .*ssl.*expiration_unix_time_seconds
+ return "cluster.ssl.certificate.test-cert.expiration_unix_time_seconds";
+ }
+ if (pattern.contains("membership_healthy")) {
+ return "cluster.test-cluster.membership_healthy";
+ }
+ if (pattern.contains("membership_total")) {
+ return "cluster.test-cluster.membership_total";
+ }
+ // Generic: try to make it match
+ return pattern.replace(".*", "test").replace(".+", "test");
+ }
+ if ("gc".equals(label)) {
+ // GC names in tagMatch: PS Scavenge|Copy|ParNew|...
+ if (pattern.contains("PS Scavenge")) {
+ return "PS Scavenge";
+ }
+ if (pattern.contains("PS MarkSweep")) {
+ return "PS MarkSweep";
+ }
+ return pattern.split("\\|")[0];
+ }
+ if ("Operation".equals(label)) {
+ return pattern.split("\\|")[0];
+ }
+ // Generic: take first alternative or strip regex syntax
+ final String stripped = pattern
+ .replace(".*", "test")
+ .replace(".+", "test")
+ .replaceAll("\\[\\^.\\]\\+", "test")
+ .replace("(", "").replace(")", "")
+ .replace("^", "").replace("$", "");
+ if (stripped.contains("|")) {
+ return stripped.split("\\|")[0];
+ }
+ return stripped;
+ }
+
+ private static boolean isKeyword(final String name) {
+ switch (name) {
+ case "def":
+ case "if":
+ case "else":
+ case "return":
+ case "null":
+ case "true":
+ case "false":
+ case "in":
+ case "String":
+ case "tag":
+ case "sum":
+ case "avg":
+ case "min":
+ case "max":
+ case "count":
+ case "rate":
+ case "increase":
+ case "irate":
+ case "histogram":
+ case "service":
+ case "instance":
+ case "endpoint":
+ case "downsampling":
+ case "forEach":
+ case "tagEqual":
+ case "tagNotEqual":
+ case "tagMatch":
+ case "tagNotMatch":
+ case "valueEqual":
+ case "multiply":
+ case "filter":
+ case "time":
+ case "Layer":
+ case "SUM":
+ case "AVG":
+ case "MIN":
+ case "MAX":
+ case "LATEST":
+ case "MEAN":
+ case "ProcessRegistry":
+ // Closure parameter names (not sample names)
+ case "tags":
+ case "me":
+ case "prefix":
+ case "key":
+ case "result":
+ case "protocol":
+ case "ssl":
+ case "matcher":
+ case "parts":
+ case "java":
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ private static String yamlKey(final String key) {
+ // Quote keys that contain special chars
+ if (key.contains("-") || key.contains(".") || key.contains(" ")) {
+ return "'" + key + "'";
+ }
+ return key;
+ }
+
+ private static String yamlValue(final String value) {
+ if (value == null) {
+ return "''";
+ }
+ // Quote values that could be misinterpreted
+ if (value.contains(":") || value.contains("#") || value.contains("{")
+ || value.contains("}") || value.contains("[") || value.contains("]")
+ || value.contains("'") || value.contains("\"") || value.contains(",")
+ || value.contains("&") || value.contains("*") || value.contains("!")
+ || value.contains("|") || value.contains(">") || value.contains("%")
+ || value.contains("@") || value.contains("`")
+ || "true".equals(value) || "false".equals(value)
+ || "null".equals(value) || "yes".equals(value) || "no".equals(value)) {
+ return "'" + value.replace("'", "''") + "'";
+ }
+ return value;
+ }
+
+ Path findScriptsDir() {
+ final String[] candidates = {
+ "test/script-cases/scripts/mal",
+ "../../scripts/mal"
+ };
+ for (final String candidate : candidates) {
+ final Path path = Path.of(candidate);
+ if (Files.isDirectory(path)) {
+ return path;
+ }
+ }
+ return null;
+ }
+}
diff --git a/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalInputDataGeneratorTest.java b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalInputDataGeneratorTest.java
new file mode 100644
index 0000000000..013d72bc31
--- /dev/null
+++ b/test/script-cases/script-runtime-with-groovy/mal-lal-v1-v2-checker/src/test/java/org/apache/skywalking/oap/server/checker/mal/MalInputDataGeneratorTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.checker.mal;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Runs {@link MalInputDataGenerator} to generate .data.yaml companion files
+ * for all MAL test YAML scripts. This test is idempotent — it skips files
+ * that already have companions.
+ */
+class MalInputDataGeneratorTest {
+
+ @Test
+ void generateAllInputFiles() throws Exception {
+ final MalInputDataGenerator gen = new MalInputDataGenerator();
+ final Path scriptsDir = gen.findScriptsDir();
+ assertTrue(scriptsDir != null && Files.isDirectory(scriptsDir),
+ "Cannot find scripts/mal directory");
+
+ final String[] dirs = {
+ "test-meter-analyzer-config",
+ "test-otel-rules",
+ "test-envoy-metrics-rules",
+ "test-log-mal-rules"
+ };
+
+ int totalGenerated = 0;
+ for (final String dir : dirs) {
+ final Path dirPath = scriptsDir.resolve(dir);
+ if (Files.isDirectory(dirPath)) {
+ final int[] counts = gen.processDirectory(dirPath);
+ totalGenerated += counts[0];
+ }
+ }
+
+ // Verify at least some files were generated or already existed
+ final long inputFileCount = Files.walk(scriptsDir)
+ .filter(p -> p.toString().endsWith(".data.yaml"))
+ .count();
+ assertTrue(inputFileCount > 0,
+ "Expected at least one .data.yaml file to exist");
+ }
+}
diff --git a/test/script-cases/scripts/hierarchy-rule/test-hierarchy-definition.data.yaml b/test/script-cases/scripts/hierarchy-rule/test-hierarchy-definition.data.yaml
new file mode 100644
index 0000000000..738ae0c4ac
--- /dev/null
+++ b/test/script-cases/scripts/hierarchy-rule/test-hierarchy-definition.data.yaml
@@ -0,0 +1,111 @@
+# 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.
+
+input:
+ name:
+ - description: "exact match"
+ upper: { name: "my-service", shortName: "my-service" }
+ lower: { name: "my-service", shortName: "my-service" }
+ expected: true
+ - description: "mismatch"
+ upper: { name: "svc-a", shortName: "svc-a" }
+ lower: { name: "svc-b", shortName: "svc-b" }
+ expected: false
+ - description: "same shortName different name"
+ upper: { name: "svc-a", shortName: "same" }
+ lower: { name: "svc-b", shortName: "same" }
+ expected: false
+ - description: "empty names"
+ upper: { name: "", shortName: "" }
+ lower: { name: "", shortName: "" }
+ expected: true
+
+ short-name:
+ - description: "exact shortName match"
+ upper: { name: "full-a", shortName: "svc" }
+ lower: { name: "full-b", shortName: "svc" }
+ expected: true
+ - description: "shortName mismatch"
+ upper: { name: "a", shortName: "svc-1" }
+ lower: { name: "b", shortName: "svc-2" }
+ expected: false
+ - description: "same name different shortName"
+ upper: { name: "same", shortName: "short-a" }
+ lower: { name: "same", shortName: "short-b" }
+ expected: false
+ - description: "empty shortNames"
+ upper: { name: "a", shortName: "" }
+ lower: { name: "b", shortName: "" }
+ expected: true
+
+ lower-short-name-remove-ns:
+ - description: "match: svc == svc.namespace"
+ upper: { name: "a", shortName: "svc" }
+ lower: { name: "b", shortName: "svc.namespace" }
+ expected: true
+ - description: "match: app == app.default"
+ upper: { name: "a", shortName: "app" }
+ lower: { name: "b", shortName: "app.default" }
+ expected: true
+ - description: "no dot in lower"
+ upper: { name: "a", shortName: "svc" }
+ lower: { name: "b", shortName: "svc" }
+ expected: false
+ - description: "mismatch prefix"
+ upper: { name: "a", shortName: "other" }
+ lower: { name: "b", shortName: "svc.namespace" }
+ expected: false
+ - description: "dot at position 0"
+ upper: { name: "a", shortName: "" }
+ lower: { name: "b", shortName: ".namespace" }
+ expected: false
+ - description: "multiple dots - uses last"
+ upper: { name: "a", shortName: "svc.ns1" }
+ lower: { name: "b", shortName: "svc.ns1.ns2" }
+ expected: true
+ - description: "empty lower"
+ upper: { name: "a", shortName: "svc" }
+ lower: { name: "b", shortName: "" }
+ expected: false
+
+ lower-short-name-with-fqdn:
+ - description: "match: db.svc.cluster.local:3306 vs db"
+ upper: { name: "a", shortName: "db.svc.cluster.local:3306" }
+ lower: { name: "b", shortName: "db" }
+ expected: true
+ - description: "match: redis.svc.cluster.local:6379 vs redis"
+ upper: { name: "a", shortName: "redis.svc.cluster.local:6379" }
+ lower: { name: "b", shortName: "redis" }
+ expected: true
+ - description: "no colon in upper"
+ upper: { name: "a", shortName: "db" }
+ lower: { name: "b", shortName: "db" }
+ expected: false
+ - description: "wrong fqdn suffix"
+ upper: { name: "a", shortName: "db:3306" }
+ lower: { name: "b", shortName: "other" }
+ expected: false
+ - description: "upper without fqdn"
+ upper: { name: "a", shortName: "db:3306" }
+ lower: { name: "b", shortName: "db" }
+ expected: false
+ - description: "empty upper"
+ upper: { name: "a", shortName: "" }
+ lower: { name: "b", shortName: "db" }
+ expected: false
+ - description: "colon at end"
+ upper: { name: "a", shortName: "db.svc.cluster.local:" }
+ lower: { name: "b", shortName: "db" }
+ expected: true
diff --git a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml b/test/script-cases/scripts/mal/test-envoy-metrics-rules/envoy-ca.data.yaml
similarity index 51%
copy from test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
copy to test/script-cases/scripts/mal/test-envoy-metrics-rules/envoy-ca.data.yaml
index 034440ce5e..213be44e18 100644
--- a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
+++ b/test/script-cases/scripts/mal/test-envoy-metrics-rules/envoy-ca.data.yaml
@@ -13,4 +13,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Refer to examples in config-examples/log-mal.yaml
+input:
+ envoy_cluster_metrics:
+ - labels:
+ app: test-app
+ secret_name: test-secret
+ instance: test-instance
+ metrics_name: cluster.ssl.certificate.test-cert.expiration_unix_time_seconds
+ value: 100.0
+ envoy_listener_metrics:
+ - labels:
+ app: test-app
+ secret_name: test-secret
+ instance: test-instance
+ metrics_name: cluster.ssl.certificate.test-cert.expiration_unix_time_seconds
+ value: 100.0
+expected:
+ service_cluster_ssl_ca_expiration_seconds:
+ min_samples: 1
+ service_listener_ssl_ca_expiration_seconds:
+ min_samples: 1
+ instance_cluster_ssl_ca_expiration_seconds:
+ min_samples: 1
+ instance_listener_ssl_ca_expiration_seconds:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml b/test/script-cases/scripts/mal/test-envoy-metrics-rules/envoy-svc-relation.data.yaml
similarity index 63%
copy from test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
copy to test/script-cases/scripts/mal/test-envoy-metrics-rules/envoy-svc-relation.data.yaml
index 034440ce5e..cea2cab52a 100644
--- a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
+++ b/test/script-cases/scripts/mal/test-envoy-metrics-rules/envoy-svc-relation.data.yaml
@@ -13,4 +13,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Refer to examples in config-examples/log-mal.yaml
+input:
+ envoy_cluster_metrics:
+ - labels:
+ app: test-app
+ cluster_name: test-cluster
+ value: 100.0
+expected:
+ cluster_up_cx_active:
+ min_samples: 1
+ cluster_up_cx_incr:
+ min_samples: 1
+ cluster_up_rq_active:
+ min_samples: 1
+ cluster_up_rq_incr:
+ min_samples: 1
+ cluster_up_rq_pending_active:
+ min_samples: 1
+ cluster_lb_healthy_panic_incr:
+ min_samples: 1
+ cluster_up_cx_none_healthy_incr:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-envoy-metrics-rules/envoy.data.yaml b/test/script-cases/scripts/mal/test-envoy-metrics-rules/envoy.data.yaml
new file mode 100644
index 0000000000..3c38ca0c62
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-envoy-metrics-rules/envoy.data.yaml
@@ -0,0 +1,96 @@
+# 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.
+
+input:
+ server_memory_heap_size:
+ - labels:
+ app: test-app
+ instance: test-instance
+ value: 100.0
+ server_memory_allocated:
+ - labels:
+ app: test-app
+ instance: test-instance
+ value: 100.0
+ server_memory_physical_size:
+ - labels:
+ app: test-app
+ instance: test-instance
+ value: 100.0
+ server_total_connections:
+ - labels:
+ app: test-app
+ instance: test-instance
+ value: 100.0
+ server_parent_connections:
+ - labels:
+ app: test-app
+ instance: test-instance
+ value: 100.0
+ server_concurrency:
+ - labels:
+ app: test-app
+ instance: test-instance
+ value: 100.0
+ server_envoy_bug_failures:
+ - labels:
+ app: test-app
+ instance: test-instance
+ value: 100.0
+ envoy_cluster_metrics:
+ - labels:
+ app: test-app
+ instance: test-instance
+ cluster_name: test-cluster
+ value: 100.0
+expected:
+ heap_memory_used:
+ min_samples: 1
+ heap_memory_max_used:
+ min_samples: 1
+ memory_allocated:
+ min_samples: 1
+ memory_allocated_max:
+ min_samples: 1
+ memory_physical_size:
+ min_samples: 1
+ memory_physical_size_max:
+ min_samples: 1
+ total_connections_used:
+ min_samples: 1
+ parent_connections_used:
+ min_samples: 1
+ worker_threads:
+ min_samples: 1
+ worker_threads_max:
+ min_samples: 1
+ bug_failures:
+ min_samples: 1
+ cluster_membership_healthy:
+ min_samples: 1
+ cluster_up_cx_active:
+ min_samples: 1
+ cluster_up_cx_incr:
+ min_samples: 1
+ cluster_up_rq_active:
+ min_samples: 1
+ cluster_up_rq_incr:
+ min_samples: 1
+ cluster_up_rq_pending_active:
+ min_samples: 1
+ cluster_lb_healthy_panic_incr:
+ min_samples: 1
+ cluster_up_cx_none_healthy_incr:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml b/test/script-cases/scripts/mal/test-log-mal-rules/nginx.data.yaml
similarity index 74%
copy from test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
copy to test/script-cases/scripts/mal/test-log-mal-rules/nginx.data.yaml
index 034440ce5e..5f43ebe3b3 100644
--- a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
+++ b/test/script-cases/scripts/mal/test-log-mal-rules/nginx.data.yaml
@@ -13,4 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Refer to examples in config-examples/log-mal.yaml
+input:
+ nginx_error_log_count:
+ - labels:
+ level: ERROR
+ service: test-service
+ service_instance_id: test-instance
+ value: 100.0
+expected:
+ service_error_log_count:
+ min_samples: 1
+ instance_error_log_count:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/continuous-profiling.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/continuous-profiling.data.yaml
new file mode 100644
index 0000000000..961f346973
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/continuous-profiling.data.yaml
@@ -0,0 +1,64 @@
+# 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.
+
+input:
+ rover_con_p_process_cpu:
+ - labels:
+ service: test-service
+ instance: test-instance
+ process_name: test-process
+ layer: GENERAL
+ value: 100.0
+ rover_con_p_process_thread_count:
+ - labels:
+ service: test-service
+ instance: test-instance
+ process_name: test-process
+ layer: GENERAL
+ value: 100.0
+ rover_con_p_system_load:
+ - labels:
+ service: test-service
+ instance: test-instance
+ process_name: test-process
+ layer: GENERAL
+ value: 100.0
+ rover_con_p_http_error_rate:
+ - labels:
+ service: test-service
+ instance: test-instance
+ process_name: test-process
+ layer: GENERAL
+ uri: /test-uri
+ value: 100.0
+ rover_con_p_http_avg_response_time:
+ - labels:
+ service: test-service
+ instance: test-instance
+ process_name: test-process
+ layer: GENERAL
+ uri: /test-uri
+ value: 100.0
+expected:
+ process_cpu:
+ min_samples: 1
+ process_thread_count:
+ min_samples: 1
+ system_load:
+ min_samples: 1
+ http_error_rate:
+ min_samples: 1
+ http_avg_response_time:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/datasource.data.yaml
similarity index 79%
copy from test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
copy to test/script-cases/scripts/mal/test-meter-analyzer-config/datasource.data.yaml
index 034440ce5e..20608b861d 100644
--- a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/datasource.data.yaml
@@ -13,4 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Refer to examples in config-examples/log-mal.yaml
+input:
+ datasource:
+ - labels:
+ service: test-service
+ instance: test-instance
+ name: test-name
+ status: active
+ value: 100.0
+expected:
+ datasource:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/go-agent.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/go-agent.data.yaml
new file mode 100644
index 0000000000..a8c57c7821
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/go-agent.data.yaml
@@ -0,0 +1,91 @@
+# 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.
+
+input:
+ sw_go_created_tracing_context_counter:
+ - labels:
+ created_by: test-creator
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ sw_go_finished_tracing_context_counter:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ sw_go_created_ignored_context_counter:
+ - labels:
+ created_by: test-creator
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ sw_go_finished_ignored_context_counter:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ sw_go_possible_leaked_context_counter:
+ - labels:
+ source: test-source
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ sw_go_interceptor_error_counter:
+ - labels:
+ plugin_name: test-plugin
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ sw_go_tracing_context_performance:
+ - labels:
+ le: '50'
+ service: test-service
+ instance: test-instance
+ value: 10.0
+ - labels:
+ le: '100'
+ service: test-service
+ instance: test-instance
+ value: 20.0
+ - labels:
+ le: '250'
+ service: test-service
+ instance: test-instance
+ value: 30.0
+ - labels:
+ le: '500'
+ service: test-service
+ instance: test-instance
+ value: 40.0
+ - labels:
+ le: '1000'
+ service: test-service
+ instance: test-instance
+ value: 50.0
+expected:
+ sw_go_created_tracing_context_count:
+ min_samples: 1
+ sw_go_finished_tracing_context_count:
+ min_samples: 1
+ sw_go_created_ignored_context_count:
+ min_samples: 1
+ sw_go_finished_ignored_context_count:
+ min_samples: 1
+ sw_go_possible_leaked_context_count:
+ min_samples: 1
+ sw_go_interceptor_error_count:
+ min_samples: 1
+ sw_go_tracing_context_execution_time_percentile:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/go-runtime.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/go-runtime.data.yaml
new file mode 100644
index 0000000000..50e8f6b3dd
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/go-runtime.data.yaml
@@ -0,0 +1,238 @@
+# 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.
+
+input:
+ instance_golang_heap_alloc:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_stack_used:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_pause_time:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_count:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_os_threads_num:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_live_goroutines_num:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_host_cpu_used_rate:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_host_mem_used_rate:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_heap_alloc_size:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_count_labeled:
+ - labels:
+ service: test-service
+ instance: test-instance
+ type: cds
+ value: 100.0
+ instance_golang_heap_alloc_objects:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_heap_frees:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_heap_frees_objects:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_memory_heap_labeled:
+ - labels:
+ service: test-service
+ instance: test-instance
+ type: cds
+ value: 100.0
+ instance_golang_metadata_mcache_labeled:
+ - labels:
+ service: test-service
+ instance: test-instance
+ type: cds
+ value: 100.0
+ instance_golang_metadata_mspan_labeled:
+ - labels:
+ service: test-service
+ instance: test-instance
+ type: cds
+ value: 100.0
+ instance_golang_cgo_calls:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_heap_goal:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_heap_objects:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_heap_tiny_allocs:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_limiter_last_enabled:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_stack_starting_size:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_memory_metadata_other:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_memory_os_stacks:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_memory_other:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_memory_profiling_buckets:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_memory_total:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_heap_allocs_by_size:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_heap_frees_by_size:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_gc_pauses:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_golang_sched_latencies:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+expected:
+ instance_golang_heap_alloc:
+ min_samples: 1
+ instance_golang_stack_used:
+ min_samples: 1
+ instance_golang_gc_pause_time:
+ min_samples: 1
+ instance_golang_gc_count:
+ min_samples: 1
+ instance_golang_os_threads_num:
+ min_samples: 1
+ instance_golang_live_goroutines_num:
+ min_samples: 1
+ instance_host_cpu_used_rate:
+ min_samples: 1
+ instance_host_mem_used_rate:
+ min_samples: 1
+ instance_golang_heap_alloc_rate:
+ min_samples: 1
+ instance_golang_gc_count_labeled:
+ min_samples: 1
+ instance_golang_heap_alloc_objects:
+ min_samples: 1
+ instance_golang_heap_frees:
+ min_samples: 1
+ instance_golang_heap_frees_objects:
+ min_samples: 1
+ instance_golang_memory_heap_labeled:
+ min_samples: 1
+ instance_golang_metadata_mcache_labeled:
+ min_samples: 1
+ instance_golang_metadata_mspan_labeled:
+ min_samples: 1
+ instance_golang_cgo_calls:
+ min_samples: 1
+ instance_golang_gc_heap_goal:
+ min_samples: 1
+ instance_golang_gc_heap_objects:
+ min_samples: 1
+ instance_golang_gc_heap_tiny_allocs:
+ min_samples: 1
+ instance_golang_gc_limiter_last_enabled:
+ min_samples: 1
+ instance_golang_gc_stack_starting_size:
+ min_samples: 1
+ instance_golang_memory_metadata_other:
+ min_samples: 1
+ instance_golang_memory_os_stacks:
+ min_samples: 1
+ instance_golang_memory_other:
+ min_samples: 1
+ instance_golang_memory_profiling_buckets:
+ min_samples: 1
+ instance_golang_memory_total:
+ min_samples: 1
+ instance_golang_gc_heap_allocs_by_size:
+ min_samples: 1
+ instance_golang_gc_heap_frees_by_size:
+ min_samples: 1
+ instance_golang_gc_pauses:
+ min_samples: 1
+ instance_golang_sched_latencies:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/java-agent.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/java-agent.data.yaml
new file mode 100644
index 0000000000..64a67bbb54
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/java-agent.data.yaml
@@ -0,0 +1,92 @@
+# 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.
+
+input:
+ created_tracing_context_counter:
+ - labels:
+ created_by: test-creator
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ finished_tracing_context_counter:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ created_ignored_context_counter:
+ - labels:
+ created_by: test-creator
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ finished_ignored_context_counter:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ possible_leaked_context_counter:
+ - labels:
+ source: test-source
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ interceptor_error_counter:
+ - labels:
+ plugin_name: test-plugin
+ inter_type: test-type
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ tracing_context_performance:
+ - labels:
+ le: '50'
+ service: test-service
+ instance: test-instance
+ value: 10.0
+ - labels:
+ le: '100'
+ service: test-service
+ instance: test-instance
+ value: 20.0
+ - labels:
+ le: '250'
+ service: test-service
+ instance: test-instance
+ value: 30.0
+ - labels:
+ le: '500'
+ service: test-service
+ instance: test-instance
+ value: 40.0
+ - labels:
+ le: '1000'
+ service: test-service
+ instance: test-instance
+ value: 50.0
+expected:
+ created_tracing_context_count:
+ min_samples: 1
+ finished_tracing_context_count:
+ min_samples: 1
+ created_ignored_context_count:
+ min_samples: 1
+ finished_ignored_context_count:
+ min_samples: 1
+ possible_leaked_context_count:
+ min_samples: 1
+ interceptor_error_count:
+ min_samples: 1
+ tracing_context_execution_time_percentile:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/network-profiling.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/network-profiling.data.yaml
new file mode 100644
index 0000000000..d9b7e82c57
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/network-profiling.data.yaml
@@ -0,0 +1,164 @@
+# 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.
+
+input:
+ tags:
+ - labels:
+ service: test-service
+ instance: test-instance
+ protocol: http
+ is_ssl: 'false'
+ value: 100.0
+ protocol:
+ - labels:
+ service: test-service
+ instance: test-instance
+ protocol: http
+ is_ssl: 'false'
+ value: 100.0
+ libraries:
+ - labels:
+ service: test-service
+ instance: test-instance
+ protocol: http
+ is_ssl: 'false'
+ value: 100.0
+ https:
+ - labels:
+ service: test-service
+ instance: test-instance
+ protocol: http
+ is_ssl: 'false'
+ value: 100.0
+ http:
+ - labels:
+ service: test-service
+ instance: test-instance
+ protocol: http
+ is_ssl: 'false'
+ value: 100.0
+ ssl:
+ - labels:
+ service: test-service
+ instance: test-instance
+ protocol: http
+ is_ssl: 'false'
+ value: 100.0
+ tls:
+ - labels:
+ service: test-service
+ instance: test-instance
+ protocol: http
+ is_ssl: 'false'
+ value: 100.0
+ tcp:
+ - labels:
+ service: test-service
+ instance: test-instance
+ protocol: http
+ is_ssl: 'false'
+ value: 100.0
+ SUM_PER_MIN:
+ - labels:
+ service: test-service
+ instance: test-instance
+ protocol: http
+ is_ssl: 'false'
+ value: 100.0
+expected:
+ client_write_cpm:
+ min_samples: 1
+ client_write_total_bytes:
+ min_samples: 1
+ client_write_avg_exe_time:
+ min_samples: 1
+ client_read_cpm:
+ min_samples: 1
+ client_read_total_bytes:
+ min_samples: 1
+ client_read_avg_exe_time:
+ min_samples: 1
+ client_write_avg_rtt_time:
+ min_samples: 1
+ client_connect_cpm:
+ min_samples: 1
+ client_connect_exe_time:
+ min_samples: 1
+ client_close_cpm:
+ min_samples: 1
+ client_close_avg_exe_time:
+ min_samples: 1
+ client_retransmit_cpm:
+ min_samples: 1
+ client_drop_cpm:
+ min_samples: 1
+ client_write_rtt_time_percentile:
+ min_samples: 1
+ client_write_exe_time_percentile:
+ min_samples: 1
+ client_read_exe_time_percentile:
+ min_samples: 1
+ server_write_cpm:
+ min_samples: 1
+ server_write_total_bytes:
+ min_samples: 1
+ server_write_avg_exe_time:
+ min_samples: 1
+ server_read_cpm:
+ min_samples: 1
+ server_read_total_bytes:
+ min_samples: 1
+ server_read_avg_exe_time:
+ min_samples: 1
+ server_write_avg_rtt_time:
+ min_samples: 1
+ server_connect_cpm:
+ min_samples: 1
+ server_connect_avg_exe_time:
+ min_samples: 1
+ server_close_cpm:
+ min_samples: 1
+ server_close_avg_exe_time:
+ min_samples: 1
+ server_retransmit_cpm:
+ min_samples: 1
+ server_drop_cpm:
+ min_samples: 1
+ server_write_rtt_time_percentile:
+ min_samples: 1
+ server_write_exe_time_percentile:
+ min_samples: 1
+ server_read_exe_time_percentile:
+ min_samples: 1
+ http1_request_cpm:
+ min_samples: 1
+ http1_response_status_cpm:
+ min_samples: 1
+ http1_request_package_size:
+ min_samples: 1
+ http1_response_package_size:
+ min_samples: 1
+ http1_request_package_size_percentile:
+ min_samples: 1
+ http1_response_package_size_percentile:
+ min_samples: 1
+ http1_client_duration:
+ min_samples: 1
+ http1_server_duration:
+ min_samples: 1
+ http1_client_duration_percentile:
+ min_samples: 1
+ http1_server_duration_percentile:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/python-runtime.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/python-runtime.data.yaml
new file mode 100644
index 0000000000..fc2b9b714a
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/python-runtime.data.yaml
@@ -0,0 +1,80 @@
+# 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.
+
+input:
+ instance_pvm_process_cpu_utilization:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_pvm_process_mem_utilization:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_pvm_total_cpu_utilization:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_pvm_total_mem_utilization:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_pvm_gc_g0:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_pvm_gc_g1:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_pvm_gc_g2:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_pvm_gc_time:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_pvm_thread_active_count:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+expected:
+ instance_pvm_process_cpu_utilization:
+ min_samples: 1
+ instance_pvm_process_mem_utilization:
+ min_samples: 1
+ instance_pvm_total_cpu_utilization:
+ min_samples: 1
+ instance_pvm_total_mem_utilization:
+ min_samples: 1
+ instance_pvm_gc_g0:
+ min_samples: 1
+ instance_pvm_gc_g1:
+ min_samples: 1
+ instance_pvm_gc_g2:
+ min_samples: 1
+ instance_pvm_gc_time:
+ min_samples: 1
+ instance_pvm_thread_active_count:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/ruby-runtime.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/ruby-runtime.data.yaml
new file mode 100644
index 0000000000..be10d6de7f
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/ruby-runtime.data.yaml
@@ -0,0 +1,108 @@
+# 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.
+
+input:
+ instance_ruby_cpu_usage_percent:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_memory_rss_mb:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_memory_usage_percent:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_gc_count_total:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_gc_minor_count_total:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_gc_major_count_total:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_gc_time_total:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_heap_usage_percent:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_thread_count_active:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_thread_count_running:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_total_allocated_objects:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_heap_live_slots_count:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ instance_ruby_heap_available_slots_count:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+expected:
+ instance_ruby_cpu_usage_percent:
+ min_samples: 1
+ instance_ruby_memory_rss_mb:
+ min_samples: 1
+ instance_ruby_memory_usage_percent:
+ min_samples: 1
+ instance_ruby_gc_count_total:
+ min_samples: 1
+ instance_ruby_gc_minor_count_total:
+ min_samples: 1
+ instance_ruby_gc_major_count_total:
+ min_samples: 1
+ instance_ruby_gc_time_total:
+ min_samples: 1
+ instance_ruby_heap_usage_percent:
+ min_samples: 1
+ instance_ruby_thread_count_active:
+ min_samples: 1
+ instance_ruby_thread_count_running:
+ min_samples: 1
+ instance_ruby_total_allocated_objects:
+ min_samples: 1
+ instance_ruby_heap_live_slots_count:
+ min_samples: 1
+ instance_ruby_heap_available_slots_count:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/satellite-tag-prefix.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/satellite-tag-prefix.data.yaml
new file mode 100644
index 0000000000..44de2988a6
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/satellite-tag-prefix.data.yaml
@@ -0,0 +1,75 @@
+# 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.
+
+input:
+ sw_stl_gatherer_receive_count:
+ - labels:
+ pipe: test-pipe
+ status: active
+ service: test-service
+ value: 100.0
+ sw_stl_gatherer_fetch_count:
+ - labels:
+ pipe: test-pipe
+ status: active
+ service: test-service
+ value: 100.0
+ sw_stl_queue_output_count:
+ - labels:
+ pipe: test-pipe
+ status: active
+ service: test-service
+ value: 100.0
+ sw_stl_sender_output_count:
+ - labels:
+ pipe: test-pipe
+ status: active
+ service: test-service
+ value: 100.0
+ sw_stl_pipeline_queue_total_capacity:
+ - labels:
+ pipeline: test-pipeline
+ service: test-service
+ value: 100.0
+ sw_stl_pipeline_queue_partition_size:
+ - labels:
+ pipeline: test-pipeline
+ service: test-service
+ value: 100.0
+ sw_stl_grpc_server_cpu_gauge:
+ - labels:
+ service: test-service
+ value: 100.0
+ sw_stl_grpc_server_connection_count:
+ - labels:
+ service: test-service
+ value: 100.0
+expected:
+ service_receive_event_count:
+ min_samples: 1
+ service_fetch_event_count:
+ min_samples: 1
+ service_queue_input_count:
+ min_samples: 1
+ service_send_event_count:
+ min_samples: 1
+ service_queue_total_capacity:
+ min_samples: 1
+ service_queue_used_count:
+ min_samples: 1
+ service_server_cpu_utilization:
+ min_samples: 1
+ service_grpc_connect_count:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/satellite.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/satellite.data.yaml
new file mode 100644
index 0000000000..44de2988a6
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/satellite.data.yaml
@@ -0,0 +1,75 @@
+# 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.
+
+input:
+ sw_stl_gatherer_receive_count:
+ - labels:
+ pipe: test-pipe
+ status: active
+ service: test-service
+ value: 100.0
+ sw_stl_gatherer_fetch_count:
+ - labels:
+ pipe: test-pipe
+ status: active
+ service: test-service
+ value: 100.0
+ sw_stl_queue_output_count:
+ - labels:
+ pipe: test-pipe
+ status: active
+ service: test-service
+ value: 100.0
+ sw_stl_sender_output_count:
+ - labels:
+ pipe: test-pipe
+ status: active
+ service: test-service
+ value: 100.0
+ sw_stl_pipeline_queue_total_capacity:
+ - labels:
+ pipeline: test-pipeline
+ service: test-service
+ value: 100.0
+ sw_stl_pipeline_queue_partition_size:
+ - labels:
+ pipeline: test-pipeline
+ service: test-service
+ value: 100.0
+ sw_stl_grpc_server_cpu_gauge:
+ - labels:
+ service: test-service
+ value: 100.0
+ sw_stl_grpc_server_connection_count:
+ - labels:
+ service: test-service
+ value: 100.0
+expected:
+ service_receive_event_count:
+ min_samples: 1
+ service_fetch_event_count:
+ min_samples: 1
+ service_queue_input_count:
+ min_samples: 1
+ service_send_event_count:
+ min_samples: 1
+ service_queue_total_capacity:
+ min_samples: 1
+ service_queue_used_count:
+ min_samples: 1
+ service_server_cpu_utilization:
+ min_samples: 1
+ service_grpc_connect_count:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-meter-analyzer-config/spring-micrometer.data.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/spring-micrometer.data.yaml
new file mode 100644
index 0000000000..dcc9ff20f6
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/spring-micrometer.data.yaml
@@ -0,0 +1,178 @@
+# 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.
+
+input:
+ http_server_requests_count:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ http_server_requests_sum:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jdbc_connections_active:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jdbc_connections_idle:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jdbc_connections_max:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_classes_loaded:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_classes_unloaded:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_gc_pause_count:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_gc_pause_sum:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_memory_committed:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_memory_max:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_memory_used:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_threads_daemon:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_threads_live:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ jvm_threads_peak:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ process_cpu_usage:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ system_cpu_usage:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ system_load_average_1m:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ tomcat_sessions_active_current:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ tomcat_sessions_active_max:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ tomcat_sessions_rejected:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ process_files_max:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+ process_files_open:
+ - labels:
+ service: test-service
+ instance: test-instance
+ value: 100.0
+expected:
+ http_server_requests_count:
+ min_samples: 1
+ http_server_requests_duration:
+ min_samples: 1
+ jdbc_connections_active:
+ min_samples: 1
+ jdbc_connections_idle:
+ min_samples: 1
+ jdbc_connections_max:
+ min_samples: 1
+ jvm_classes_loaded:
+ min_samples: 1
+ jvm_classes_unloaded:
+ min_samples: 1
+ jvm_gc_pause_count:
+ min_samples: 1
+ jvm_gc_pause_duration:
+ min_samples: 1
+ jvm_memory_committed:
+ min_samples: 1
+ jvm_memory_max:
+ min_samples: 1
+ jvm_memory_used:
+ min_samples: 1
+ jvm_threads_daemon:
+ min_samples: 1
+ jvm_threads_live:
+ min_samples: 1
+ jvm_threads_peak:
+ min_samples: 1
+ process_cpu_usage:
+ min_samples: 1
+ system_cpu_usage:
+ min_samples: 1
+ system_load_average_1m:
+ min_samples: 1
+ tomcat_sessions_active_current:
+ min_samples: 1
+ tomcat_sessions_active_max:
+ min_samples: 1
+ tomcat_sessions_rejected:
+ min_samples: 1
+ process_files_max:
+ min_samples: 1
+ process_files_open:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml b/test/script-cases/scripts/mal/test-meter-analyzer-config/threadpool.data.yaml
similarity index 77%
copy from test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
copy to test/script-cases/scripts/mal/test-meter-analyzer-config/threadpool.data.yaml
index 034440ce5e..2b75bf1794 100644
--- a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
+++ b/test/script-cases/scripts/mal/test-meter-analyzer-config/threadpool.data.yaml
@@ -13,4 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Refer to examples in config-examples/log-mal.yaml
+input:
+ thread_pool:
+ - labels:
+ metric_type: test-metric
+ pool_name: test-value
+ instance: test-instance
+ service: test-service
+ value: 100.0
+expected:
+ thread_pool:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/activemq/activemq-broker.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/activemq/activemq-broker.data.yaml
new file mode 100644
index 0000000000..1b9e7f0dc8
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/activemq/activemq-broker.data.yaml
@@ -0,0 +1,173 @@
+# 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.
+
+input:
+ org_apache_activemq_Broker_UptimeMillis:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_Slave:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_CurrentConnectionsCount:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_ProducerCount:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_ConsumerCount:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_TotalProducerCount:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_TotalConsumerCount:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_TotalEnqueueCount:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_TotalDequeueCount:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_MemoryPercentUsage:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_MemoryUsageByteCount:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_MemoryLimit:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_StorePercentUsage:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_StoreLimit:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_TempPercentUsage:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_TempLimit:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_AverageMessageSize:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_MaxMessageSize:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_QueueSize:
+ - labels:
+ cluster: test-cluster
+ brokerName: test-broker
+ destinationName: test-destination
+ value: 100.0
+expected:
+ uptime:
+ min_samples: 1
+ state:
+ min_samples: 1
+ current_connections:
+ min_samples: 1
+ current_producer_count:
+ min_samples: 1
+ current_consumer_count:
+ min_samples: 1
+ producer_count:
+ min_samples: 1
+ consumer_count:
+ min_samples: 1
+ enqueue_count:
+ min_samples: 1
+ dequeue_count:
+ min_samples: 1
+ enqueue_rate:
+ min_samples: 1
+ dequeue_rate:
+ min_samples: 1
+ memory_percent_usage:
+ min_samples: 1
+ memory_usage:
+ min_samples: 1
+ memory_limit:
+ min_samples: 1
+ store_percent_usage:
+ min_samples: 1
+ store_limit:
+ min_samples: 1
+ temp_percent_usage:
+ min_samples: 1
+ temp_limit:
+ min_samples: 1
+ average_message_size:
+ min_samples: 1
+ max_message_size:
+ min_samples: 1
+ queue_size:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/activemq/activemq-cluster.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/activemq/activemq-cluster.data.yaml
new file mode 100644
index 0000000000..9ae30243f2
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/activemq/activemq-cluster.data.yaml
@@ -0,0 +1,144 @@
+# 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.
+
+input:
+ java_lang_OperatingSystem_SystemLoadAverage:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ tags:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ java_lang_Threading_ThreadCount:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_Memory_HeapMemoryUsage_init:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_Memory_HeapMemoryUsage_committed:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_Memory_HeapMemoryUsage_used:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_Memory_HeapMemoryUsage_max:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_G1_Old_Generation_CollectionCount:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_G1_Young_Generation_CollectionCount:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_G1_Old_Generation_CollectionTime:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_G1_Young_Generation_CollectionTime:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_GarbageCollector_CollectionCount:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ java_lang_GarbageCollector_CollectionTime:
+ - labels:
+ cluster: test-cluster
+ service_instance_id: test-instance
+ value: 100.0
+ org_apache_activemq_Broker_TotalEnqueueCount:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ org_apache_activemq_Broker_TotalDequeueCount:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ org_apache_activemq_Broker_DispatchCount:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ org_apache_activemq_Broker_ExpiredCount:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ org_apache_activemq_Broker_AverageEnqueueTime:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ org_apache_activemq_Broker_MaxEnqueueTime:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+expected:
+ system_load_average:
+ min_samples: 1
+ thread_count:
+ min_samples: 1
+ heap_memory_usage_init:
+ min_samples: 1
+ heap_memory_usage_committed:
+ min_samples: 1
+ heap_memory_usage_used:
+ min_samples: 1
+ heap_memory_usage_max:
+ min_samples: 1
+ gc_g1_old_collection_count:
+ min_samples: 1
+ gc_g1_young_collection_count:
+ min_samples: 1
+ gc_g1_old_collection_time:
+ min_samples: 1
+ gc_g1_young_collection_time:
+ min_samples: 1
+ gc_parallel_old_collection_count:
+ min_samples: 1
+ gc_parallel_young_collection_count:
+ min_samples: 1
+ gc_parallel_old_collection_time:
+ min_samples: 1
+ gc_parallel_young_collection_time:
+ min_samples: 1
+ enqueue_rate:
+ min_samples: 1
+ dequeue_rate:
+ min_samples: 1
+ dispatch_rate:
+ min_samples: 1
+ expired_rate:
+ min_samples: 1
+ average_enqueue_time:
+ min_samples: 1
+ max_enqueue_time:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/activemq/activemq-destination.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/activemq/activemq-destination.data.yaml
new file mode 100644
index 0000000000..d44fce6d6f
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/activemq/activemq-destination.data.yaml
@@ -0,0 +1,131 @@
+# 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.
+
+input:
+ org_apache_activemq_Broker_ProducerCount:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_ConsumerCount:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_QueueSize:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_MemoryUsageByteCount:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_MemoryPercentUsage:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_EnqueueCount:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_DequeueCount:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_AverageEnqueueTime:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_MaxEnqueueTime:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_DispatchCount:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_ExpiredCount:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_InFlightCount:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_AverageMessageSize:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+ org_apache_activemq_Broker_MaxMessageSize:
+ - labels:
+ cluster: test-cluster
+ destinationName: test-destination
+ destinationType: Topic
+ value: 100.0
+expected:
+ producer_count:
+ min_samples: 1
+ consumer_count:
+ min_samples: 1
+ topic_consumer_count:
+ min_samples: 1
+ queue_size:
+ min_samples: 1
+ memory_usage:
+ min_samples: 1
+ memory_percent_usage:
+ min_samples: 1
+ enqueue_count:
+ min_samples: 1
+ dequeue_count:
+ min_samples: 1
+ average_enqueue_time:
+ min_samples: 1
+ max_enqueue_time:
+ min_samples: 1
+ dispatch_count:
+ min_samples: 1
+ expired_count:
+ min_samples: 1
+ inflight_count:
+ min_samples: 1
+ average_message_size:
+ min_samples: 1
+ max_message_size:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/apisix.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/apisix.data.yaml
new file mode 100644
index 0000000000..5e8d2cff95
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/apisix.data.yaml
@@ -0,0 +1,76 @@
+# 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.
+
+input:
+ tags:
+ - labels:
+ service_name: test-service
+ skywalking_service: test-sw-service
+ route: test-route
+ node: test-node
+ value: 100.0
+expected:
+ sv_http_connections:
+ min_samples: 1
+ sv_http_requests:
+ min_samples: 1
+ sv_bandwidth_unmatched:
+ min_samples: 1
+ sv_http_status_unmatched:
+ min_samples: 1
+ sv_http_latency_unmatched:
+ min_samples: 1
+ sv_bandwidth_matched:
+ min_samples: 1
+ sv_http_status_matched:
+ min_samples: 1
+ sv_http_latency_matched:
+ min_samples: 1
+ instance_shared_dict_capacity_bytes:
+ min_samples: 1
+ instance_shared_dict_free_space_bytes:
+ min_samples: 1
+ instance_etcd_indexes:
+ min_samples: 1
+ instance_etcd_reachable:
+ min_samples: 1
+ instance_http_connections:
+ min_samples: 1
+ instance_http_requests:
+ min_samples: 1
+ instance_bandwidth_matched:
+ min_samples: 1
+ instance_http_status_matched:
+ min_samples: 1
+ instance_http_latency_matched:
+ min_samples: 1
+ instance_bandwidth_unmatched:
+ min_samples: 1
+ instance_http_status_unmatched:
+ min_samples: 1
+ instance_http_latency_unmatched:
+ min_samples: 1
+ endpoint_http_status:
+ min_samples: 1
+ endpoint_bandwidth:
+ min_samples: 1
+ endpoint_http_latency:
+ min_samples: 1
+ endpoint_http_status:
+ min_samples: 1
+ endpoint_bandwidth:
+ min_samples: 1
+ endpoint_http_latency:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/aws-dynamodb/dynamodb-endpoint.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/aws-dynamodb/dynamodb-endpoint.data.yaml
new file mode 100644
index 0000000000..ec3c51c7a1
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/aws-dynamodb/dynamodb-endpoint.data.yaml
@@ -0,0 +1,65 @@
+# 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.
+
+input:
+ dynamodb:
+ - labels:
+ host_name: test-host
+ cloud_account_id: 123456789
+ value: 100.0
+ tags:
+ - labels:
+ host_name: test-host
+ cloud_account_id: 123456789
+ value: 100.0
+expected:
+ endpoint_consumed_write_capacity_units:
+ min_samples: 1
+ endpoint_consumed_read_capacity_units:
+ min_samples: 1
+ endpoint_provisioned_read_capacity_units:
+ min_samples: 1
+ endpoint_provisioned_write_capacity_units:
+ min_samples: 1
+ endpoint_get_successful_request_latency:
+ min_samples: 1
+ endpoint_put_successful_request_latency:
+ min_samples: 1
+ endpoint_query_successful_request_latency:
+ min_samples: 1
+ endpoint_scan_successful_request_latency:
+ min_samples: 1
+ endpoint_scan_returned_item_count:
+ min_samples: 1
+ endpoint_query_returned_item_count:
+ min_samples: 1
+ endpoint_time_to_live_deleted_item_count:
+ min_samples: 1
+ endpoint_read_throttled_requests:
+ min_samples: 1
+ endpoint_write_throttled_requests:
+ min_samples: 1
+ endpoint_read_throttle_events:
+ min_samples: 1
+ endpoint_write_throttle_events:
+ min_samples: 1
+ endpoint_read_system_errors:
+ min_samples: 1
+ endpoint_write_system_errors:
+ min_samples: 1
+ endpoint_conditional_check_failed_requests:
+ min_samples: 1
+ endpoint_transaction_conflict:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/aws-dynamodb/dynamodb-service.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/aws-dynamodb/dynamodb-service.data.yaml
new file mode 100644
index 0000000000..2a128c3d02
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/aws-dynamodb/dynamodb-service.data.yaml
@@ -0,0 +1,83 @@
+# 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.
+
+input:
+ dynamodb:
+ - labels:
+ host_name: test-host
+ cloud_account_id: 123456789
+ value: 100.0
+ tags:
+ - labels:
+ host_name: test-host
+ cloud_account_id: 123456789
+ value: 100.0
+expected:
+ account_max_writes:
+ min_samples: 1
+ account_max_reads:
+ min_samples: 1
+ account_max_table_level_writes:
+ min_samples: 1
+ account_max_table_level_reads:
+ min_samples: 1
+ max_provisioned_write_capacity_utilization:
+ min_samples: 1
+ max_provisioned_read_capacity_utilization:
+ min_samples: 1
+ account_provisioned_read_capacity_utilization:
+ min_samples: 1
+ account_provisioned_write_capacity_utilization:
+ min_samples: 1
+ consumed_write_capacity_units:
+ min_samples: 1
+ consumed_read_capacity_units:
+ min_samples: 1
+ provisioned_read_capacity_units:
+ min_samples: 1
+ provisioned_write_capacity_units:
+ min_samples: 1
+ get_successful_request_latency:
+ min_samples: 1
+ put_successful_request_latency:
+ min_samples: 1
+ query_successful_request_latency:
+ min_samples: 1
+ scan_successful_request_latency:
+ min_samples: 1
+ scan_returned_item_count:
+ min_samples: 1
+ query_returned_item_count:
+ min_samples: 1
+ time_to_live_deleted_item_count:
+ min_samples: 1
+ read_throttled_requests:
+ min_samples: 1
+ write_throttled_requests:
+ min_samples: 1
+ read_throttle_events:
+ min_samples: 1
+ write_throttle_events:
+ min_samples: 1
+ read_system_errors:
+ min_samples: 1
+ write_system_errors:
+ min_samples: 1
+ user_errors:
+ min_samples: 1
+ conditional_check_failed_requests:
+ min_samples: 1
+ transaction_conflict:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml b/test/script-cases/scripts/mal/test-otel-rules/aws-eks/eks-cluster.data.yaml
similarity index 55%
copy from test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
copy to test/script-cases/scripts/mal/test-otel-rules/aws-eks/eks-cluster.data.yaml
index 034440ce5e..3641f9600d 100644
--- a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
+++ b/test/script-cases/scripts/mal/test-otel-rules/aws-eks/eks-cluster.data.yaml
@@ -13,4 +13,36 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Refer to examples in config-examples/log-mal.yaml
+input:
+ eks:
+ - labels:
+ cluster: test-cluster
+ ClusterName: test-value
+ value: 100.0
+ cluster:
+ - labels:
+ cluster: test-cluster
+ ClusterName: test-value
+ value: 100.0
+ tags:
+ - labels:
+ cluster: test-cluster
+ ClusterName: test-value
+ value: 100.0
+expected:
+ node_count:
+ min_samples: 1
+ failed_node_count:
+ min_samples: 1
+ namespace_count:
+ min_samples: 1
+ service_count:
+ min_samples: 1
+ net_rx_dropped:
+ min_samples: 1
+ net_rx_error:
+ min_samples: 1
+ net_tx_dropped:
+ min_samples: 1
+ net_tx_error:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/aws-eks/eks-node.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/aws-eks/eks-node.data.yaml
new file mode 100644
index 0000000000..b282e74743
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/aws-eks/eks-node.data.yaml
@@ -0,0 +1,64 @@
+# 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.
+
+input:
+ eks:
+ - labels:
+ cluster: test-cluster
+ ClusterName: test-value
+ value: 100.0
+ cluster:
+ - labels:
+ cluster: test-cluster
+ ClusterName: test-value
+ value: 100.0
+ tags:
+ - labels:
+ cluster: test-cluster
+ ClusterName: test-value
+ value: 100.0
+expected:
+ pod_number:
+ min_samples: 1
+ cpu_utilization:
+ min_samples: 1
+ memory_utilization:
+ min_samples: 1
+ net_rx_bytes:
+ min_samples: 1
+ net_rx_error:
+ min_samples: 1
+ net_tx_bytes:
+ min_samples: 1
+ net_tx_error:
+ min_samples: 1
+ disk_io_write:
+ min_samples: 1
+ disk_io_read:
+ min_samples: 1
+ fs_utilization:
+ min_samples: 1
+ pod_cpu_utilization:
+ min_samples: 1
+ pod_memory_utilization:
+ min_samples: 1
+ pod_net_rx_bytes:
+ min_samples: 1
+ pod_net_rx_error:
+ min_samples: 1
+ pod_net_tx_bytes:
+ min_samples: 1
+ pod_net_tx_error:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml b/test/script-cases/scripts/mal/test-otel-rules/aws-eks/eks-service.data.yaml
similarity index 57%
copy from test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
copy to test/script-cases/scripts/mal/test-otel-rules/aws-eks/eks-service.data.yaml
index 034440ce5e..8d3c47df93 100644
--- a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
+++ b/test/script-cases/scripts/mal/test-otel-rules/aws-eks/eks-service.data.yaml
@@ -13,4 +13,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Refer to examples in config-examples/log-mal.yaml
+input:
+ eks:
+ - labels:
+ cluster: test-cluster
+ ClusterName: test-value
+ value: 100.0
+ cluster:
+ - labels:
+ cluster: test-cluster
+ ClusterName: test-value
+ value: 100.0
+ tags:
+ - labels:
+ cluster: test-cluster
+ ClusterName: test-value
+ value: 100.0
+expected:
+ pod_cpu_utilization:
+ min_samples: 1
+ pod_memory_utilization:
+ min_samples: 1
+ pod_net_rx_bytes:
+ min_samples: 1
+ pod_net_rx_error:
+ min_samples: 1
+ pod_net_tx_bytes:
+ min_samples: 1
+ pod_net_tx_error:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/aws-gateway/gateway-endpoint.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/aws-gateway/gateway-endpoint.data.yaml
new file mode 100644
index 0000000000..bfc5e88232
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/aws-gateway/gateway-endpoint.data.yaml
@@ -0,0 +1,163 @@
+# 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.
+
+input:
+ amazonaws_com_AWS_ApiGateway_4xx_sum:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_5xx_sum:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_DataProcessed_sum:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_4XXError_sum:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_5XXError_sum:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_CacheHitCount_sum:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_CacheHitCount_count:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_CacheMissCount_sum:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_CacheMissCount_count:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_Count:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_IntegrationLatency_sum:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_IntegrationLatency_count:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_Latency_sum:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_Latency_count:
+ - labels:
+ service_name: test-service
+ Method: test-value
+ Resource: test-value
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+expected:
+ 4xx:
+ min_samples: 1
+ 5xx:
+ min_samples: 1
+ DataProcessed:
+ min_samples: 1
+ 4xx:
+ min_samples: 1
+ 5xx:
+ min_samples: 1
+ cache_hit_rate:
+ min_samples: 1
+ cache_miss_rate:
+ min_samples: 1
+ count:
+ min_samples: 1
+ integration_latency:
+ min_samples: 1
+ latency:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/aws-gateway/gateway-service.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/aws-gateway/gateway-service.data.yaml
new file mode 100644
index 0000000000..919cdc4857
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/aws-gateway/gateway-service.data.yaml
@@ -0,0 +1,135 @@
+# 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.
+
+input:
+ amazonaws_com_AWS_ApiGateway_4xx_sum:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_5xx_sum:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_DataProcessed_sum:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_4XXError_sum:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_5XXError_sum:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_CacheHitCount_sum:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_CacheHitCount_count:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_CacheMissCount_sum:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_CacheMissCount_count:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_Count:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_IntegrationLatency_sum:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_IntegrationLatency_count:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_Latency_sum:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+ amazonaws_com_AWS_ApiGateway_Latency_count:
+ - labels:
+ service_name: test-service
+ ApiId: test-value
+ Stage: test-value
+ ApiName: test-value
+ value: 100.0
+expected:
+ 4xx:
+ min_samples: 1
+ 5xx:
+ min_samples: 1
+ data_processed:
+ min_samples: 1
+ 4xx:
+ min_samples: 1
+ 5xx:
+ min_samples: 1
+ cache_hit_rate:
+ min_samples: 1
+ cache_miss_rate:
+ min_samples: 1
+ count:
+ min_samples: 1
+ integration_latency:
+ min_samples: 1
+ latency:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/aws-s3/s3-service.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/aws-s3/s3-service.data.yaml
new file mode 100644
index 0000000000..af67d83910
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/aws-s3/s3-service.data.yaml
@@ -0,0 +1,97 @@
+# 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.
+
+input:
+ amazonaws_com_AWS_S3_4xxErrors_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_5xxErrors_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_BytesDownloaded_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_BytesUploaded_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_TotalRequestLatency_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_TotalRequestLatency_count:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_FirstByteLatency_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_FirstByteLatency_count:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_AllRequests_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_PutRequests_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_GetRequests_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+ amazonaws_com_AWS_S3_DeleteRequests_sum:
+ - labels:
+ bucket: test-value
+ BucketName: test-value
+ value: 100.0
+expected:
+ 4xx:
+ min_samples: 1
+ 5xx:
+ min_samples: 1
+ downloaded_bytes:
+ min_samples: 1
+ uploaded_bytes:
+ min_samples: 1
+ request_latency:
+ min_samples: 1
+ first_latency_bytes:
+ min_samples: 1
+ all_requests:
+ min_samples: 1
+ put_requests:
+ min_samples: 1
+ get_requests:
+ min_samples: 1
+ delete_requests:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/banyandb/banyandb-instance.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/banyandb/banyandb-instance.data.yaml
new file mode 100644
index 0000000000..0d122cfed6
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/banyandb/banyandb-instance.data.yaml
@@ -0,0 +1,195 @@
+# 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.
+
+input:
+ banyandb_measure_total_written:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_stream_tst_total_written:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_system_memory_state:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_system_disk:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_liaison_grpc_total_started:
+ - labels:
+ method: query
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_system_cpu_num:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_liaison_grpc_total_err:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_liaison_grpc_total_stream_msg_sent_err:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_liaison_grpc_total_stream_msg_received_err:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_queue_sub_total_msg_sent_err:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ tags:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_liaison_grpc_total_registry_started:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ up:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ process_cpu_seconds_total:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ process_resident_memory_bytes:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_system_net_state:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_liaison_grpc_total_latency:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_measure_total_file_elements:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_measure_total_merge_loop_started:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_measure_total_merge_latency:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_measure_total_merged_parts:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_measure_inverted_index_total_updates:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_stream_storage_inverted_index_total_term_searchers_started:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_measure_inverted_index_total_doc_count:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_stream_tst_inverted_index_total_updates:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_stream_tst_inverted_index_total_term_searchers_started:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_stream_tst_inverted_index_total_doc_count:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+expected:
+ instance_write_rate:
+ min_samples: 1
+ instance_total_memory:
+ min_samples: 1
+ instance_disk_usage:
+ min_samples: 1
+ instance_query_rate:
+ min_samples: 1
+ instance_total_cpu:
+ min_samples: 1
+ instance_write_and_query_errors_rate:
+ min_samples: 1
+ instance_etcd_operation_rate:
+ min_samples: 1
+ instance_active_instance:
+ min_samples: 1
+ instance_cpu_usage:
+ min_samples: 1
+ instance_rss_memory_usage:
+ min_samples: 1
+ instance_disk_usage_all:
+ min_samples: 1
+ instance_network_usage_recv:
+ min_samples: 1
+ instance_network_usage_sent:
+ min_samples: 1
+ instance_storage_write_rate:
+ min_samples: 1
+ instance_query_latency:
+ min_samples: 1
+ instance_total_data:
+ min_samples: 1
+ instance_merge_file_data:
+ min_samples: 1
+ instance_merge_file_latency:
+ min_samples: 1
+ instance_merge_file_partitions:
+ min_samples: 1
+ instance_series_write_rate:
+ min_samples: 1
+ instance_series_term_search_rate:
+ min_samples: 1
+ instance_total_series:
+ min_samples: 1
+ instance_stream_write_rate:
+ min_samples: 1
+ instance_term_search_rate:
+ min_samples: 1
+ instance_total_document:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/banyandb/banyandb-service.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/banyandb/banyandb-service.data.yaml
new file mode 100644
index 0000000000..c1ead0a9ca
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/banyandb/banyandb-service.data.yaml
@@ -0,0 +1,195 @@
+# 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.
+
+input:
+ banyandb_measure_total_written:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_stream_tst_total_written:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_system_memory_state:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_system_disk:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_liaison_grpc_total_started:
+ - labels:
+ method: query
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_system_cpu_num:
+ - labels:
+ method: query
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_liaison_grpc_total_err:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_liaison_grpc_total_stream_msg_sent_err:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_liaison_grpc_total_stream_msg_received_err:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_queue_sub_total_msg_sent_err:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ tags:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_liaison_grpc_total_registry_started:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ up:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ process_cpu_seconds_total:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ process_resident_memory_bytes:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_system_net_state:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_liaison_grpc_total_latency:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_measure_total_file_elements:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_measure_total_merge_loop_started:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_measure_total_merge_latency:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_measure_total_merged_parts:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_measure_inverted_index_total_updates:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_stream_storage_inverted_index_total_term_searchers_started:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_measure_inverted_index_total_doc_count:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_stream_tst_inverted_index_total_updates:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ banyandb_stream_tst_inverted_index_total_term_searchers_started:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ banyandb_stream_tst_inverted_index_total_doc_count:
+ - labels:
+ group: test-value
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+expected:
+ write_rate:
+ min_samples: 1
+ total_memory:
+ min_samples: 1
+ disk_usage:
+ min_samples: 1
+ query_rate:
+ min_samples: 1
+ total_cpu:
+ min_samples: 1
+ write_and_query_errors_rate:
+ min_samples: 1
+ etcd_operation_rate:
+ min_samples: 1
+ active_instance:
+ min_samples: 1
+ cpu_usage:
+ min_samples: 1
+ rss_memory_usage:
+ min_samples: 1
+ disk_usage_all:
+ min_samples: 1
+ network_usage_recv:
+ min_samples: 1
+ network_usage_sent:
+ min_samples: 1
+ storage_write_rate:
+ min_samples: 1
+ query_latency:
+ min_samples: 1
+ total_data:
+ min_samples: 1
+ merge_file_data:
+ min_samples: 1
+ merge_file_latency:
+ min_samples: 1
+ merge_file_partitions:
+ min_samples: 1
+ series_write_rate:
+ min_samples: 1
+ series_term_search_rate:
+ min_samples: 1
+ total_series:
+ min_samples: 1
+ stream_write_rate:
+ min_samples: 1
+ term_search_rate:
+ min_samples: 1
+ total_document:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/bookkeeper/bookkeeper-cluster.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/bookkeeper/bookkeeper-cluster.data.yaml
new file mode 100644
index 0000000000..19a6de3ce7
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/bookkeeper/bookkeeper-cluster.data.yaml
@@ -0,0 +1,87 @@
+# 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.
+
+input:
+ bookie_ledgers_count:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookie_ledger_writable_dirs:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookie_ledger_dir_data_bookkeeper_ledgers_usage:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookie_entries_count:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookie_write_cache_size:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookie_write_cache_count:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookie_read_cache_size:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookie_read_cache_count:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookie_WRITE_BYTES:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookie_READ_BYTES:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+expected:
+ bookie_ledgers_count:
+ min_samples: 1
+ bookie_ledger_writable_dirs:
+ min_samples: 1
+ bookie_ledger_dir_data_bookkeeper_ledgers_usage:
+ min_samples: 1
+ bookie_entries_count:
+ min_samples: 1
+ bookie_write_cache_size:
+ min_samples: 1
+ bookie_write_cache_count:
+ min_samples: 1
+ bookie_read_cache_size:
+ min_samples: 1
+ bookie_read_cache_count:
+ min_samples: 1
+ bookie_write_rate:
+ min_samples: 1
+ bookie_read_rate:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/bookkeeper/bookkeeper-node.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/bookkeeper/bookkeeper-node.data.yaml
new file mode 100644
index 0000000000..873ba09542
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/bookkeeper/bookkeeper-node.data.yaml
@@ -0,0 +1,186 @@
+# 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.
+
+input:
+ bookkeeper_server_thread_executor_completed:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookkeeper_server_thread_executor_tasks_completed:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookkeeper_server_thread_executor_tasks_rejected:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookkeeper_server_thread_executor_tasks_failed:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookkeeper_server_BookieHighPriorityThread_threads:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookkeeper_server_BookieReadThreadPool_threads:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookkeeper_server_BookieHighPriorityThread_max_queue_size:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ bookkeeper_server_BookieReadThreadPool_max_queue_size:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ jvm_memory_bytes_used:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ jvm_memory_bytes_committed:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ jvm_memory_bytes_init:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ jvm_memory_pool_bytes_used:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ pool: PS_Eden_Space
+ value: 100.0
+ jvm_memory_pool_bytes_committed:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ pool: PS_Eden_Space
+ value: 100.0
+ jvm_memory_pool_bytes_init:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ pool: PS_Eden_Space
+ value: 100.0
+ jvm_buffer_pool_used_bytes:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ pool: PS_Eden_Space
+ value: 100.0
+ jvm_buffer_pool_capacity_bytes:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ pool: PS_Eden_Space
+ value: 100.0
+ jvm_buffer_pool_used_buffers:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ pool: PS_Eden_Space
+ value: 100.0
+ jvm_gc_collection_seconds_count:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ gc: PS Scavenge
+ value: 100.0
+ jvm_gc_collection_seconds_sum:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ gc: PS Scavenge
+ value: 100.0
+ jvm_threads_current:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ jvm_threads_daemon:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ jvm_threads_peak:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+ jvm_threads_deadlocked:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 100.0
+expected:
+ thread_executor_completed:
+ min_samples: 1
+ thread_executor_tasks_completed:
+ min_samples: 1
+ thread_executor_tasks_rejected:
+ min_samples: 1
+ thread_executor_tasks_failed:
+ min_samples: 1
+ high_priority_threads:
+ min_samples: 1
+ read_thread_pool_threads:
+ min_samples: 1
+ high_priority_thread_max_queue_size:
+ min_samples: 1
+ read_thread_pool_max_queue_size:
+ min_samples: 1
+ jvm_memory_used:
+ min_samples: 1
+ jvm_memory_committed:
+ min_samples: 1
+ jvm_memory_init:
+ min_samples: 1
+ jvm_memory_pool_used:
+ min_samples: 1
+ jvm_memory_pool_committed:
+ min_samples: 1
+ jvm_memory_pool_init:
+ min_samples: 1
+ jvm_buffer_pool_used_bytes:
+ min_samples: 1
+ jvm_buffer_pool_capacity_bytes:
+ min_samples: 1
+ jvm_buffer_pool_used_buffers:
+ min_samples: 1
+ jvm_gc_collection_seconds_count:
+ min_samples: 1
+ jvm_gc_collection_seconds_sum:
+ min_samples: 1
+ jvm_threads_current:
+ min_samples: 1
+ jvm_threads_daemon:
+ min_samples: 1
+ jvm_threads_peak:
+ min_samples: 1
+ jvm_threads_deadlocked:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/clickhouse/clickhouse-instance.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/clickhouse/clickhouse-instance.data.yaml
new file mode 100644
index 0000000000..ad5bdccb9c
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/clickhouse/clickhouse-instance.data.yaml
@@ -0,0 +1,327 @@
+# 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.
+
+input:
+ ClickHouseMetrics_VersionInteger:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_OSCPUVirtualTimeMicroseconds:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ tags:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ ClickHouseMetrics_MemoryTracking:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ ClickHouseAsyncMetrics_OSMemoryTotal:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ ClickHouseAsyncMetrics_OSMemoryAvailable:
+ - labels:
+ host_name: test-host
+ value: 100.0
+ ClickHouseAsyncMetrics_Uptime:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_FileOpen:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_TCPConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_MySQLConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_HTTPConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_InterserverConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_PostgreSQLConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_NetworkReceiveBytes:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_NetworkSendBytes:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_Query:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_SelectQuery:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_InsertQuery:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_QueryTimeMicroseconds:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_SelectQueryTimeMicroseconds:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_InsertQueryTimeMicroseconds:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_OtherQueryTimeMicroseconds:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_SlowRead:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_InsertedRows:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_InsertedBytes:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_DelayedInserts:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ReplicatedChecks:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ReplicatedFetch:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ReplicatedSend:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_Merge:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_MergedRows:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_MergedUncompressedBytes:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_Move:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_PartsActive:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_PartMutation:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_KafkaMessagesRead:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_KafkaWrites:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_KafkaConsumers:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_KafkaProducers:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ZooKeeperSession:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ZooKeeperWatch:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_ZooKeeperBytesSent:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_ZooKeeperBytesReceived:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_KeeperAliveConnections:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_KeeperOutstandingRequets:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+expected:
+ instance_version:
+ min_samples: 1
+ instance_cpu_usage:
+ min_samples: 1
+ instance_memory_usage:
+ min_samples: 1
+ instance_memory_available:
+ min_samples: 1
+ instance_uptime:
+ min_samples: 1
+ instance_file_open:
+ min_samples: 1
+ instance_tcp_connections:
+ min_samples: 1
+ instance_mysql_connections:
+ min_samples: 1
+ instance_http_connections:
+ min_samples: 1
+ instance_interserver_connections:
+ min_samples: 1
+ instance_postgresql_connections:
+ min_samples: 1
+ instance_network_receive_bytes:
+ min_samples: 1
+ instance_network_send_bytes:
+ min_samples: 1
+ instance_query:
+ min_samples: 1
+ instance_query_select:
+ min_samples: 1
+ instance_query_insert:
+ min_samples: 1
+ instance_query_select_rate:
+ min_samples: 1
+ instance_query_insert_rate:
+ min_samples: 1
+ instance_querytime_microseconds:
+ min_samples: 1
+ instance_querytime_select_microseconds:
+ min_samples: 1
+ instance_querytime_insert_microseconds:
+ min_samples: 1
+ instance_querytime_other_microseconds:
+ min_samples: 1
+ instance_query_slow:
+ min_samples: 1
+ instance_inserted_rows:
+ min_samples: 1
+ instance_inserted_bytes:
+ min_samples: 1
+ instance_delayed_inserts:
+ min_samples: 1
+ instance_replicated_checks:
+ min_samples: 1
+ instance_replicated_fetch:
+ min_samples: 1
+ instance_replicated_send:
+ min_samples: 1
+ instance_background_merge:
+ min_samples: 1
+ instance_merge_rows:
+ min_samples: 1
+ instance_merge_uncompressed_bytes:
+ min_samples: 1
+ instance_move:
+ min_samples: 1
+ instance_parts_active:
+ min_samples: 1
+ instance_mutations:
+ min_samples: 1
+ instance_kafka_messages_read:
+ min_samples: 1
+ instance_kafka_writes:
+ min_samples: 1
+ instance_kafka_consumers:
+ min_samples: 1
+ instance_kafka_producers:
+ min_samples: 1
+ instance_zookeeper_session:
+ min_samples: 1
+ instance_zookeeper_watch:
+ min_samples: 1
+ instance_zookeeper_bytes_sent:
+ min_samples: 1
+ instance_zookeeper_bytes_received:
+ min_samples: 1
+ instance_keeper_connections_alive:
+ min_samples: 1
+ instance_keeper_outstanding_requests:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/clickhouse/clickhouse-service.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/clickhouse/clickhouse-service.data.yaml
new file mode 100644
index 0000000000..6f64eb909d
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/clickhouse/clickhouse-service.data.yaml
@@ -0,0 +1,287 @@
+# 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.
+
+input:
+ ClickHouseProfileEvents_FileOpen:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_TCPConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_MySQLConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_HTTPConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_InterserverConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_PostgreSQLConnection:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_NetworkReceiveBytes:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_NetworkSendBytes:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_Query:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_SelectQuery:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_InsertQuery:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_QueryTimeMicroseconds:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_SelectQueryTimeMicroseconds:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_InsertQueryTimeMicroseconds:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_OtherQueryTimeMicroseconds:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_SlowRead:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_InsertedRows:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_InsertedBytes:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_DelayedInserts:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ReplicatedChecks:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ReplicatedFetch:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ReplicatedSend:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_Merge:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_MergedRows:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_MergedUncompressedBytes:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_Move:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_PartsActive:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_PartMutation:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_KafkaMessagesRead:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_KafkaWrites:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_KafkaConsumers:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_KafkaProducers:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ZooKeeperSession:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_ZooKeeperWatch:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_ZooKeeperBytesSent:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseProfileEvents_ZooKeeperBytesReceived:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_KeeperAliveConnections:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+ ClickHouseMetrics_KeeperOutstandingRequets:
+ - labels:
+ host_name: test-host
+ service_instance_id: test-instance
+ value: 100.0
+expected:
+ file_open:
+ min_samples: 1
+ tcp_connections:
+ min_samples: 1
+ mysql_connections:
+ min_samples: 1
+ http_connections:
+ min_samples: 1
+ interserver_connections:
+ min_samples: 1
+ postgresql_connections:
+ min_samples: 1
+ network_receive_bytes:
+ min_samples: 1
+ network_send_bytes:
+ min_samples: 1
+ query:
+ min_samples: 1
+ query_select:
+ min_samples: 1
+ query_insert:
+ min_samples: 1
+ query_select_rate:
+ min_samples: 1
+ query_insert_rate:
+ min_samples: 1
+ querytime_microseconds:
+ min_samples: 1
+ querytime_select_microseconds:
+ min_samples: 1
+ querytime_insert_microseconds:
+ min_samples: 1
+ querytime_other_microseconds:
+ min_samples: 1
+ query_slow:
+ min_samples: 1
+ inserted_rows:
+ min_samples: 1
+ inserted_bytes:
+ min_samples: 1
+ delayed_inserts:
+ min_samples: 1
+ replicated_checks:
+ min_samples: 1
+ replicated_fetch:
+ min_samples: 1
+ replicated_send:
+ min_samples: 1
+ background_merge:
+ min_samples: 1
+ merge_rows:
+ min_samples: 1
+ merge_uncompressed_bytes:
+ min_samples: 1
+ move:
+ min_samples: 1
+ parts_active:
+ min_samples: 1
+ mutations:
+ min_samples: 1
+ kafka_messages_read:
+ min_samples: 1
+ kafka_writes:
+ min_samples: 1
+ kafka_consumers:
+ min_samples: 1
+ kafka_producers:
+ min_samples: 1
+ zookeeper_session:
+ min_samples: 1
+ zookeeper_watch:
+ min_samples: 1
+ zookeeper_bytes_sent:
+ min_samples: 1
+ zookeeper_bytes_received:
+ min_samples: 1
+ keeper_connections_alive:
+ min_samples: 1
+ keeper_outstanding_requests:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/elasticsearch/elasticsearch-cluster.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/elasticsearch/elasticsearch-cluster.data.yaml
new file mode 100644
index 0000000000..1e2c87436e
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/elasticsearch/elasticsearch-cluster.data.yaml
@@ -0,0 +1,110 @@
+# 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.
+
+input:
+ elasticsearch_cluster_health_status:
+ - labels:
+ cluster: test-cluster
+ color: green
+ value: 1.0
+ elasticsearch_breakers_tripped:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_cluster_health_number_of_nodes:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_cluster_health_number_of_data_nodes:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_cluster_health_number_of_pending_tasks:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_process_cpu_percent:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_jvm_memory_used_bytes:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_jvm_memory_max_bytes:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ tags:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_process_open_files_count:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_cluster_health_active_primary_shards:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_cluster_health_active_shards:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_cluster_health_initializing_shards:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_cluster_health_delayed_unassigned_shards:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_cluster_health_relocating_shards:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+ elasticsearch_cluster_health_unassigned_shards:
+ - labels:
+ cluster: test-cluster
+ value: 1.0
+expected:
+ health_status:
+ min_samples: 1
+ breakers_tripped:
+ min_samples: 1
+ nodes:
+ min_samples: 1
+ data_nodes:
+ min_samples: 1
+ pending_tasks_total:
+ min_samples: 1
+ cpu_usage_avg:
+ min_samples: 1
+ jvm_memory_used_avg:
+ min_samples: 1
+ open_file_count:
+ min_samples: 1
+ primary_shards_total:
+ min_samples: 1
+ shards_total:
+ min_samples: 1
+ initializing_shards_total:
+ min_samples: 1
+ delayed_unassigned_shards_total:
+ min_samples: 1
+ relocating_shards_total:
+ min_samples: 1
+ unassigned_shards_total:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/elasticsearch/elasticsearch-index.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/elasticsearch/elasticsearch-index.data.yaml
new file mode 100644
index 0000000000..42ffcf0781
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/elasticsearch/elasticsearch-index.data.yaml
@@ -0,0 +1,314 @@
+# 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.
+
+input:
+ elasticsearch_index_stats_indexing_index_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_indexing_index_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_search_query_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_search_query_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_search_fetch_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_search_scroll_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_search_suggest_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_merge_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_flush_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_refresh_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_warmer_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_indexing_delete_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_search_fetch_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_search_scroll_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_search_suggest_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_get_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_merge_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_flush_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_refresh_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_warmer_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_indexing_delete_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_get_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_merge_stopped_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_merge_throttle_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_index_stats_indexing_throttle_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_docs_primary:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_store_size_bytes_primary:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_docs_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_store_size_bytes_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_deleted_docs_primary:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_segment_count_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_segment_memory_bytes_total:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_segment_count_primary:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_segment_memory_bytes_primary:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ value: 100.0
+ elasticsearch_indices_shards_docs:
+ - labels:
+ cluster: test-cluster
+ index: test-value
+ primary: test-value
+ shard: test-value
+ value: 100.0
+expected:
+ stats_indexing_index_total_req_rate:
+ min_samples: 1
+ stats_indexing_index_total_proc_rate:
+ min_samples: 1
+ stats_search_query_total_req_rate:
+ min_samples: 1
+ stats_search_query_total_proc_rate:
+ min_samples: 1
+ stats_merge_total_req_rate:
+ min_samples: 1
+ stats_flush_total_req_rate:
+ min_samples: 1
+ stats_refresh_total_req_rate:
+ min_samples: 1
+ stats_warmer_total_req_rate:
+ min_samples: 1
+ stats_indexing_delete_total_req_rate:
+ min_samples: 1
+ stats_search_fetch_total_req_rate:
+ min_samples: 1
+ stats_search_scroll_total_req_rate:
+ min_samples: 1
+ stats_search_suggest_total_req_rate:
+ min_samples: 1
+ stats_get_total_req_rate:
+ min_samples: 1
+ stats_merge_time_seconds_total:
+ min_samples: 1
+ stats_flush_time_seconds_total:
+ min_samples: 1
+ stats_refresh_time_seconds_total:
+ min_samples: 1
+ stats_warmer_time_seconds_total:
+ min_samples: 1
+ stats_indexing_delete_time_seconds_total:
+ min_samples: 1
+ stats_search_fetch_time_seconds_total:
+ min_samples: 1
+ stats_search_query_time_seconds_total:
+ min_samples: 1
+ stats_search_scroll_time_seconds_total:
+ min_samples: 1
+ stats_search_suggest_time_seconds_total:
+ min_samples: 1
+ stats_indexing_index_time_seconds_total:
+ min_samples: 1
+ stats_get_time_seconds_total:
+ min_samples: 1
+ stats_merge_stopped_time_seconds_total:
+ min_samples: 1
+ stats_merge_throttle_time_seconds_total:
+ min_samples: 1
+ stats_indexing_throttle_time_seconds_total:
+ min_samples: 1
+ search_fetch_avg_time:
+ min_samples: 1
+ search_query_avg_time:
+ min_samples: 1
+ search_scroll_avg_time:
+ min_samples: 1
+ search_suggest_avg_time:
+ min_samples: 1
+ indices_docs_primary:
+ min_samples: 1
+ indices_docs_primary_rate:
+ min_samples: 1
+ indices_store_size_bytes_primary:
+ min_samples: 1
+ indices_docs_total:
+ min_samples: 1
+ indices_docs_total_rate:
+ min_samples: 1
+ indices_store_size_bytes_total:
+ min_samples: 1
+ indices_deleted_docs_primary:
+ min_samples: 1
+ indices_segment_count_total:
+ min_samples: 1
+ indices_segment_memory_bytes_total:
+ min_samples: 1
+ indices_segment_count_primary:
+ min_samples: 1
+ indices_segment_memory_bytes_primary:
+ min_samples: 1
+ indices_shards_docs:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/elasticsearch/elasticsearch-node.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/elasticsearch/elasticsearch-node.data.yaml
new file mode 100644
index 0000000000..eb96f243ab
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/elasticsearch/elasticsearch-node.data.yaml
@@ -0,0 +1,354 @@
+# 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.
+
+input:
+ elasticsearch_process_cpu_percent:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ es_client_node: test-value
+ es_data_node: test-value
+ es_ingest_node: test-value
+ es_master_node: test-value
+ value: 100.0
+ elasticsearch_process_open_files_count:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_filesystem_data_available_bytes:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ mount: test-value
+ value: 100.0
+ elasticsearch_jvm_memory_used_bytes:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_jvm_memory_max_bytes:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_jvm_memory_committed_bytes:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_jvm_memory_pool_peak_used_bytes:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ pool: PS_Eden_Space
+ value: 100.0
+ elasticsearch_jvm_gc_collection_seconds_count:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ gc: PS Scavenge
+ value: 100.0
+ elasticsearch_jvm_gc_collection_seconds_sum:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ gc: PS Scavenge
+ value: 100.0
+ elasticsearch_os_cpu_percent:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_os_load1:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ tags:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ elasticsearch_os_load5:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ elasticsearch_os_load15:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ elasticsearch_indices_translog_operations:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_translog_size_in_bytes:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_breakers_tripped:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ breaker: test-value
+ value: 100.0
+ elasticsearch_breakers_estimated_size_bytes:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ breaker: test-value
+ value: 100.0
+ elasticsearch_filesystem_data_size_bytes:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ mount: test-value
+ value: 100.0
+ elasticsearch_filesystem_io_stats_device_read_size_kilobytes_sum:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ mount: test-value
+ value: 100.0
+ elasticsearch_filesystem_io_stats_device_write_size_kilobytes_sum:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ mount: test-value
+ value: 100.0
+ elasticsearch_transport_tx_size_bytes_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_transport_rx_size_bytes_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_search_query_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_search_query_time_seconds:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_search_fetch_time_seconds:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_search_scroll_time_seconds:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_search_suggest_time_seconds:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_search_fetch_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_indexing_index_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_indexing_index_time_seconds_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_merges_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_refresh_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_flush_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_get_exists_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_get_missing_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_get_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_indexing_delete_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_search_scroll_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_search_suggest_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_docs:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_docs_deleted:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_merges_docs_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_merges_total_size_bytes_total:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_segments_count:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+ elasticsearch_indices_segments_memory_bytes:
+ - labels:
+ cluster: test-cluster
+ name: test-name
+ value: 100.0
+expected:
+ rules:
+ min_samples: 1
+ open_file_count:
+ min_samples: 1
+ all_disk_free_space:
+ min_samples: 1
+ jvm_memory_used:
+ min_samples: 1
+ jvm_memory_nonheap_used:
+ min_samples: 1
+ jvm_memory_heap_used:
+ min_samples: 1
+ jvm_memory_heap_max:
+ min_samples: 1
+ jvm_memory_nonheap_committed:
+ min_samples: 1
+ jvm_memory_heap_committed:
+ min_samples: 1
+ jvm_memory_pool_peak_used:
+ min_samples: 1
+ jvm_gc_count:
+ min_samples: 1
+ jvm_gc_time:
+ min_samples: 1
+ process_cpu_percent:
+ min_samples: 1
+ os_cpu_percent:
+ min_samples: 1
+ os_load1:
+ min_samples: 1
+ os_load5:
+ min_samples: 1
+ os_load15:
+ min_samples: 1
+ indices_translog_operations:
+ min_samples: 1
+ indices_translog_size:
+ min_samples: 1
+ breakers_tripped:
+ min_samples: 1
+ breakers_estimated_size:
+ min_samples: 1
+ disk_usage_percent:
+ min_samples: 1
+ disk_usage:
+ min_samples: 1
+ disk_io_read_bytes:
+ min_samples: 1
+ disk_io_write_bytes:
+ min_samples: 1
+ network_send_bytes:
+ min_samples: 1
+ network_receive_bytes:
+ min_samples: 1
+ indices_search_query_total_req_rate:
+ min_samples: 1
+ indices_search_query_time_seconds_proc_rate:
+ min_samples: 1
+ indices_search_fetch_total_req_rate:
+ min_samples: 1
+ indices_search_fetch_time_seconds:
+ min_samples: 1
+ indices_indexing_index_total_req_rate:
+ min_samples: 1
+ indices_indexing_index_total_proc_rate:
+ min_samples: 1
+ indices_merges_total_req_rate:
+ min_samples: 1
+ indices_refresh_total_req_rate:
+ min_samples: 1
+ indices_flush_total_req_rate:
+ min_samples: 1
+ indices_get_exists_total_req_rate:
+ min_samples: 1
+ indices_get_missing_total_req_rate:
+ min_samples: 1
+ indices_get_total_req_rate:
+ min_samples: 1
+ indices_indexing_delete_total_req_rate:
+ min_samples: 1
+ indices_search_scroll_total_req_rate:
+ min_samples: 1
+ indices_search_suggest_total_req_rate:
+ min_samples: 1
+ indices_docs:
+ min_samples: 1
+ indices_docs_deleted_total:
+ min_samples: 1
+ indices_docs_deleted:
+ min_samples: 1
+ indices_merges_docs_total:
+ min_samples: 1
+ indices_merges_total_size_bytes_total:
+ min_samples: 1
+ segment_count:
+ min_samples: 1
+ segment_memory:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/flink/flink-job.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/flink/flink-job.data.yaml
new file mode 100644
index 0000000000..2b788d74be
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/flink/flink-job.data.yaml
@@ -0,0 +1,127 @@
+# 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.
+
+input:
+ flink_jobmanager_job_numRestarts:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_jobmanager_job_runningTime:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_jobmanager_job_restartingTime:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_jobmanager_job_cancellingTime:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_jobmanager_job_totalNumberOfCheckpoints:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_jobmanager_job_numberOfFailedCheckpoints:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_jobmanager_job_numberOfCompletedCheckpoints:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_jobmanager_job_numberOfInProgressCheckpoints:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_jobmanager_job_lastCheckpointSize:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_jobmanager_job_lastCheckpointDuration:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_operator_currentEmitEventTimeLag:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ operator_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_operator_numRecordsIn:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ operator_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_operator_numRecordsOut:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ operator_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_operator_numBytesInPerSecond:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ operator_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_operator_numBytesOutPerSecond:
+ - labels:
+ cluster: test-cluster
+ flink_job_name: test-value
+ operator_name: test-value
+ value: 100.0
+expected:
+ restart_number:
+ min_samples: 1
+ runningTime:
+ min_samples: 1
+ restartingTime:
+ min_samples: 1
+ cancellingTime:
+ min_samples: 1
+ checkpoints_total:
+ min_samples: 1
+ checkpoints_failed:
+ min_samples: 1
+ checkpoints_completed:
+ min_samples: 1
+ checkpoints_inProgress:
+ min_samples: 1
+ lastCheckpointSize:
+ min_samples: 1
+ lastCheckpointDuration:
+ min_samples: 1
+ currentEmitEventTimeLag:
+ min_samples: 1
+ numRecordsIn:
+ min_samples: 1
+ numRecordsOut:
+ min_samples: 1
+ numBytesInPerSecond:
+ min_samples: 1
+ numBytesOutPerSecond:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/flink/flink-jobManager.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/flink/flink-jobManager.data.yaml
new file mode 100644
index 0000000000..059ee3b4af
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/flink/flink-jobManager.data.yaml
@@ -0,0 +1,149 @@
+# 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.
+
+input:
+ flink_jobmanager_numRunningJobs:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ flink_jobmanager_numRegisteredTaskManagers:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ flink_jobmanager_taskSlotsTotal:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ flink_jobmanager_taskSlotsAvailable:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ flink_jobmanager_Status_JVM_CPU_Load:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ tags:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ flink_jobmanager_Status_JVM_CPU_Time:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_Memory_Heap_Used:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_Memory_Heap_Max:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_Memory_NonHeap_Used:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_Memory_NonHeap_Max:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_Threads_Count:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_Memory_Metaspace_Used:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_Memory_Metaspace_Max:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_GarbageCollector_G1_Young_Generation_Count:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_GarbageCollector_G1_Old_Generation_Count:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_GarbageCollector_G1_Young_Generation_Time:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_GarbageCollector_G1_Old_Generation_Time:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_GarbageCollector_All_Count:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+ flink_jobmanager_Status_JVM_GarbageCollector_All_Time:
+ - labels:
+ cluster: test-cluster
+ jobManager_node: test-value
+ value: 100.0
+expected:
+ running_job_number:
+ min_samples: 1
+ taskManagers_registered_number:
+ min_samples: 1
+ taskManagers_slots_total:
+ min_samples: 1
+ taskManagers_slots_available:
+ min_samples: 1
+ jvm_cpu_load:
+ min_samples: 1
+ jvm_cpu_time:
+ min_samples: 1
+ jvm_memory_heap_used:
+ min_samples: 1
+ jvm_memory_heap_available:
+ min_samples: 1
+ jvm_memory_nonHeap_used:
+ min_samples: 1
+ jvm_memory_nonHeap_available:
+ min_samples: 1
+ jvm_thread_count:
+ min_samples: 1
+ jvm_memory_metaspace_used:
+ min_samples: 1
+ jvm_memory_metaspace_available:
+ min_samples: 1
+ jvm_g1_young_generation_count:
+ min_samples: 1
+ jvm_g1_old_generation_count:
+ min_samples: 1
+ jvm_g1_young_generation_time:
+ min_samples: 1
+ jvm_g1_old_generation_time:
+ min_samples: 1
+ jvm_all_garbageCollector_count:
+ min_samples: 1
+ jvm_all_garbageCollector_time:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/flink/flink-taskManager.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/flink/flink-taskManager.data.yaml
new file mode 100644
index 0000000000..3644786959
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/flink/flink-taskManager.data.yaml
@@ -0,0 +1,190 @@
+# 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.
+
+input:
+ flink_taskmanager_Status_JVM_CPU_Load:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ tags:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ flink_taskmanager_Status_JVM_CPU_Time:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_Status_JVM_Memory_Heap_Used:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_Status_JVM_Memory_Heap_Max:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_Status_JVM_Threads_Count:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_Status_JVM_Memory_Metaspace_Max:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_Status_JVM_Memory_Metaspace_Used:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_Status_JVM_Memory_NonHeap_Used:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_Status_JVM_Memory_NonHeap_Max:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_job_task_numRecordsIn:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ flink_job_name: test-value
+ task_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_numRecordsOut:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ flink_job_name: test-value
+ task_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_numBytesInPerSecond:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ flink_job_name: test-value
+ task_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_numBytesOutPerSecond:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ flink_job_name: test-value
+ task_name: test-value
+ value: 100.0
+ flink_taskmanager_Status_Shuffle_Netty_UsedMemory:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_Status_Shuffle_Netty_AvailableMemory:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ value: 100.0
+ flink_taskmanager_job_task_Shuffle_Netty_Input_Buffers_inPoolUsage:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ flink_taskmanager_job_task_Shuffle_Netty_Output_Buffers_outPoolUsage:
+ - labels:
+ cluster: test-cluster
+ value: 100.0
+ flink_taskmanager_job_task_isBackPressured:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ flink_job_name: test-value
+ task_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_idleTimeMsPerSecond:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ flink_job_name: test-value
+ task_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_busyTimeMsPerSecond:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ flink_job_name: test-value
+ task_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_softBackPressuredTimeMsPerSecond:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ flink_job_name: test-value
+ task_name: test-value
+ value: 100.0
+ flink_taskmanager_job_task_hardBackPressuredTimeMsPerSecond:
+ - labels:
+ cluster: test-cluster
+ taskManager_node: test-value
+ flink_job_name: test-value
+ task_name: test-value
+ value: 100.0
+expected:
+ jvm_cpu_load:
+ min_samples: 1
+ jvm_cpu_time:
+ min_samples: 1
+ jvm_memory_heap_used:
+ min_samples: 1
+ jvm_memory_heap_available:
+ min_samples: 1
+ jvm_thread_count:
+ min_samples: 1
+ jvm_memory_metaspace_available:
+ min_samples: 1
+ jvm_memory_metaspace_used:
+ min_samples: 1
+ jvm_memory_nonHeap_used:
+ min_samples: 1
+ jvm_memory_nonHeap_available:
+ min_samples: 1
+ numRecordsIn:
+ min_samples: 1
+ numRecordsOut:
+ min_samples: 1
+ numBytesInPerSecond:
+ min_samples: 1
+ numBytesOutPerSecond:
+ min_samples: 1
+ netty_usedMemory:
+ min_samples: 1
+ netty_availableMemory:
+ min_samples: 1
+ inPoolUsage:
+ min_samples: 1
+ outPoolUsage:
+ min_samples: 1
+ isBackPressured:
+ min_samples: 1
+ idleTimeMsPerSecond:
+ min_samples: 1
+ busyTimeMsPerSecond:
+ min_samples: 1
+ softBackPressuredTimeMsPerSecond:
+ min_samples: 1
+ hardBackPressuredTimeMsPerSecond:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/istio-controlplane.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/istio-controlplane.data.yaml
new file mode 100644
index 0000000000..dfcd7a02da
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/istio-controlplane.data.yaml
@@ -0,0 +1,250 @@
+# 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.
+
+input:
+ istio_build:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ tag: 1.19.0
+ value: 100.0
+ process_virtual_memory_bytes:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ process_resident_memory_bytes:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ go_memstats_alloc_bytes:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ go_memstats_heap_inuse_bytes:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ go_memstats_stack_inuse_bytes:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ process_cpu_seconds_total:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ go_goroutines:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_xds_pushes:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ type: lds
+ value: 100.0
+ pilot_xds_cds_reject:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_xds_eds_reject:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_xds_rds_reject:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_xds_lds_reject:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_xds_write_timeout:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_total_xds_internal_errors:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_total_xds_rejects:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_xds_push_context_errors:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_xds_push_timeout:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_proxy_convergence_time:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ le: '50'
+ value: 10.0
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ le: '100'
+ value: 20.0
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ le: '250'
+ value: 30.0
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ le: '500'
+ value: 40.0
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ le: '1000'
+ value: 50.0
+ pilot_conflict_inbound_listener:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_conflict_outbound_listener_http_over_current_tcp:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_conflict_outbound_listener_tcp_over_current_tcp:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_conflict_outbound_listener_tcp_over_current_http:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_virt_services:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_services:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ pilot_xds:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ galley_validation_passed:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ galley_validation_failed:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ sidecar_injection_success_total:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+ sidecar_injection_failure_total:
+ - labels:
+ cluster: test-cluster
+ app: istiod
+ value: 100.0
+expected:
+ pilot_version:
+ min_samples: 1
+ virtual_memory:
+ min_samples: 1
+ resident_memory:
+ min_samples: 1
+ go_alloc:
+ min_samples: 1
+ go_heap_inuse:
+ min_samples: 1
+ go_stack_inuse:
+ min_samples: 1
+ cpu:
+ min_samples: 1
+ go_goroutines:
+ min_samples: 1
+ pilot_xds_pushes:
+ min_samples: 1
+ pilot_xds_cds_reject:
+ min_samples: 1
+ pilot_xds_eds_reject:
+ min_samples: 1
+ pilot_xds_rds_reject:
+ min_samples: 1
+ pilot_xds_lds_reject:
+ min_samples: 1
+ pilot_xds_write_timeout:
+ min_samples: 1
+ pilot_total_xds_internal_errors:
+ min_samples: 1
+ pilot_total_xds_rejects:
+ min_samples: 1
+ pilot_xds_push_context_errors:
+ min_samples: 1
+ pilot_xds_push_timeout:
+ min_samples: 1
+ pilot_proxy_push_percentile:
+ min_samples: 1
+ pilot_conflict_il:
+ min_samples: 1
+ pilot_conflict_ol_http_tcp:
+ min_samples: 1
+ pilot_conflict_ol_tcp_tcp:
+ min_samples: 1
+ pilot_conflict_ol_tcp_http:
+ min_samples: 1
+ pilot_virt_services:
+ min_samples: 1
+ pilot_services:
+ min_samples: 1
+ pilot_xds:
+ min_samples: 1
+ galley_validation_passed:
+ min_samples: 1
+ galley_validation_failed:
+ min_samples: 1
+ sidecar_injection_success_total:
+ min_samples: 1
+ sidecar_injection_failure_total:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-cluster.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-cluster.data.yaml
new file mode 100644
index 0000000000..7787760b4a
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-cluster.data.yaml
@@ -0,0 +1,174 @@
+# 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.
+
+input:
+ kube_node_status_capacity:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_node_status_allocatable:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_pod_container_resource_requests:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_pod_container_resource_limits:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_node_info:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_node_status_condition:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ condition: Available
+ remove: test-value
+ value: 1.0
+ kube_namespace_labels:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_deployment_labels:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_deployment_status_condition:
+ - labels:
+ cluster: test-cluster
+ deployment: test-value
+ namespace: test-namespace
+ condition: Available
+ status: 'true'
+ remove: test-value
+ value: 1.0
+ kube_deployment_spec_replicas:
+ - labels:
+ cluster: test-cluster
+ deployment: test-value
+ namespace: test-namespace
+ remove: test-value
+ value: 1.0
+ kube_statefulset_labels:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_daemonset_labels:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_service_info:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_pod_status_phase:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ phase: test-value
+ pod: test-pod
+ remove: test-value
+ value: 1.0
+ kube_pod_info:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_pod_container_info:
+ - labels:
+ cluster: test-cluster
+ remove: test-value
+ value: 1.0
+ kube_pod_container_status_waiting_reason:
+ - labels:
+ cluster: test-cluster
+ pod: test-pod
+ container: test-container
+ reason: test-value
+ remove: test-value
+ value: 1.0
+ kube_pod_container_status_terminated_reason:
+ - labels:
+ cluster: test-cluster
+ pod: test-pod
+ container: test-container
+ reason: test-value
+ remove: test-value
+ value: 1.0
+expected:
+ cpu_cores:
+ min_samples: 1
+ cpu_cores_allocatable:
+ min_samples: 1
+ cpu_cores_requests:
+ min_samples: 1
+ cpu_cores_limits:
+ min_samples: 1
+ memory_total:
+ min_samples: 1
+ memory_allocatable:
+ min_samples: 1
+ memory_requests:
+ min_samples: 1
+ memory_limits:
+ min_samples: 1
+ storage_total:
+ min_samples: 1
+ storage_allocatable:
+ min_samples: 1
+ node_total:
+ min_samples: 1
+ node_status:
+ min_samples: 1
+ namespace_total:
+ min_samples: 1
+ deployment_total:
+ min_samples: 1
+ deployment_status:
+ min_samples: 1
+ deployment_spec_replicas:
+ min_samples: 1
+ statefulset_total:
+ min_samples: 1
+ daemonset_total:
+ min_samples: 1
+ service_total:
+ min_samples: 1
+ service_pod_status:
+ min_samples: 1
+ pod_total:
+ min_samples: 1
+ pod_status_not_running:
+ min_samples: 1
+ container_total:
+ min_samples: 1
+ pod_status_waiting:
+ min_samples: 1
+ pod_status_terminated:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml b/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-instance.data.yaml
similarity index 77%
copy from test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
copy to test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-instance.data.yaml
index 034440ce5e..eb71143ad1 100644
--- a/test/script-cases/scripts/mal/test-log-mal-rules/placeholder.yaml
+++ b/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-instance.data.yaml
@@ -13,4 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Refer to examples in config-examples/log-mal.yaml
+input:
+ kube_pod_status_phase:
+ - labels:
+ cluster: test-cluster
+ namespace: test-namespace
+ service: test-service
+ pod: test-pod
+ value: 100.0
+expected:
+ pod_instance_status:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-node.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-node.data.yaml
new file mode 100644
index 0000000000..a139c2da38
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-node.data.yaml
@@ -0,0 +1,100 @@
+# 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.
+
+input:
+ kube_node_status_capacity:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 1.0
+ container_cpu_usage_seconds_total:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 1.0
+ kube_node_status_allocatable:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 1.0
+ kube_pod_container_resource_requests:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 1.0
+ kube_pod_container_resource_limits:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 1.0
+ container_memory_working_set_bytes:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 1.0
+ kube_node_status_condition:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ condition: test-value
+ value: 1.0
+ kube_pod_info:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 1.0
+ container_network_receive_bytes_total:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 1.0
+ container_network_transmit_bytes_total:
+ - labels:
+ cluster: test-cluster
+ node: test-node
+ value: 1.0
+expected:
+ cpu_cores:
+ min_samples: 1
+ cpu_usage:
+ min_samples: 1
+ cpu_cores_allocatable:
+ min_samples: 1
+ cpu_cores_requests:
+ min_samples: 1
+ cpu_cores_limits:
+ min_samples: 1
+ memory_total:
+ min_samples: 1
+ memory_allocatable:
+ min_samples: 1
+ memory_requests:
+ min_samples: 1
+ memory_limits:
+ min_samples: 1
+ memory_usage:
+ min_samples: 1
+ storage_total:
+ min_samples: 1
+ storage_allocatable:
+ min_samples: 1
+ node_status:
+ min_samples: 1
+ pod_total:
+ min_samples: 1
+ network_receive:
+ min_samples: 1
+ network_transmit:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-service.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-service.data.yaml
new file mode 100644
index 0000000000..fe79be219c
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/k8s/k8s-service.data.yaml
@@ -0,0 +1,95 @@
+# 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.
+
+input:
+ kube_pod_info:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ value: 1.0
+ kube_pod_container_resource_requests:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ value: 1.0
+ kube_pod_container_resource_limits:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ value: 1.0
+ kube_pod_status_phase:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ pod: test-pod
+ phase: test-value
+ value: 1.0
+ kube_pod_container_status_waiting_reason:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ pod: test-pod
+ container: test-container
+ reason: test-value
+ value: 1.0
+ kube_pod_container_status_terminated_reason:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ pod: test-pod
+ container: test-container
+ reason: test-value
+ value: 1.0
+ kube_pod_container_status_restarts_total:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ pod: test-pod
+ value: 1.0
+ container_cpu_usage_seconds_total:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ pod: test-pod
+ value: 1.0
+ container_memory_working_set_bytes:
+ - labels:
+ cluster: test-cluster
+ service: test-service
+ pod: test-pod
+ value: 1.0
+expected:
+ pod_total:
+ min_samples: 1
+ cpu_cores_requests:
+ min_samples: 1
+ cpu_cores_limits:
+ min_samples: 1
+ memory_requests:
+ min_samples: 1
+ memory_limits:
+ min_samples: 1
+ pod_status:
+ min_samples: 1
+ pod_status_waiting:
+ min_samples: 1
+ pod_status_terminated:
+ min_samples: 1
+ pod_status_restarts_total:
+ min_samples: 1
+ pod_cpu_usage:
+ min_samples: 1
+ pod_memory_usage:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/kafka/kafka-broker.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/kafka/kafka-broker.data.yaml
new file mode 100644
index 0000000000..a264e02287
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/kafka/kafka-broker.data.yaml
@@ -0,0 +1,209 @@
+# 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.
+
+input:
+ process_cpu_seconds_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ jvm_memory_bytes_used:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ area: heap
+ value: 100.0
+ jvm_memory_bytes_max:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ area: heap
+ value: 100.0
+ kafka_server_brokertopicmetrics_messagesin_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ topic: test-topic
+ value: 100.0
+ kafka_server_brokertopicmetrics_bytesin_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_brokertopicmetrics_bytesout_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ topic: test-topic
+ value: 100.0
+ kafka_server_brokertopicmetrics_replicationbytesin_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_brokertopicmetrics_replicationbytesout_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicamanager_underreplicatedpartitions:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicamanager_underminisrpartitioncount:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicamanager_partitioncount:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicamanager_leadercount:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicamanager_isrshrinks_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicamanager_isrexpands_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicafetchermanager_maxlag:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_delayedoperationpurgatory_purgatorysize:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ delayedOperation: test-value
+ value: 100.0
+ jvm_gc_collection_seconds_count:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ gc: PS Scavenge
+ value: 100.0
+ kafka_network_requestmetrics_requests_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ request: test-value
+ value: 100.0
+ kafka_network_requestmetrics_requestqueuetimems_count:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ request: test-value
+ value: 100.0
+ kafka_network_requestmetrics_remotetimems_count:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ request: test-value
+ value: 100.0
+ kafka_network_requestmetrics_responsequeuetimems_count:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ request: test-value
+ value: 100.0
+ kafka_network_requestmetrics_responsesendtimems_count:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ request: test-value
+ value: 100.0
+ kafka_network_socketserver_networkprocessoravgidlepercent:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_brokertopicmetrics_totalfetchrequests_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ topic: test-topic
+ value: 100.0
+ kafka_server_brokertopicmetrics_totalproducerequests_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ topic: test-topic
+ value: 100.0
+expected:
+ cpu_time_total:
+ min_samples: 1
+ memory_usage_percentage:
+ min_samples: 1
+ messages_per_second:
+ min_samples: 1
+ bytes_in_per_second:
+ min_samples: 1
+ bytes_out_per_second:
+ min_samples: 1
+ replication_bytes_in_per_second:
+ min_samples: 1
+ replication_bytes_out_per_second:
+ min_samples: 1
+ under_replicated_partitions:
+ min_samples: 1
+ under_min_isr_partition_count:
+ min_samples: 1
+ partition_count:
+ min_samples: 1
+ leader_count:
+ min_samples: 1
+ isr_shrinks_per_second:
+ min_samples: 1
+ isr_expands_per_second:
+ min_samples: 1
+ max_lag:
+ min_samples: 1
+ purgatory_size:
+ min_samples: 1
+ garbage_collector_count:
+ min_samples: 1
+ requests_per_second:
+ min_samples: 1
+ request_queue_time_ms:
+ min_samples: 1
+ remote_time_ms:
+ min_samples: 1
+ response_queue_time_ms:
+ min_samples: 1
+ response_send_time_ms:
+ min_samples: 1
+ network_processor_avg_idle_percent:
+ min_samples: 1
+ topic_messages_in_total:
+ min_samples: 1
+ topic_bytesout_per_second:
+ min_samples: 1
+ topic_bytesin_per_second:
+ min_samples: 1
+ topic_fetch_requests_per_second:
+ min_samples: 1
+ topic_produce_requests_per_second:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/kafka/kafka-cluster.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/kafka/kafka-cluster.data.yaml
new file mode 100644
index 0000000000..2c1870810a
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/kafka/kafka-cluster.data.yaml
@@ -0,0 +1,73 @@
+# 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.
+
+input:
+ kafka_server_replicamanager_underreplicatedpartitions:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_controller_kafkacontroller_offlinepartitionscount:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicamanager_partitioncount:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicamanager_leadercount:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_controller_kafkacontroller_activecontrollercount:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_controller_controllerstats_leaderelectionrateandtimems_count:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_controller_controllerstats_uncleanleaderelections_total:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+ kafka_server_replicafetchermanager_maxlag:
+ - labels:
+ cluster: test-cluster
+ broker: test-broker
+ value: 100.0
+expected:
+ under_replicated_partitions:
+ min_samples: 1
+ offline_partitions_count:
+ min_samples: 1
+ partition_count:
+ min_samples: 1
+ leader_count:
+ min_samples: 1
+ active_controller_count:
+ min_samples: 1
+ leader_election_rate:
+ min_samples: 1
+ unclean_leader_elections_per_second:
+ min_samples: 1
+ max_lag:
+ min_samples: 1
diff --git a/test/script-cases/scripts/mal/test-otel-rules/kong/kong-endpoint.data.yaml b/test/script-cases/scripts/mal/test-otel-rules/kong/kong-endpoint.data.yaml
new file mode 100644
index 0000000000..4e4f737166
--- /dev/null
+++ b/test/script-cases/scripts/mal/test-otel-rules/kong/kong-endpoint.data.yaml
@@ -0,0 +1,117 @@
+# 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
... 3873 lines suppressed ...