Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Ambari REST API list components with Stale configs not showing service_name

avatar
Rising Star

I would like to list all components with stale configs and I would like to have the service_name in the response. I tried several methods, like the one below, and all I get is the component but not the service it belongs to. Any idea how to get this please?

I am using Ambari 2.1

curl -u admin:admin http://host_name:8080/api/v1/clusters/test_cluster/host_components?HostRoles/stale_configs=true

1 ACCEPTED SOLUTION

avatar
Master Mentor

@Theyaa Matti

Can you try putting the URL inside Quotation Mark?

As the URL consist of (&)

Example:

curl -u admin:admin -H "X-Requested-By:ambari" -X GET "http://172.26.102.21:8080/api/v1/clusters/hdp234/host_components?HostRoles/stale_configs=false&fields=HostRoles/service_name

View solution in original post

14 REPLIES 14

avatar
Guru

@Theyaa Matti

Can you try this

http://172.26.100.103:8080/api/v1/clusters/hdp253/host_components?HostRoles/stale_configs=false&fiel...

see if you are able to list all service names, if yes, then change the value for "stale_configs=true" and rerun it like this

http://172.26.100.103:8080/api/v1/clusters/hdp253/host_components?HostRoles/stale_configs=true&field...

I am using HDP 2.6 and Ambari 2.5, works for me.

Here is the sample output:

{
  "href" : "http://172.26.100.103:8080/api/v1/clusters/hdp253/host_components?HostRoles/stale_configs=false&fields=HostRoles/service_name",
  "items" : [
    {
      "href" : "http://172.26.100.103:8080/api/v1/clusters/hdp253/hosts/xlnode-1.h.c/host_components/ACTIVITY_ANALYZER",
      "HostRoles" : {
        "cluster_name" : "hdp253",
        "component_name" : "ACTIVITY_ANALYZER",
        "host_name" : "xlnode-1.h.c",
        "service_name" : "SMARTSENSE",
        "stale_configs" : false
      },
      "host" : {
        "href" : "http://172.26.100.103:8080/api/v1/clusters/hdp253/hosts/xlnode-1.h.c"
      }
    },                      

avatar
Guru

@Theyaa Matti

Tried this with Ambari 2.2, of course I am checking for non-stale configs here, but it does show the service_name. You should upgrade your Ambari version, its not a major version.

http://172.26.102.21:8080/api/v1/clusters/hdp234/host_components?HostRoles/stale_configs=false&field...

Output

{
  "href" : "http://172.26.102.21:8080/api/v1/clusters/hdp234/host_components?HostRoles/stale_configs=false&fields=HostRoles/service_name",
  "items" : [
    {
      "href" : "http://172.26.102.21:8080/api/v1/clusters/hdp234/hosts/xlnode-234.h.c/host_components/APP_TIMELINE_SERVER",
      "HostRoles" : {
        "cluster_name" : "hdp234",
        "component_name" : "APP_TIMELINE_SERVER",
        "host_name" : "xlnode-234.h.c",
        "service_name" : "YARN",
        "stale_configs" : false
      },
      "host" : {
        "href" : "http://172.26.102.21:8080/api/v1/clusters/hdp234/hosts/xlnode-234.h.c"
      }
    },
    {
      "href" : "http://172.26.102.21:8080/api/v1/clusters/hdp234/hosts/xlnode-234.h.c/host_components/DATANODE",
      "HostRoles" : {
        "cluster_name" : "hdp234",
        "component_name" : "DATANODE",
        "host_name" : "xlnode-234.h.c",
        "service_name" : "HDFS",
        "stale_configs" : false
      },
      "host" : {
        "href" : "http://172.26.102.21:8080/api/v1/clusters/hdp234/hosts/xlnode-234.h.c"
      }
    },
....
...
..

avatar
Rising Star

I upgraded to Ambari 2.4.2 and the same issue. In order to replicate the issue, you need to call that url using curl and not the browser. Something like:

curl -u admin:admin -H "X-Requested-By:ambari" -X GET http://172.26.102.21:8080/api/v1/clusters/hdp234/host_components?HostRoles/stale_configs=false&field...

avatar
Master Mentor

@Theyaa Matti

Can you try putting the URL inside Quotation Mark?

As the URL consist of (&)

Example:

curl -u admin:admin -H "X-Requested-By:ambari" -X GET "http://172.26.102.21:8080/api/v1/clusters/hdp234/host_components?HostRoles/stale_configs=false&fields=HostRoles/service_name

avatar
Rising Star

As simple as adding quotes!