You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by "Eric Landry (JIRA)" <ji...@apache.org> on 2015/12/01 02:52:11 UTC

[jira] [Commented] (SAMZA-340) Support metrics report via Graphite

    [ https://issues.apache.org/jira/browse/SAMZA-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15032882#comment-15032882 ] 

Eric Landry commented on SAMZA-340:
-----------------------------------

I also ran into the OutOfBound exception and modified the code just to get it working. I have no idea the implications of this change, but to get around the exception, I modified the getMax method
{code:title=GraphiteSnapshot.java|borderStyle=solid}
    @Override
    public long getMax() {
        try {
            return samzaTimer.getSnapshot().getMax();
        } catch (IndexOutOfBoundsException e) {
            return samzaTimer.getSnapshot().getSize();
        }
    }
{code}

On a separate topic, I'd like to make a small request regarding the GraphiteMetricName. We use Grafana (for a very short time) and have been working with the convention:
{noformat}
[System/Cluster].[Hostname].[MetricType].[MetricSubType etc].[MetricName].[MetricValue]
{noformat}

By default, Samza has all these metrics at the root level. Would it be possible to at least pass in a String prefix into SamzaGraphiteReporter.java to avoid Graphite namespace pollution? Again, here's my quick-fix to this problem:
{code:title=SamzaGraphiteReporter.java|borderStyle=solid}
    private static String hostName;

    public SamzaGraphiteReporter(String name, Config config, String containerName) {
        <snip>
        graphiteReporter = GraphiteReporter.forRegistry(graphiteMetricRegistry).filter(MetricFilter.ALL).convertDurationsTo(TimeUnit.NANOSECONDS)
                .build(graphite);
        try {
            hostName = InetAddress.getLocalHost().getHostName();
            hostName = getSafeValue(hostName);
        } catch (Throwable t) {
            log.error("Could not get hostname", t);
            hostName = "UnresolvedHostName";
        }
    }

    private static String getGraphiteMetricName(String group, String source, String name) {
        if (StringUtils.isEmpty(group) || StringUtils.isEmpty(name) || StringUtils.isEmpty(source)) {
            throw new IllegalArgumentException("Make sure group, source and name are defined");
        }
        return String.format("samza.%s.%s.%s.%s", hostName, getSafeValue(group), getSafeValue(source), getSafeValue(name));
    }

{code}

Thanks!

> Support metrics report via Graphite
> -----------------------------------
>
>                 Key: SAMZA-340
>                 URL: https://issues.apache.org/jira/browse/SAMZA-340
>             Project: Samza
>          Issue Type: Improvement
>          Components: metrics
>    Affects Versions: 0.9.0
>            Reporter: Yan Fang
>            Assignee: Luis De Pombo
>              Labels: metrics
>         Attachments: SAMZA-340.patch, SAMZA-340.v2.patch, SAMZA-340.v3.patch
>
>
> Currently we only support metrics report via JMX, it is helpful to support more output formats.  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)