You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by saloni udani <sa...@gmail.com> on 2018/07/12 15:25:54 UTC

How to get active metric collector hostname in alert script?

We have developed a custom script based alert for our ambari service which
triggers alert based on some ambari metric value. For fetching this metric
value, the metric collector hostname and port is required. It seems that
clusterHostInfo configuration is not available in alert script, so we
referred to timeline.metrics.service.webapp.address. Everthing works as
expected. But now the issue arises when we configure metric service in HA
mode. For metric service to work in HA mode
timeline.metrics.service.webapp.address cannot be changed to hostname as we
previously did.

So from where can we get active metric collector hostname?

Re: How to get active metric collector hostname in alert script?

Posted by David Quiroga <qu...@gmail.com>.
From what I understand config is a member variable of the Script class
(resource_management.libraries.script).
A service script (install/configure/start/stop) creates a class inherited
from the Script, which makes config available there.
That is to say config is not a library that can be imported and called.

I believe alert scripts themselves don't instantiate any classes, they rely
on common function naming.

Not too helpful in this case, but just a note that the host the alert is
running on is exposed via the host_name parameter in the execute function,
at least when the alert is triggered by Ambari Server.
def execute(configurations={}, parameters={}, host_name=None):

Re: How to get active metric collector hostname in alert script?

Posted by saloni udani <sa...@gmail.com>.
Thank you Aravindan.

- clusterHostInfo is not available in alert script
- for znode path we will require zookeeper client on that host
- we are not aware of host on which METRIC_COLLECTOR's are installed.

So we are planning to use ambari API
http://<AMBARI_SERVER_HOST>:8080/api/v1/clusters/<CLUSTER_NAME>/services/AMBARI_METRICS/components/METRICS_COLLECTOR?fields=host_components/HostRoles/host_name
to fetch hostname.

Just want to understand why is config.clusterHostInfo not available in
alert scripts?

On Thu, Jul 12, 2018 at 11:15 PM, Aravindan Vijayan <
avijayan@hortonworks.com> wrote:

> Hi Saloni,
>
>
>
> When you have multiple metrics collectors all of them are active. Any one
> of them can be used.
>
>
>
> FYI, there are 3 lookup options for the list of collectors.
>
>   *   Ambari Cluster Host info.
>   *   Zookeeper znode path (/ambari-metrics-cluster/LIVEINSTANCES)
>   *   Response to http://<ANY_COLLECTOR_HOST>:6188/ws/v1/timeline/metrics/
> livenodes
>
>
>
> --
>
> Thanks and Regards,
>
> Aravindan Vijayan
>
>
>
> On 7/12/18, 8:26 AM, "saloni udani" <sa...@gmail.com> wrote:
>
>
>
>     We have developed a custom script based alert for our ambari service
> which
>
>     triggers alert based on some ambari metric value. For fetching this
> metric
>
>     value, the metric collector hostname and port is required. It seems
> that
>
>     clusterHostInfo configuration is not available in alert script, so we
>
>     referred to timeline.metrics.service.webapp.address. Everthing works
> as
>
>     expected. But now the issue arises when we configure metric service in
> HA
>
>     mode. For metric service to work in HA mode
>
>     timeline.metrics.service.webapp.address cannot be changed to hostname
> as we
>
>     previously did.
>
>
>
>     So from where can we get active metric collector hostname?
>
>
>

Re: How to get active metric collector hostname in alert script?

Posted by Aravindan Vijayan <av...@hortonworks.com>.
Hi Saloni,



When you have multiple metrics collectors all of them are active. Any one of them can be used.



FYI, there are 3 lookup options for the list of collectors.

  *   Ambari Cluster Host info.
  *   Zookeeper znode path (/ambari-metrics-cluster/LIVEINSTANCES)
  *   Response to http://<ANY_COLLECTOR_HOST>:6188/ws/v1/timeline/metrics/livenodes



--

Thanks and Regards,

Aravindan Vijayan



On 7/12/18, 8:26 AM, "saloni udani" <sa...@gmail.com> wrote:



    We have developed a custom script based alert for our ambari service which

    triggers alert based on some ambari metric value. For fetching this metric

    value, the metric collector hostname and port is required. It seems that

    clusterHostInfo configuration is not available in alert script, so we

    referred to timeline.metrics.service.webapp.address. Everthing works as

    expected. But now the issue arises when we configure metric service in HA

    mode. For metric service to work in HA mode

    timeline.metrics.service.webapp.address cannot be changed to hostname as we

    previously did.



    So from where can we get active metric collector hostname?