What is it?

Ambari provides set of web services for cluster management and monitoring. HDInsight clusters expose Ambari end-points for monitoring. In this release we are providing simple .Net client library to use Ambari monitoring capabilities. This client library doesn’t cover all functionality available in the service. We encourage you to extend this client library if you find that it doesn’t cover scenario you are interested in. Following operations are available in the current release of the client library:
  • Retrieve basic information about the cluster
  • Get map tasks execution statistics (number of completed, failed, running maps, etc)
  • Get Azure Blob storage bandwidth usage
Note: OneBox installation of the HDInsight doesn’t support Ambari end-points, therefore Ambari client can be used against Azure HDInsight clusters only.

NuGet package

Ambari client library is part of Hadoop WebClient NuGet package. To install WebClient package, run the following command in the Package Manager Console
PM> Install-Package Microsoft.Hadoop.WebClient 

Using Ambari Client Library

Ambari client library resides in Microsoft.Hadoop.WebClient.AmbariClient namespace. Using classes in this namespace you can retrieve information about HDInsight cluster:
  • Create an instance of AmbariClient passing in your server credentials:
    var client = new AmbariClient(Cluster.Uri, Cluster.UserName, Cluster.Password);
  • Retrieve basic information about the cluster:
    IList<ClusterInfo> clusterInfos = client.GetClusters();
    Console.WriteLine("Cluster Count: {0}", clusterInfos.Count);

    ClusterInfo clusterInfo = clusterInfos[0];
    Console.WriteLine("Cluster Href: {0}", clusterInfo.Href);
  • Get map tasks execution statistics:
    HostComponentMetric hostComponentMetric = client.GetHostComponentMetric(clusterName);
    Console.WriteLine("Cluster Metrics:");
    Console.WriteLine("\tMapsCompleted: \t{0}", hostComponentMetric.MapsCompleted);
    Console.WriteLine("\tMapsFailed: \t{0}", hostComponentMetric.MapsFailed);
    Console.WriteLine("\tMapsKilled: \t{0}", hostComponentMetric.MapsKilled);
    Console.WriteLine("\tMapsLaunched: \t{0}", hostComponentMetric.MapsLaunched);
    Console.WriteLine("\tMapsRunning: \t{0}", hostComponentMetric.MapsRunning);
    Console.WriteLine("\tMapsWaiting: \t{0}", hostComponentMetric.MapsWaiting);
  • Get Azure Blob storage bandwidth usage:
    IEnumerable<Tuple<DateTime, double>> asvMetrics = client.GetAsvMetrics(Cluster.StorageAccount, DateTime.Now.AddDays(-7), DateTime.Now);
    Console.WriteLine("ASV Metrics (Time, Bytes Uploaded):");
    foreach (var metric in asvMetrics)
        Console.WriteLine("\t{0}:\t{1}", metric.Item1, metric.Item2);

Last edited Jan 21, 2014 at 7:57 PM by maxluk, version 3


No comments yet.