You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by rickysaltzer <gi...@git.apache.org> on 2016/01/24 18:17:07 UTC

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

GitHub user rickysaltzer opened a pull request:

    https://github.com/apache/nifi/pull/188

    NIFI-1337: Add Riemann Reporting Task

    New reporting task for publishing metrics to Riemann. You may
    enable or disable forwarding the following type of events:
    
    	- JVM
    	- Processor/Processor Group
    	- Overal Data Flow
    	- Bulleting Board Messages

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/rickysaltzer/nifi riemann-reporting-task

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/188.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #188
    
----
commit e0856021b52fd77f6af2aae404450555981f30ce
Author: ricky <ri...@cloudera.com>
Date:   2016-01-04T15:57:52Z

    NIFI-1337: Add Riemann Reporting Task
    
    New reporting task for publishing metrics to Riemann. You may
    enable or disable forwarding the following type of events:
    
    	- JVM
    	- Processor/Processor Group
    	- Overal Data Flow
    	- Bulleting Board Messages

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51226675
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import com.google.common.collect.ImmutableList;
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    private static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    private static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    private static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    private static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected Transport transport;
    --- End diff --
    
    this transport object can probably be removed.  The only place where the need to know whether it is 'UDP' or 'TCP' based is in the onTrigger call (will comment re onScheduled in a moment).  GIven that it is just two values and not something expected to ever change you might consider simply using a boolean to indicate tcp or not.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51226877
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import com.google.common.collect.ImmutableList;
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    private static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    private static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    private static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    private static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private MetricsService metricsService;
    +    private final VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    +
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        final List<PropertyDescriptor> properties = Lists.newArrayList();
    +        properties.add(RIEMANN_HOST);
    +        properties.add(RIEMANN_PORT);
    +        properties.add(TRANSPORT_PROTOCOL);
    +        properties.add(SERVICE_PREFIX);
    +        properties.add(HOSTNAME);
    +        properties.add(TAGS);
    +        properties.add(SEND_JVM_METRICS);
    +        properties.add(SEND_NIFI_METRICS);
    +        properties.add(SEND_PROCESSOR_METRICS);
    +        properties.add(SEND_BULLETIN_MESSAGES);
    +        properties.add(MIN_BULLETIN_LEVEL);
    +        properties.add(WRITE_TIMEOUT);
    +        return Collections.unmodifiableList(properties);
    +    }
    +
    +    @Override
    +    protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    +        return new PropertyDescriptor.Builder().name(propertyDescriptorName).required(false).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).expressionLanguageSupported(false).dynamic(true)
    +                .build();
    +    }
    +
    +    @OnStopped
    +    public final void cleanUpClient() {
    +        if (riemannClient != null) {
    +            this.riemannClient.close();
    --- End diff --
    
    What if this throws an exception?  Hopefully the framework will catch it and log an error and provide a bulletin.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51226918
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import com.google.common.collect.ImmutableList;
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    private static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    private static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    private static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    private static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private MetricsService metricsService;
    +    private final VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    +
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        final List<PropertyDescriptor> properties = Lists.newArrayList();
    +        properties.add(RIEMANN_HOST);
    +        properties.add(RIEMANN_PORT);
    +        properties.add(TRANSPORT_PROTOCOL);
    +        properties.add(SERVICE_PREFIX);
    +        properties.add(HOSTNAME);
    +        properties.add(TAGS);
    +        properties.add(SEND_JVM_METRICS);
    +        properties.add(SEND_NIFI_METRICS);
    +        properties.add(SEND_PROCESSOR_METRICS);
    +        properties.add(SEND_BULLETIN_MESSAGES);
    +        properties.add(MIN_BULLETIN_LEVEL);
    +        properties.add(WRITE_TIMEOUT);
    +        return Collections.unmodifiableList(properties);
    +    }
    +
    +    @Override
    +    protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    +        return new PropertyDescriptor.Builder().name(propertyDescriptorName).required(false).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).expressionLanguageSupported(false).dynamic(true)
    +                .build();
    +    }
    +
    +    @OnStopped
    +    public final void cleanUpClient() {
    +        if (riemannClient != null) {
    +            this.riemannClient.close();
    +        }
    +        this.riemannClient = null;
    +    }
    +
    +    @OnScheduled
    --- End diff --
    
    should definitely avoid client creation in the onScheduled call.  The client should be created if necessary in the onTrigger calls and in the event of IOExceptions and timeouts then it is probably best to tear down/close the client.  It will be automatically reconnected at each on trigger then.  In this current approach if the connection breaks after the processor is scheduled I don't think it will reconnect (unless the riemann client is doing that automatically)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51007338
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    public static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    public static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    public static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected volatile Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private volatile MetricsService metricsService;
    +    private volatile VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    +
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        final List<PropertyDescriptor> properties = Lists.newArrayList();
    +        properties.add(RIEMANN_HOST);
    +        properties.add(RIEMANN_PORT);
    +        properties.add(TRANSPORT_PROTOCOL);
    +        properties.add(SERVICE_PREFIX);
    +        properties.add(HOSTNAME);
    +        properties.add(TAGS);
    +        properties.add(SEND_JVM_METRICS);
    +        properties.add(SEND_NIFI_METRICS);
    +        properties.add(SEND_PROCESSOR_METRICS);
    +        properties.add(SEND_BULLETIN_MESSAGES);
    +        properties.add(MIN_BULLETIN_LEVEL);
    +        properties.add(WRITE_TIMEOUT);
    +        return properties;
    +    }
    +
    +    @Override
    +    protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    +        return new PropertyDescriptor.Builder().name(propertyDescriptorName).required(false).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).expressionLanguageSupported(false).dynamic(true)
    +                .build();
    +    }
    +
    +    @OnStopped
    +    public final void cleanUpClient() {
    +        if (riemannClient != null) {
    +            this.riemannClient.close();
    +        }
    +        this.riemannClient = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ConfigurationContext context) throws ProcessException {
    +        if (riemannClient == null || !riemannClient.isConnected()) {
    +            transport = Transport.valueOf(context.getProperty(TRANSPORT_PROTOCOL).getValue());
    +            String host = context.getProperty(RIEMANN_HOST).evaluateAttributeExpressions().getValue();
    +            int port = context.getProperty(RIEMANN_PORT).asInteger();
    +            RiemannClient client = null;
    +            try {
    +                switch (transport) {
    +                case TCP:
    +                    client = RiemannClient.tcp(host, port);
    +                    break;
    +                case UDP:
    +                    client = RiemannClient.udp(host, port);
    +                    break;
    +                }
    --- End diff --
    
    Rick, sorry for my ignorance, don't know much about Reiman, so purely Java question here. What if its neither UDP nor TCP? Should there be a default?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #188: NIFI-1337: Add Riemann Reporting Task

Posted by trixpan <gi...@git.apache.org>.
Github user trixpan commented on the issue:

    https://github.com/apache/nifi/pull/188
  
    @rickysaltzer - There has been a while since this PR was last updated. Is it still needed? If not, would you mind if we close this PR?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the pull request:

    https://github.com/apache/nifi/pull/188#issuecomment-211702845
  
    @rickysaltzer Looks like there might be a lack of time to focus on this at this time.  How do you feel about closing this PR down for now and revisiting later?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #188: NIFI-1337: Add Riemann Reporting Task

Posted by rickysaltzer <gi...@git.apache.org>.
Github user rickysaltzer commented on the issue:

    https://github.com/apache/nifi/pull/188
  
    @trixpan I can close this for now 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by rickysaltzer <gi...@git.apache.org>.
Github user rickysaltzer commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51010255
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    public static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    public static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    public static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected volatile Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private volatile MetricsService metricsService;
    +    private volatile VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    +
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        final List<PropertyDescriptor> properties = Lists.newArrayList();
    +        properties.add(RIEMANN_HOST);
    +        properties.add(RIEMANN_PORT);
    +        properties.add(TRANSPORT_PROTOCOL);
    +        properties.add(SERVICE_PREFIX);
    +        properties.add(HOSTNAME);
    +        properties.add(TAGS);
    +        properties.add(SEND_JVM_METRICS);
    +        properties.add(SEND_NIFI_METRICS);
    +        properties.add(SEND_PROCESSOR_METRICS);
    +        properties.add(SEND_BULLETIN_MESSAGES);
    +        properties.add(MIN_BULLETIN_LEVEL);
    +        properties.add(WRITE_TIMEOUT);
    +        return properties;
    +    }
    +
    +    @Override
    +    protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    +        return new PropertyDescriptor.Builder().name(propertyDescriptorName).required(false).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).expressionLanguageSupported(false).dynamic(true)
    +                .build();
    +    }
    +
    +    @OnStopped
    +    public final void cleanUpClient() {
    +        if (riemannClient != null) {
    +            this.riemannClient.close();
    +        }
    +        this.riemannClient = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ConfigurationContext context) throws ProcessException {
    +        if (riemannClient == null || !riemannClient.isConnected()) {
    +            transport = Transport.valueOf(context.getProperty(TRANSPORT_PROTOCOL).getValue());
    +            String host = context.getProperty(RIEMANN_HOST).evaluateAttributeExpressions().getValue();
    +            int port = context.getProperty(RIEMANN_PORT).asInteger();
    +            RiemannClient client = null;
    +            try {
    +                switch (transport) {
    +                case TCP:
    +                    client = RiemannClient.tcp(host, port);
    +                    break;
    +                case UDP:
    +                    client = RiemannClient.udp(host, port);
    +                    break;
    +                }
    --- End diff --
    
    Since the `TRANSPORT_PROTOCOL` property only allows the `Transport.TCP` and `Transport.UDP` values, we shouldn't have to worry about handling an additional value. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51226973
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import com.google.common.collect.ImmutableList;
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    private static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    private static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    private static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    private static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private MetricsService metricsService;
    +    private final VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    +
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        final List<PropertyDescriptor> properties = Lists.newArrayList();
    +        properties.add(RIEMANN_HOST);
    +        properties.add(RIEMANN_PORT);
    +        properties.add(TRANSPORT_PROTOCOL);
    +        properties.add(SERVICE_PREFIX);
    +        properties.add(HOSTNAME);
    +        properties.add(TAGS);
    +        properties.add(SEND_JVM_METRICS);
    +        properties.add(SEND_NIFI_METRICS);
    +        properties.add(SEND_PROCESSOR_METRICS);
    +        properties.add(SEND_BULLETIN_MESSAGES);
    +        properties.add(MIN_BULLETIN_LEVEL);
    +        properties.add(WRITE_TIMEOUT);
    +        return Collections.unmodifiableList(properties);
    +    }
    +
    +    @Override
    +    protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    +        return new PropertyDescriptor.Builder().name(propertyDescriptorName).required(false).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).expressionLanguageSupported(false).dynamic(true)
    +                .build();
    +    }
    +
    +    @OnStopped
    +    public final void cleanUpClient() {
    +        if (riemannClient != null) {
    +            this.riemannClient.close();
    +        }
    +        this.riemannClient = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ConfigurationContext context) throws ProcessException {
    +        if (riemannClient == null || !riemannClient.isConnected()) {
    +            transport = Transport.valueOf(context.getProperty(TRANSPORT_PROTOCOL).getValue());
    +            String host = context.getProperty(RIEMANN_HOST).evaluateAttributeExpressions().getValue();
    +            int port = context.getProperty(RIEMANN_PORT).asInteger();
    +            RiemannClient client = null;
    +            try {
    +                switch (transport) {
    +                case TCP:
    +                    client = RiemannClient.tcp(host, port);
    +                    break;
    +                case UDP:
    +                    client = RiemannClient.udp(host, port);
    +                    break;
    +                }
    +                client.connect();
    +                riemannClient = client;
    +            } catch (IOException e) {
    +                if (client != null) {
    +                    client.close();
    +                }
    +                throw new ProcessException(String.format("Unable to connect to Riemann [%s:%d] (%s)\n%s", host, port, transport, e.getMessage()));
    +            }
    +        }
    +        metricsService = new MetricsService(context.getProperty(SERVICE_PREFIX).getValue(), context.getProperty(HOSTNAME).evaluateAttributeExpressions().getValue(),
    +                context.getProperty(TAGS).getValue().split(","));
    +
    +        // Add dynamic properties as attributes to messages
    +        Map<String, String> additionalProperties = Maps.newHashMapWithExpectedSize(context.getProperties().size());
    +        for (PropertyDescriptor propertyDescriptor : context.getProperties().keySet()) {
    +            if (propertyDescriptor.isDynamic()) {
    +                additionalProperties.put(propertyDescriptor.getName(), context.getProperty(propertyDescriptor).getValue());
    +            }
    +        }
    +        metricsService.setAdditionalAttributes(additionalProperties);
    --- End diff --
    
    consider just making setting the additional properties part of the constructor of MetricsService.  Doing so it seems would make that class thread safe as well.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51006207
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    public static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    public static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    public static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected volatile Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private volatile MetricsService metricsService;
    +    private volatile VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    +
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        final List<PropertyDescriptor> properties = Lists.newArrayList();
    +        properties.add(RIEMANN_HOST);
    +        properties.add(RIEMANN_PORT);
    +        properties.add(TRANSPORT_PROTOCOL);
    +        properties.add(SERVICE_PREFIX);
    +        properties.add(HOSTNAME);
    +        properties.add(TAGS);
    +        properties.add(SEND_JVM_METRICS);
    +        properties.add(SEND_NIFI_METRICS);
    +        properties.add(SEND_PROCESSOR_METRICS);
    +        properties.add(SEND_BULLETIN_MESSAGES);
    +        properties.add(MIN_BULLETIN_LEVEL);
    +        properties.add(WRITE_TIMEOUT);
    +        return properties;
    --- End diff --
    
    Consider wrapping it into immutable list as it seems to be a general pattern _Collections.immutable. . ._


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by rickysaltzer <gi...@git.apache.org>.
Github user rickysaltzer commented on the pull request:

    https://github.com/apache/nifi/pull/188#issuecomment-176812870
  
    Thanks @joewitt - I'll take a look either today or tomorrow. Yep, post 0.5.0 seems more than likely to get this in good shape. Thanks again 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51010766
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    public static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    public static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    public static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected volatile Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private volatile MetricsService metricsService;
    +    private volatile VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    +
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        final List<PropertyDescriptor> properties = Lists.newArrayList();
    +        properties.add(RIEMANN_HOST);
    +        properties.add(RIEMANN_PORT);
    +        properties.add(TRANSPORT_PROTOCOL);
    +        properties.add(SERVICE_PREFIX);
    +        properties.add(HOSTNAME);
    +        properties.add(TAGS);
    +        properties.add(SEND_JVM_METRICS);
    +        properties.add(SEND_NIFI_METRICS);
    +        properties.add(SEND_PROCESSOR_METRICS);
    +        properties.add(SEND_BULLETIN_MESSAGES);
    +        properties.add(MIN_BULLETIN_LEVEL);
    +        properties.add(WRITE_TIMEOUT);
    +        return properties;
    +    }
    +
    +    @Override
    +    protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    +        return new PropertyDescriptor.Builder().name(propertyDescriptorName).required(false).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).expressionLanguageSupported(false).dynamic(true)
    +                .build();
    +    }
    +
    +    @OnStopped
    +    public final void cleanUpClient() {
    +        if (riemannClient != null) {
    +            this.riemannClient.close();
    +        }
    +        this.riemannClient = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ConfigurationContext context) throws ProcessException {
    +        if (riemannClient == null || !riemannClient.isConnected()) {
    +            transport = Transport.valueOf(context.getProperty(TRANSPORT_PROTOCOL).getValue());
    +            String host = context.getProperty(RIEMANN_HOST).evaluateAttributeExpressions().getValue();
    +            int port = context.getProperty(RIEMANN_PORT).asInteger();
    +            RiemannClient client = null;
    +            try {
    +                switch (transport) {
    +                case TCP:
    +                    client = RiemannClient.tcp(host, port);
    +                    break;
    +                case UDP:
    +                    client = RiemannClient.udp(host, port);
    +                    break;
    +                }
    --- End diff --
    
    Ohh yeah. my bad!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the pull request:

    https://github.com/apache/nifi/pull/188#issuecomment-176582576
  
    Ricky
    
    Went through and did a review.  Left several comments.  Ran it against a running Riemann server and it seemed to work well.  I didn't go full bore into Graphite or Graphana but did see it in riemann-dash.  Pretty cool.  There are lots of other metrics worth adding here particularly around what we can learn from the JVM.  But these are a great start.  The licensing/notice will also need to be accounted for.
    
    Will assume this is a post 050 target but happy to keep chipping away at it with you as avail.
    
    Thanks
    Joe


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51226816
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import com.google.common.collect.ImmutableList;
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    private static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    private static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    private static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    private static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    private static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private MetricsService metricsService;
    --- End diff --
    
    should probably mark as volatile


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51005854
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    public static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    public static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    public static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected volatile Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private volatile MetricsService metricsService;
    +    private volatile VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    --- End diff --
    
    I don't see you resetting anywhere (may be missing something), but if I am correct, then consider making it _final_.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by rickysaltzer <gi...@git.apache.org>.
Github user rickysaltzer commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51010878
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    public static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    public static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    public static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected volatile Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private volatile MetricsService metricsService;
    +    private volatile VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    +
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        final List<PropertyDescriptor> properties = Lists.newArrayList();
    +        properties.add(RIEMANN_HOST);
    +        properties.add(RIEMANN_PORT);
    +        properties.add(TRANSPORT_PROTOCOL);
    +        properties.add(SERVICE_PREFIX);
    +        properties.add(HOSTNAME);
    +        properties.add(TAGS);
    +        properties.add(SEND_JVM_METRICS);
    +        properties.add(SEND_NIFI_METRICS);
    +        properties.add(SEND_PROCESSOR_METRICS);
    +        properties.add(SEND_BULLETIN_MESSAGES);
    +        properties.add(MIN_BULLETIN_LEVEL);
    +        properties.add(WRITE_TIMEOUT);
    +        return properties;
    +    }
    +
    +    @Override
    +    protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    +        return new PropertyDescriptor.Builder().name(propertyDescriptorName).required(false).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).expressionLanguageSupported(false).dynamic(true)
    +                .build();
    +    }
    +
    +    @OnStopped
    +    public final void cleanUpClient() {
    +        if (riemannClient != null) {
    +            this.riemannClient.close();
    +        }
    +        this.riemannClient = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ConfigurationContext context) throws ProcessException {
    +        if (riemannClient == null || !riemannClient.isConnected()) {
    +            transport = Transport.valueOf(context.getProperty(TRANSPORT_PROTOCOL).getValue());
    +            String host = context.getProperty(RIEMANN_HOST).evaluateAttributeExpressions().getValue();
    +            int port = context.getProperty(RIEMANN_PORT).asInteger();
    +            RiemannClient client = null;
    +            try {
    +                switch (transport) {
    +                case TCP:
    +                    client = RiemannClient.tcp(host, port);
    +                    break;
    +                case UDP:
    +                    client = RiemannClient.udp(host, port);
    +                    break;
    +                }
    --- End diff --
    
    :+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51227157
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java ---
    @@ -31,6 +31,7 @@
     import java.util.Map;
     import java.util.Set;
     import java.util.concurrent.atomic.AtomicReference;
    +import java.util.regex.Pattern;
    --- End diff --
    
    extraneous?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51227063
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/metrics/MetricsService.java ---
    @@ -0,0 +1,388 @@
    +/*
    + * 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.riemann.metrics;
    +
    +import java.util.ArrayList;
    +import java.util.Collection;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.controller.status.ProcessGroupStatus;
    +import org.apache.nifi.controller.status.ProcessorStatus;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.riemann.attributes.AttributeNames;
    +
    +import com.aphyr.riemann.Proto;
    +import com.google.common.base.Joiner;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +public class MetricsService {
    +    public final static Joiner SEP = Joiner.on('.');
    +    private final String servicePrefix;
    +    private final Collection<String> serviceTags;
    +    private final String hostName;
    +    private Map<String, String> additionalAttributes = Maps.newHashMap();
    --- End diff --
    
    should be final and ideally populated by the constructor


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by rickysaltzer <gi...@git.apache.org>.
Github user rickysaltzer commented on the pull request:

    https://github.com/apache/nifi/pull/188#issuecomment-198464162
  
    hey @joewitt  - not an issue. I haven't actually put this patch into production yet, but I have a good use case to try it out today / over the weekend. Let me give that a shot and report my findings. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by rickysaltzer <gi...@git.apache.org>.
Github user rickysaltzer commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51008627
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    public static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    public static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    public static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    --- End diff --
    
    not a good reason, no. I'll get these moved into private.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by rickysaltzer <gi...@git.apache.org>.
Github user rickysaltzer commented on the pull request:

    https://github.com/apache/nifi/pull/188#issuecomment-212058991
  
    My apologies, @joewitt, I've been out of the country on vacation for the past few months. I have this patch deployed on a test application that I am building so I will keep an eye on it. I don't mind focusing on this for a future release, though. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #188: NIFI-1337: Add Riemann Reporting Task

Posted by rickysaltzer <gi...@git.apache.org>.
Github user rickysaltzer closed the pull request at:

    https://github.com/apache/nifi/pull/188


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #188: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the issue:

    https://github.com/apache/nifi/pull/188
  
    @rickysaltzer cool thanks for following up.  And hope you enjoyed your time away.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51226391
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-nar/pom.xml ---
    @@ -1,34 +1,40 @@
     <?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.
    --->
    +      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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    -    <modelVersion>4.0.0</modelVersion>
    -    <parent>
    -        <artifactId>nifi-riemann-bundle</artifactId>
    -        <groupId>org.apache.nifi</groupId>
    -        <version>0.4.2-SNAPSHOT</version>
    -    </parent>
    +  <parent>
    +    <artifactId>nifi-riemann-bundle</artifactId>
    +    <groupId>org.apache.nifi</groupId>
    +    <version>0.4.2-SNAPSHOT</version>
    +  </parent>
    +  <modelVersion>4.0.0</modelVersion>
     
    -    <artifactId>nifi-riemann-nar</artifactId>
    -    <packaging>nar</packaging>
    -    <dependencies>
    -        <dependency>
    -            <groupId>org.apache.nifi</groupId>
    -            <artifactId>nifi-riemann-processors</artifactId>
    -        </dependency>
    -    </dependencies>
    +  <artifactId>nifi-riemann-nar</artifactId>
    +  <packaging>nar</packaging>
    +  <dependencies>
    +    <dependency>
    +      <groupId>org.apache.nifi</groupId>
    +      <artifactId>nifi-riemann-processors</artifactId>
    +      <version>${project.version}</version>
    +    </dependency>
    +    <dependency>
    +      <groupId>org.apache.nifi</groupId>
    +      <artifactId>nifi-riemann-reporting-task</artifactId>
    +      <version>${project.version}</version>
    --- End diff --
    
    Strong recommend not using ${project.version}.  Has been unreliable in the release process in the past.  Recommend simply using the 0.4.2-SNAPSHOT.  These get handled seamlessly during the release cycle.  Also recommend not declaring the versions here but rather in the bundle/pom.xml in a dependency management section and here simply pulling that dependency but without version.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51226519
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import com.google.common.collect.ImmutableList;
    --- End diff --
    
    appears to be an unused import


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the pull request:

    https://github.com/apache/nifi/pull/188#issuecomment-198151066
  
    @rickysaltzer hey there.  I just realized that this does have a commit against it post review commentary.  My apologies for not engaging.  Do you happen to be using this consistently/etc.. and are getting good results/like how it is working?  I ask because the value of my own review will be fairly superficial and just want to make sure we have someone with good experience using it that is liking it (even if that is the author of it :))


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51005574
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    public static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    public static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    public static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    --- End diff --
    
    Just curious if there is a reason for these properties not being public? More of a consistency question, no big deal.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1337: Add Riemann Reporting Task

Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/188#discussion_r51008302
  
    --- Diff: nifi-nar-bundles/nifi-riemann-bundle/nifi-riemann-reporting-task/src/main/java/org/apache/nifi/reporting/riemann/RiemannReportingTask.java ---
    @@ -0,0 +1,244 @@
    +/*
    + * 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.riemann;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.behavior.DynamicProperty;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.ConfigurationContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.reporting.AbstractReportingTask;
    +import org.apache.nifi.reporting.Bulletin;
    +import org.apache.nifi.reporting.BulletinQuery;
    +import org.apache.nifi.reporting.ReportingContext;
    +import org.apache.nifi.reporting.riemann.metrics.MetricsService;
    +
    +import com.aphyr.riemann.Proto;
    +import com.aphyr.riemann.client.IPromise;
    +import com.aphyr.riemann.client.RiemannClient;
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.yammer.metrics.core.VirtualMachineMetrics;
    +
    +@Tags({ "reporting", "riemann", "metrics" })
    +@DynamicProperty(name = "Attribute Name", value = "Attribute Value", supportsExpressionLanguage = false,
    +        description = "Additional attributes may be attached to the event by adding dynamic properties")
    +@CapabilityDescription("Publish NiFi metrics to Riemann. These metrics include " + "JVM, Processor, and General Data Flow metrics. In addition, you may also forward bulletin " + "board messages.")
    +public class RiemannReportingTask extends AbstractReportingTask {
    +    public static final PropertyDescriptor RIEMANN_HOST = new PropertyDescriptor.Builder().name("Riemann Address").description("Hostname of Riemann server").required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor RIEMANN_PORT = new PropertyDescriptor.Builder().name("Riemann Port").description("Port that Riemann is listening on").required(true).defaultValue("5555")
    +            .addValidator(StandardValidators.PORT_VALIDATOR).build();
    +    public static final PropertyDescriptor TRANSPORT_PROTOCOL = new PropertyDescriptor.Builder().name("Transport Protocol").description("Transport protocol to speak to Riemann in").required(true)
    +            .allowableValues(new Transport[] { Transport.TCP, Transport.UDP }).defaultValue("TCP").build();
    +    public static final PropertyDescriptor SERVICE_PREFIX = new PropertyDescriptor.Builder().name("Prefix for Service Name").description("Prefix to use when reporting to Riemann").defaultValue("nifi")
    +            .required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    public static final PropertyDescriptor WRITE_TIMEOUT = new PropertyDescriptor.Builder().name("Timeout").description("Timeout in milliseconds when writing events to Riemann").required(true)
    +            .defaultValue("500ms").addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).build();
    +    static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder().name("Hostname").description("The Hostname of this NiFi instance to report to Riemann").required(true)
    +            .expressionLanguageSupported(true).defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor TAGS = new PropertyDescriptor.Builder().name("Tags").description("Comma separated list of tags to include ").required(true).expressionLanguageSupported(true)
    +            .defaultValue("nifi,metrics").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_JVM_METRICS = new PropertyDescriptor.Builder().name("JVM Metrics").description("Forwards NiFi JVM metrics to Riemann").allowableValues("true", "false")
    +            .required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_NIFI_METRICS = new PropertyDescriptor.Builder().name("NiFi Metrics").description("Forwards aggregated data flow metrics to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_PROCESSOR_METRICS = new PropertyDescriptor.Builder().name("Processor Metrics").description("Forwards metrics for individual processor to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor SEND_BULLETIN_MESSAGES = new PropertyDescriptor.Builder().name("Bulletin Messages").description("Forwards messages from the Bulletin board to Riemann")
    +            .allowableValues("true", "false").required(true).defaultValue("true").addValidator(StandardValidators.BOOLEAN_VALIDATOR).build();
    +    static final PropertyDescriptor MIN_BULLETIN_LEVEL = new PropertyDescriptor.Builder().name("Minimum Bulletin Level")
    +            .description("Only forward bulletin messages at this level and above to Riemann").allowableValues(LogLevel.values()).required(true).defaultValue("WARNING").build();
    +    protected volatile Transport transport;
    +    private volatile long lastObservedBulletinId = 0;
    +    private volatile RiemannClient riemannClient = null;
    +    private volatile MetricsService metricsService;
    +    private volatile VirtualMachineMetrics virtualMachineMetrics = VirtualMachineMetrics.getInstance();
    +
    +    @Override
    +    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        final List<PropertyDescriptor> properties = Lists.newArrayList();
    +        properties.add(RIEMANN_HOST);
    +        properties.add(RIEMANN_PORT);
    +        properties.add(TRANSPORT_PROTOCOL);
    +        properties.add(SERVICE_PREFIX);
    +        properties.add(HOSTNAME);
    +        properties.add(TAGS);
    +        properties.add(SEND_JVM_METRICS);
    +        properties.add(SEND_NIFI_METRICS);
    +        properties.add(SEND_PROCESSOR_METRICS);
    +        properties.add(SEND_BULLETIN_MESSAGES);
    +        properties.add(MIN_BULLETIN_LEVEL);
    +        properties.add(WRITE_TIMEOUT);
    +        return properties;
    +    }
    +
    +    @Override
    +    protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    +        return new PropertyDescriptor.Builder().name(propertyDescriptorName).required(false).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).expressionLanguageSupported(false).dynamic(true)
    +                .build();
    +    }
    +
    +    @OnStopped
    +    public final void cleanUpClient() {
    +        if (riemannClient != null) {
    +            this.riemannClient.close();
    +        }
    +        this.riemannClient = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ConfigurationContext context) throws ProcessException {
    +        if (riemannClient == null || !riemannClient.isConnected()) {
    +            transport = Transport.valueOf(context.getProperty(TRANSPORT_PROTOCOL).getValue());
    +            String host = context.getProperty(RIEMANN_HOST).evaluateAttributeExpressions().getValue();
    +            int port = context.getProperty(RIEMANN_PORT).asInteger();
    +            RiemannClient client = null;
    +            try {
    +                switch (transport) {
    +                case TCP:
    +                    client = RiemannClient.tcp(host, port);
    +                    break;
    +                case UDP:
    +                    client = RiemannClient.udp(host, port);
    +                    break;
    +                }
    +                client.connect();
    +                riemannClient = client;
    +            } catch (IOException e) {
    +                if (client != null) {
    +                    client.close();
    +                }
    +                throw new ProcessException(String.format("Unable to connect to Riemann [%s:%d] (%s)\n%s", host, port, transport, e.getMessage()));
    +            }
    +        }
    +        metricsService = new MetricsService(context.getProperty(SERVICE_PREFIX).getValue(), context.getProperty(HOSTNAME).evaluateAttributeExpressions().getValue(),
    +                context.getProperty(TAGS).getValue().split(","));
    +
    +        // Add dynamic properties as attributes to messages
    +        Map<String, String> additionalProperties = Maps.newHashMapWithExpectedSize(context.getProperties().size());
    +        for (PropertyDescriptor propertyDescriptor : context.getProperties().keySet()) {
    +            if (propertyDescriptor.isDynamic()) {
    +                additionalProperties.put(propertyDescriptor.getName(), context.getProperty(propertyDescriptor).getValue());
    +            }
    +        }
    +        metricsService.setAdditionalAttributes(additionalProperties);
    +    }
    +
    +    /**
    +     * Retrieves all new bulletins in the `BulletinRepository` since the last time this method was called.
    +     *
    +     * @param context
    +     *          Reporting context
    +     * @return new bulletins
    +     */
    +    private List<Bulletin> getNewBulletins(ReportingContext context) {
    +        BulletinQuery.Builder bulletinQueryBuilder = new BulletinQuery.Builder().messageMatches(".*").after(lastObservedBulletinId);
    +        List<Bulletin> bulletins = context.getBulletinRepository().findBulletins(bulletinQueryBuilder.build());
    +        List<Bulletin> filteredBulletins = Lists.newArrayListWithCapacity(bulletins.size());
    +        int logLevelValue = LogLevel.valueOf(context.getProperty(MIN_BULLETIN_LEVEL).getValue()).getValue();
    +        if (bulletins.size() > 0) {
    +            for (Bulletin bulletin : bulletins) {
    +                if (LogLevel.valueOf(bulletin.getLevel()).getValue() >= logLevelValue) {
    +                    filteredBulletins.add(bulletin);
    +                }
    +            }
    +            for (Bulletin bulletin : bulletins) {
    +                lastObservedBulletinId = Math.max(lastObservedBulletinId, bulletin.getId());
    --- End diff --
    
    Seems like this line could be incorporated into a loop above instead of looping twice, right?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---