<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question how to add variable in  kafka-env template by API? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-add-variable-in-kafka-env-template-by-API/m-p/203410#M78707</link>
    <description>&lt;P&gt;how to add the following variable ( export KAFKA_HEAP_OPTS="-Xms3g -Xmx3g" ) in  &lt;STRONG&gt;kafka-env template &lt;/STRONG&gt;by API?&lt;/P&gt;&lt;P&gt;the target is to update the file &lt;STRONG&gt;kafka-env template&lt;/STRONG&gt; in ambari GUI by API&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from ambari GUI&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ambari UI --&amp;gt; Configs --&amp;gt; Advanced --&amp;gt; "Advanced kafka-env" --&amp;gt; kafka-env template&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="76381-capture.png" style="width: 1169px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17284i2FE8DF8525E4B3E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="76381-capture.png" alt="76381-capture.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;the variable that we want to add by API:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;export KAFKA_HEAP_OPTS="-Xms3g -Xmx3g"&lt;/PRE&gt;</description>
    <pubDate>Sun, 18 Aug 2019 05:12:34 GMT</pubDate>
    <dc:creator>mike_bronson7</dc:creator>
    <dc:date>2019-08-18T05:12:34Z</dc:date>
    <item>
      <title>how to add variable in  kafka-env template by API?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-add-variable-in-kafka-env-template-by-API/m-p/203410#M78707</link>
      <description>&lt;P&gt;how to add the following variable ( export KAFKA_HEAP_OPTS="-Xms3g -Xmx3g" ) in  &lt;STRONG&gt;kafka-env template &lt;/STRONG&gt;by API?&lt;/P&gt;&lt;P&gt;the target is to update the file &lt;STRONG&gt;kafka-env template&lt;/STRONG&gt; in ambari GUI by API&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from ambari GUI&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ambari UI --&amp;gt; Configs --&amp;gt; Advanced --&amp;gt; "Advanced kafka-env" --&amp;gt; kafka-env template&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="76381-capture.png" style="width: 1169px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17284i2FE8DF8525E4B3E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="76381-capture.png" alt="76381-capture.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;the variable that we want to add by API:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;export KAFKA_HEAP_OPTS="-Xms3g -Xmx3g"&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Aug 2019 05:12:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-add-variable-in-kafka-env-template-by-API/m-p/203410#M78707</guid>
      <dc:creator>mike_bronson7</dc:creator>
      <dc:date>2019-08-18T05:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to add variable in  kafka-env template by API?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-add-variable-in-kafka-env-template-by-API/m-p/203411#M78708</link>
      <description>&lt;P&gt; &lt;A rel="user" href="https://community.cloudera.com/users/26229/uribarih.html" nodeid="26229"&gt;@Michael Bronson&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;You can do this in 3 steps. &lt;/P&gt;&lt;P&gt;1. Get the latest version tag for kafka-env. You can do this by hitting below curl request&lt;/P&gt;&lt;PRE&gt;#curl -u admin:admin -H "X-Requested-By: ambari" &lt;A href="http://{ambari-host}:{ambari-port}/api/v1/clusters/{cluster-name}?fields=Clusters/desired_configs" target="_blank"&gt;http://{ambari-host}:{ambari-port}/api/v1/clusters/{cluster-name}?fields=Clusters/desired_configs&lt;/A&gt;
Sample resp:
{
  "href" : "http://localhost:8080/api/v1/clusters/clustername?fields=Clusters/desired_configs",
  "Clusters" : {
    "cluster_name" : "clustername",
    "version" : "HDP-2.6",
    "desired_configs" : {
      "accumulo-env" : {
        "tag" : "version1525370182117",
        "version" : 8
      },
      "accumulo-log4j" : {
        "tag" : "version1525368283467",
        "version" : 4
      },
      "accumulo-logsearch-conf" : {
        "tag" : "version1525368283467",
        "version" : 4
      },
      "accumulo-site" : {
        "tag" : "version1525987821696",
        "version" : 9
      },
      "kafka-env" : {
        "tag" : "version1526330057712",
        "version" : 1
      },
      "admin-properties" : {
        "tag" : "version1526330057712",
        "version" : 1
      },
      "ams-env" : {
        "tag" : "version1",
        "version" : 1
      },
      "ams-grafana-env" : {
        "tag" : "version1",
        "version" : 1
      }
    }
  }
}
&lt;/PRE&gt;&lt;P&gt;2) Get the tag for kafka-env from the above response. For above example call, tag for kafka-env is "version1526330057712".&lt;/P&gt;&lt;P&gt;Now get the latest kafka-env config by using the above tag and the curl call.&lt;/P&gt;&lt;PRE&gt;curl -u admin:admin -H "X-Requested-By: ambari" "http://{ambari-host}:{ambari-port}/api/v1/clusters/{cluster-name}/configurations?type=kafka-env&amp;amp;tag={tag-version}"
Sample resp:
{
  "href" : "http://localhost:8080/api/v1/clusters/clustername/configurations?type=kafka-env&amp;amp;tag=version1525370182459",
  "items" : [
    {
      "href" : "http://localhost:8080/api/v1/clusters/clustername/configurations?type=kafka-env&amp;amp;tag=version1525370182459",
      "tag" : "version1525370182459",
      "type" : "kafka-env",
      "version" : 10,
      "Config" : {
        "cluster_name" : "clustername",
        "stack_id" : "HDP-2.6"
      },
      "properties" : {
        "content" : "\n#!/bin/bash\n\n# Set KAFKA specific environment variables here.\n\n# The java implementation to use.\nexport JAVA_HOME={{java64_home}}\nexport PATH=$PATH:$JAVA_HOME/bin\nexport PID_DIR={{kafka_pid_dir}}\nexport LOG_DIR={{kafka_log_dir}}\n{% if kerberos_security_enabled or kafka_other_sasl_enabled %}\nexport KAFKA_KERBEROS_PARAMS=\"-Djavax.security.auth.useSubjectCredsOnly=false {{kafka_kerberos_params}}\"\n{% else %}\nexport KAFKA_KERBEROS_PARAMS={{kafka_kerberos_params}}\n{% endif %}\n# Add kafka sink to classpath and related depenencies\nif [ -e \"/usr/lib/ambari-metrics-kafka-sink/ambari-metrics-kafka-sink.jar\" ]; then\n  export CLASSPATH=$CLASSPATH:/usr/lib/ambari-metrics-kafka-sink/ambari-metrics-kafka-sink.jar\n  export CLASSPATH=$CLASSPATH:/usr/lib/ambari-metrics-kafka-sink/lib/*\nfi\nif [ -f /etc/kafka/conf/kafka-ranger-env.sh ]; then\n. /etc/kafka/conf/kafka-ranger-env.sh\nfi",
        "is_supported_kafka_ranger" : "true",
        "kafka_keytab" : "/etc/security/keytabs/kafka.service.keytab",
        "kafka_log_dir" : "/var/log/kafka",
        "kafka_pid_dir" : "/var/run/kafka",
        "kafka_principal_name" : "kafka/_HOST@KDC_COLO.COM",
        "kafka_user" : "kafka",
        "kafka_user_nofile_limit" : "128000",
        "kafka_user_nproc_limit" : "65536"
      }
    }
  ]
}

&lt;/PRE&gt;&lt;P&gt;3) Copy the properties json from the above response. Append your config "export KAFKA_HEAP_OPTS="-Xms3g -Xmx3g" to the &lt;/P&gt;&lt;P&gt;content field under properties json.&lt;/P&gt;&lt;P&gt;New content json should look like below&lt;/P&gt;&lt;PRE&gt;"content" : "\n#!/bin/bash\n\n# Set KAFKA specific environment variables here.\n\n# The java implementation to use.\nexport JAVA_HOME={{java64_home}}\nexport PATH=$PATH:$JAVA_HOME/bin\nexport PID_DIR={{kafka_pid_dir}}\nexport LOG_DIR={{kafka_log_dir}}\n{% if kerberos_security_enabled or kafka_other_sasl_enabled %}\nexport KAFKA_KERBEROS_PARAMS=\"-Djavax.security.auth.useSubjectCredsOnly=false {{kafka_kerberos_params}}\"\n{% else %}\nexport KAFKA_KERBEROS_PARAMS={{kafka_kerberos_params}}\n{% endif %}\n# Add kafka sink to classpath and related depenencies\nif [ -e \"/usr/lib/ambari-metrics-kafka-sink/ambari-metrics-kafka-sink.jar\" ]; then\n  export CLASSPATH=$CLASSPATH:/usr/lib/ambari-metrics-kafka-sink/ambari-metrics-kafka-sink.jar\n  export CLASSPATH=$CLASSPATH:/usr/lib/ambari-metrics-kafka-sink/lib/*\nfi\nif [ -f /etc/kafka/conf/kafka-ranger-env.sh ]; then\n. /etc/kafka/conf/kafka-ranger-env.sh\nfi\nexport KAFKA_HEAP_OPTS=\"-Xms3g -Xmx3g\""&lt;/PRE&gt;&lt;P&gt;4) Post the new config to ambari&lt;/P&gt;&lt;PRE&gt;curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '[
  {
    "Clusters": {
      "desired_config": [
        {
          "type": "kafka-env",
          "tag": "unique value",
          "properties": {
            "content" : "\n#!/bin/bash\n\n# Set KAFKA specific environment variables here.\n\n# The java implementation to use.\nexport JAVA_HOME={{java64_home}}\nexport PATH=$PATH:$JAVA_HOME/bin\nexport PID_DIR={{kafka_pid_dir}}\nexport LOG_DIR={{kafka_log_dir}}\n{% if kerberos_security_enabled or kafka_other_sasl_enabled %}\nexport KAFKA_KERBEROS_PARAMS=\"-Djavax.security.auth.useSubjectCredsOnly=false {{kafka_kerberos_params}}\"\n{% else %}\nexport KAFKA_KERBEROS_PARAMS={{kafka_kerberos_params}}\n{% endif %}\n# Add kafka sink to classpath and related depenencies\nif [ -e \"/usr/lib/ambari-metrics-kafka-sink/ambari-metrics-kafka-sink.jar\" ]; then\n  export CLASSPATH=$CLASSPATH:/usr/lib/ambari-metrics-kafka-sink/ambari-metrics-kafka-sink.jar\n  export CLASSPATH=$CLASSPATH:/usr/lib/ambari-metrics-kafka-sink/lib/*\nfi\nif [ -f /etc/kafka/conf/kafka-ranger-env.sh ]; then\n. /etc/kafka/conf/kafka-ranger-env.sh\nfi\nexport KAFKA_HEAP_OPTS=\"-Xms3g -Xmx3g\"",
            "is_supported_kafka_ranger": "true",
            "kafka_keytab": "/etc/security/keytabs/kafka.service.keytab",
            "kafka_log_dir": "/var/log/kafka",
            "kafka_pid_dir": "/var/run/kafka",
            "kafka_principal_name": "kafka/_HOST@KDC_COLO.COM",
            "kafka_user": "kafka",
            "kafka_user_nofile_limit": "128000",
            "kafka_user_nproc_limit": "65536"
          },
          "service_config_version_note": "New config version"
        }
      ]
    }
  }
]' "http://localhost:8080/api/v1/clusters/clustername"&lt;/PRE&gt;&lt;P&gt;Make sure to give unique value for the tag key in the above json. Add all the properties obtained from step 3 in the above curl call and add extra config values if you need any&lt;/P&gt;&lt;P&gt;After doing these steps, new config will be added to Kafka. Restart kafka for the changes to reflect.&lt;/P&gt;&lt;P&gt;Reference : &lt;A href="https://cwiki.apache.org/confluence/display/AMBARI/Modify+configurations" target="_blank"&gt;https://cwiki.apache.org/confluence/display/AMBARI/Modify+configurations&lt;/A&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;-Aditya&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 16:57:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-add-variable-in-kafka-env-template-by-API/m-p/203411#M78708</guid>
      <dc:creator>asirna</dc:creator>
      <dc:date>2018-05-25T16:57:18Z</dc:date>
    </item>
  </channel>
</rss>

