Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NIFI-6583: adding azure log analytics reporting task to nifi-azure-bu… #3817

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions nifi-nar-bundles/nifi-azure-bundle/nifi-azure-nar/pom.xml
Expand Up @@ -35,13 +35,17 @@
<artifactId>nifi-azure-processors</artifactId>
<version>1.10.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-azure-reporting-task</artifactId>
<version>1.10.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-azure-services-api-nar</artifactId>
<version>1.10.0-SNAPSHOT</version>
<type>nar</type>
</dependency>
</dependency>
</dependencies>

</project>
Expand Up @@ -83,7 +83,6 @@
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-distributed-cache-client-service-api</artifactId>
<scope>test</scope>
sjyang18 marked this conversation as resolved.
Show resolved Hide resolved
</dependency>
</dependencies>
<build>
Expand Down
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 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. -->
<project xmlns="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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-azure-bundle</artifactId>
<version>1.10.0-SNAPSHOT</version>
</parent>
<artifactId>nifi-azure-reporting-task</artifactId>
<packaging>jar</packaging>

<properties>
<nifi.version>1.10.0-SNAPSHOT</nifi.version>
</properties>

<dependencies>

<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>
<version>${nifi.version}</version>
sjyang18 marked this conversation as resolved.
Show resolved Hide resolved
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
<version>${nifi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-metrics</artifactId>
<version>${nifi.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-mock</artifactId>
<version>${nifi.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

Large diffs are not rendered by default.

@@ -0,0 +1,54 @@
/*
* 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.nifi.reporting.azure.loganalytics;

public class Metric {
public static final String CATEGORY_DATAFLOW = "DataFlow";
public static final String CATEGORY_CONNECTIONS = "Connections";
public static final String CATEGORY_PROCESSOR = "Processor";
public static final String CATEGORY_JVM = "JvmMetrics";


public Metric(String instanceId, String processGroupId, String processGroupName ) {
Computer = instanceId;
ProcessGroupName = processGroupName;
ProcessGroupId = processGroupId;
}

public void setCount(long value){
this.Count = Long.valueOf((long)value);
}
public void setCount(double value){
this.Count = Long.valueOf((long)value);
}
public void setCount(int value){
this.Count = Long.valueOf((long)value);
}
public void setTags(String tags){
this.Tags = tags;
}

public String Computer;
public String ProcessGroupId;
public String ProcessGroupName;
public String ProcessorId;
public String ProcessorName;
public Long Count;
public String Name;
public String CategoryName;
public String Tags;
sjyang18 marked this conversation as resolved.
Show resolved Hide resolved
}
@@ -0,0 +1,66 @@
/*
* 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.nifi.reporting.azure.loganalytics;

/**
* The Metric names to send to Azure Log Analytics.
*/
public interface MetricNames {

// Metric Name separator
String METRIC_NAME_SEPARATOR = ".";

// NiFi Metrics
String FLOW_FILES_RECEIVED = "FlowFilesReceived";
String FLOW_FILES_TRANSFERRED = "FlowFilesTransferred";
String BYTES_RECEIVED = "BytesReceived";
String FLOW_FILES_SENT = "FlowFilesSent";
String BYTES_SENT = "BytesSent";
String FLOW_FILES_QUEUED = "FlowFilesQueued";
String BYTES_TRANSFERRED= "BytesTransferred";
String BYTES_QUEUED= "BytesQueued";
String BYTES_READ = "BytesRead";
String BYTES_WRITTEN = "BytesWritten";
String ACTIVE_THREADS = "ActiveThreads";
String TOTAL_TASK_DURATION_SECONDS = "TotalTaskDurationSeconds";
String TOTAL_TASK_DURATION_NANOS = "TotalTaskDurationNanoSeconds";
String OUTPUT_CONTENT_SIZE = "OutputContentSize";
String INPUT_CONTENT_SIZE = "InputContentSize";
String QUEUED_CONTENT_SIZE = "QueuedContentSize";
String OUTPUT_COUNT = "OutputCount";
String INPUT_COUNT = "InputCount";
String QUEUED_COUNT = "QueuedCount";
String OUTPUT_BYTES = "OutputBytes";
String INPUT_BYTES = "InputBytes";
String QUEUED_BYTES = "QueuedBytes";

// JVM Metrics
String JVM_UPTIME = "jvm.uptime";
String JVM_HEAP_USED = "jvm.heap_used";
String JVM_HEAP_USAGE = "jvm.heap_usage";
String JVM_NON_HEAP_USAGE = "jvm.non_heap_usage";
String JVM_THREAD_STATES_RUNNABLE = "jvm.thread_states.runnable";
String JVM_THREAD_STATES_BLOCKED = "jvm.thread_states.blocked";
String JVM_THREAD_STATES_TIMED_WAITING = "jvm.thread_states.timed_waiting";
String JVM_THREAD_STATES_TERMINATED = "jvm.thread_states.terminated";
String JVM_THREAD_COUNT = "jvm.thread_count";
String JVM_DAEMON_THREAD_COUNT = "jvm.daemon_thread_count";
String JVM_FILE_DESCRIPTOR_USAGE = "jvm.file_descriptor_usage";
String JVM_GC_RUNS = "jvm.gc.runs";
String JVM_GC_TIME = "jvm.gc.time";

}
@@ -0,0 +1,128 @@
/*
* 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.nifi.reporting.azure.loganalytics;

import java.util.ArrayList;
import java.util.List;

/**
* MetricsBuilder builds the list of metrics
*/
public class MetricsBuilder{
private List<Metric> metrics = new ArrayList<>();

public MetricsBuilder(String category, String instanceId, String processGroupId, String processGroupName) {
Computer = instanceId;
ProcessGroupName = processGroupName;
ProcessGroupId = processGroupId;
CategoryName = category;
if (category.equals(Metric.CATEGORY_PROCESSOR)){
isProcessorMetric = true;
}
}

public MetricsBuilder(String category, String instanceId, String processGroupId, String processGroupName, String processorId, String processorName) {
this(category, instanceId,processGroupId,processGroupName);
ProcessorId = processorId;
ProcessorName =processorName;
}

public MetricsBuilder setProcessorId(String processorId){
this.ProcessorId = processorId;
return this;
}

public MetricsBuilder setProcessorName(String processorName){
this.ProcessorName = processorName;
return this;
}

public MetricsBuilder setTags(String tags) {
this.Tags = tags;
return this;
}

public MetricsBuilder metric(String metricName, long count){
Metric metric = null;
if(isProcessorMetric) {
metric = new Metric(this.Computer, this.ProcessGroupId, this.ProcessGroupName);
metric.ProcessorId = this.ProcessorId;
metric.ProcessorName = this.ProcessorName;
} else {
metric = new Metric(this.Computer, this.ProcessGroupId, this.ProcessGroupName);
}
metric.CategoryName = this.CategoryName;
metric.Name = metricName;
metric.setCount(count);
if(this.Tags != null) {
metric.Tags = this.Tags;
}
metrics.add(metric);
return this;
}

public MetricsBuilder metric(String metricName, double count){
Metric metric = null;
if(isProcessorMetric) {
metric = new Metric(this.Computer, this.ProcessGroupId, this.ProcessGroupName);
metric.ProcessorId = this.ProcessorId;
metric.ProcessorName = this.ProcessorName;
} else {
metric = new Metric(this.Computer, this.ProcessGroupId, this.ProcessGroupName);
}
metric.CategoryName = this.CategoryName;
metric.Name = metricName;
metric.setCount(count);
if(this.Tags != null) {
metric.Tags = this.Tags;
}
metrics.add(metric);
return this;
}

public MetricsBuilder metric(String metricName, int count) {
Metric metric = null;
if(isProcessorMetric) {
metric = new Metric(this.Computer, this.ProcessGroupId, this.ProcessGroupName);
metric.ProcessorId = this.ProcessorId;
metric.ProcessorName = this.ProcessorName;
} else {
metric = new Metric(this.Computer, this.ProcessGroupId, this.ProcessGroupName);
}
metric.CategoryName = this.CategoryName;
metric.Name = metricName;
metric.setCount(count);
if(this.Tags != null) {
metric.Tags = this.Tags;
}
metrics.add(metric);
return this;
}
public List<Metric> build() {
return metrics;
}

public String Computer;
public String CategoryName;
public String ProcessGroupId;
public String ProcessGroupName;
public String ProcessorId;
public String ProcessorName;
public boolean isProcessorMetric = false;
public String Tags = null;

sjyang18 marked this conversation as resolved.
Show resolved Hide resolved
}