Support Questions

Find answers, ask questions, and share your expertise
Announcements
Welcome to the upgraded Community! Read this blog to see What’s New!

Ambari REST API list components with Stale configs not showing service_name

avatar
Explorer

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
Super 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
Super Mentor

avatar
Explorer

Tried both methods and same results, no service_name 😞

avatar
Super Mentor

@Theyaa Matti

Which ambari version are you using? Also can you please share the exact command and response output here?

I just now tried the same on Ambaei 2.4.0.0 and can se this thing working fine.

http://localhost:8080/api/v1/clusters/Sandbox/host_components?HostRoles/stale_configs=true&fields=Ho...

15271-service-name.png

.

avatar
Super Mentor

@Theyaa Matti

Currently i do not have Ambari 2.1 setup ready to test the same .... but i guess it should be working as expected or else it might be enhanced to show the service name in later version of ambari 2.1

avatar
Explorer

So, I am getting mixed results. When I use the browser, like what you did above, I get the service_name. But when I use curl on command line, I do NOT get the the service_name. Which makes me more confused.

I am using Ambari 2.1

avatar
Explorer

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://localhost:8080/api/v1/clusters/Sandbox/host_components?HostRoles/stale_configs=true&fields=Ho...

avatar
Super 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
Explorer

I tried your suggestion and here is what I get:

"HostRoles" : {

"cluster_name" : "test_cluster",

"component_name" : "WEBHCAT_SERVER",

"host_name" : "hostname",

"stale_configs" : true

}

So, no service_name 😞

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
Explorer

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
Super 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
Explorer

As simple as adding quotes!

Labels