You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug and provide the minimal reproduce step
I got some error while trying to add a trigger with quite litterally the documentation provided example:
ClusterAlertingExample.java File
/* * 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. */packageorg.apache.iotdb.trigger;
importorg.apache.iotdb.db.engine.trigger.sink.alertmanager.AlertManagerConfiguration;
importorg.apache.iotdb.db.engine.trigger.sink.alertmanager.AlertManagerEvent;
importorg.apache.iotdb.db.engine.trigger.sink.alertmanager.AlertManagerHandler;
importorg.apache.iotdb.trigger.api.Trigger;
importorg.apache.iotdb.trigger.api.TriggerAttributes;
importorg.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
importorg.apache.iotdb.tsfile.write.record.Tablet;
importorg.apache.iotdb.tsfile.write.schema.MeasurementSchema;
importjava.io.IOException;
importjava.util.HashMap;
importjava.util.List;
publicclassClusterAlertingExampleimplementsTrigger {
privatefinalAlertManagerHandleralertManagerHandler = newAlertManagerHandler();
privatefinalAlertManagerConfigurationalertManagerConfiguration =
newAlertManagerConfiguration("http://127.0.0.1:9093/api/v2/alerts");
privateStringalertname;
privatefinalHashMap<String, String> labels = newHashMap<>();
privatefinalHashMap<String, String> annotations = newHashMap<>();
@OverridepublicvoidonCreate(TriggerAttributesattributes) throwsException {
alertname = "alert_test";
labels.put("series", "root.Firewall");
labels.put("value", "");
labels.put("severity", "");
annotations.put("summary", "high temperature");
annotations.put("description", "{{.alertname}}: {{.series}} is {{.value}}");
alertManagerHandler.open(alertManagerConfiguration);
}
@OverridepublicvoidonDrop() throwsIOException {
alertManagerHandler.close();
}
@Overridepublicbooleanfire(Tablettablet) throwsException {
List<MeasurementSchema> measurementSchemaList = tablet.getSchemas();
for (inti = 0, n = measurementSchemaList.size(); i < n; i++) {
if (measurementSchemaList.get(i).getType().equals(TSDataType.DOUBLE)) {
// for example, we only deal with the columns of Double typedouble[] values = (double[]) tablet.values[i];
for (doublevalue : values) {
if (value > 100.0) {
labels.put("value", String.valueOf(value));
labels.put("severity", "critical");
AlertManagerEventalertManagerEvent =
newAlertManagerEvent(alertname, labels, annotations);
alertManagerHandler.onEvent(alertManagerEvent);
} elseif (value > 50.0) {
labels.put("value", String.valueOf(value));
labels.put("severity", "warning");
AlertManagerEventalertManagerEvent =
newAlertManagerEvent(alertname, labels, annotations);
alertManagerHandler.onEvent(alertManagerEvent);
}
}
}
}
returntrue;
}
}
pom.xml File
<?xml version="1.0" encoding="UTF-8"?>
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>apache.iotdb</groupId>
<artifactId>cluster_alerting</artifactId>
<version>1.0-SNAPSHOT</version>
<name>cluster_alerting</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-server</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</project>
I have builded the jar file using mvn compile -> mvn package command
Then using the jar tvf command i got this output:
93 Thu Feb 22 09:48:48 UTC 2024 META-INF/MANIFEST.MF
0 Thu Feb 22 09:48:48 UTC 2024 META-INF/
0 Thu Feb 22 09:47:38 UTC 2024 org/
0 Thu Feb 22 09:47:38 UTC 2024 org/apache/
0 Thu Feb 22 09:47:38 UTC 2024 org/apache/iotdb/
0 Thu Feb 22 09:47:40 UTC 2024 org/apache/iotdb/trigger/
0 Thu Feb 22 09:48:48 UTC 2024 META-INF/maven/
0 Thu Feb 22 09:48:48 UTC 2024 META-INF/maven/apache.iotdb/
0 Thu Feb 22 09:48:48 UTC 2024 META-INF/maven/apache.iotdb/cluster_alerting/
3835 Thu Feb 22 09:48:40 UTC 2024 org/apache/iotdb/trigger/ClusterAlertingExample.class
2905 Thu Feb 22 09:47:34 UTC 2024 META-INF/maven/apache.iotdb/cluster_alerting/pom.xml
101 Thu Feb 22 09:48:48 UTC 2024 META-INF/maven/apache.iotdb/cluster_alerting/pom.properties
As you can see i have a java class called org/apache/iotdb/trigger/ClusterAlertingExample.class
but on IoTDB while i try to create the trigger i got this error:
IoTDB> CREATE STATELESS TRIGGER test> BEFORE INSERT
> ON root.Firewall.**> AS 'org.apache.iotdb.trigger.ClusterAlertingExample'> USING URI 'file:///home/sean/apache-iotdb/ext/trigger/install/cluster_alerting-1.0-SNAPSHOT.jar'
Msg: 1303: Failed to load class 'org.apache.iotdb.trigger.ClusterAlertingExample', because it's not found in jar file: file:///home/sean/apache-iotdb/ext/trigger/install/cluster_alerting-1.0-SNAPSHOT.jar
What did you expect to see?
I'll expect to see a succesfully statement while execute the CREATE STATELESS TRIGGER function
IoTDB> CREATE STATELESS TRIGGER test> BEFORE INSERT
> ON root.Firewall.**> AS 'org.apache.iotdb.trigger.ClusterAlertingExample'> USING URI 'file:///home/sean/apache-iotdb/ext/trigger/install/cluster_alerting-1.0-SNAPSHOT.jar'
Msg: The statement is executed successfully.
What did you see instead?
I got an error statement while execute the CREATE STATELESS TRIGGER function saying that the class is missing in the jar file
IoTDB> CREATE STATELESS TRIGGER test> BEFORE INSERT
> ON root.Firewall.**> AS 'org.apache.iotdb.trigger.ClusterAlertingExample'> USING URI 'file:///home/sean/apache-iotdb/ext/trigger/install/cluster_alerting-1.0-SNAPSHOT.jar'
Msg: 1303: Failed to load class 'org.apache.iotdb.trigger.ClusterAlertingExample', because it's not found in jar file: file:///home/sean/apache-iotdb/ext/trigger/install/cluster_alerting-1.0-SNAPSHOT.jar
Anything else?
No response
Are you willing to submit a PR?
I'm willing to submit a PR!
The text was updated successfully, but these errors were encountered:
Search before asking
Version
Describe the bug and provide the minimal reproduce step
I got some error while trying to add a trigger with quite litterally the documentation provided example:
ClusterAlertingExample.java File
pom.xml File
The schema file is like this
i'm missing something?
################################################################################################
mvn compile
->mvn package
commandjar tvf
command i got this output:As you can see i have a java class called
org/apache/iotdb/trigger/ClusterAlertingExample.class
but on IoTDB while i try to create the trigger i got this error:
What did you expect to see?
I'll expect to see a succesfully statement while execute the CREATE STATELESS TRIGGER function
What did you see instead?
I got an error statement while execute the CREATE STATELESS TRIGGER function saying that the class is missing in the jar file
Anything else?
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: