Support Questions
Find answers, ask questions, and share your expertise
Alert: Please see the Cloudera blog for information on the Cloudera Response to CVE-2021-4428

Update single text configuration using rest api


There are many text fields in services configurations in ambari, Especially the templates configurations. I would like to know if there is a way to append text to the end of the content rather than replacing the entire thing.

I tried to extract single property so I can modify it and save it back, but "get" action does not take property key, only the type.

/var/lib/ambari-server/resources/scripts/ get localhost c1 mapred-site

I tried the following url:

/var/lib/ambari-server/resources/scripts/ get localhost c1 mapred-site ""

But it did not work to get only that property.

So, is there a way to do an append rather than total replace?


Super Mentor

@Theyaa Matti

The "get" gives a JSON data that contains the complete configuration of a particular type.

But if you want to set any specific property then you can try the following using "set" with specific property.

# /var/lib/ambari-server/resources/scripts/ set ErieCluster mapred-site "" "1537"


Then you can login to ambari UI to see the changes. (config changes requires restart of affected services though)


This solution is good for properties with short values, like the one you have mentioned. But, for properties that are templates, like Log4j templates, I would like to pull that modify it and upload it back to ambari.

Super Mentor

@Theyaa Matti

Can you please share exact example of the log4j template/property that you want to edit?

So that if we are aware of any best approach to make such modification that then we will share our findings.


Apologies for the delay in responding. Here is an example of a log4j property.

# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Define some default values that can be overridden by system properties hbase.root.logger=INFO,console,console hbase.log.dir=. hbase.log.file=hbase.log # Define the root logger to the system property "hbase.root.logger". log4j.rootLogger=${hbase.root.logger} # Logging Threshold log4j.threshold=ALL # # Daily Rolling File Appender # log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender log4j.appender.DRFA.File=${hbase.log.dir}/${hbase.log.file} # Rollver at midnight log4j.appender.DRFA.DatePattern=.yyyy-MM-dd # 30-day backup #log4j.appender.DRFA.MaxBackupIndex=30 log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout # Pattern format: Date LogLevel LoggerName LogMessage log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n # Rolling File Appender properties hbase.log.maxfilesize=256MB hbase.log.maxbackupindex=20 # Rolling File Appender log4j.appender.RFA=org.apache.log4j.RollingFileAppender log4j.appender.RFA.File=${hbase.log.dir}/${hbase.log.file} log4j.appender.RFA.MaxFileSize=${hbase.log.maxfilesize} log4j.appender.RFA.MaxBackupIndex=${hbase.log.maxbackupindex} log4j.appender.RFA.layout=org.apache.log4j.PatternLayout log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n # # Security audit appender # log4j.appender.RFAS=org.apache.log4j.RollingFileAppender log4j.appender.RFAS.File=${hbase.log.dir}/${} log4j.appender.RFAS.MaxFileSize=${} log4j.appender.RFAS.MaxBackupIndex=${} log4j.appender.RFAS.layout=org.apache.log4j.PatternLayout log4j.appender.RFAS.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n log4j.category.SecurityLogger=${} log4j.additivity.SecurityLogger=false # # Null Appender # log4j.appender.NullAppender=org.apache.log4j.varia.NullAppender # # console # Add "console" to rootlogger above if you want to use this # log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n # Custom Logging levels # Make these two classes INFO-level. Make them DEBUG to see more zk debug. # Set this class to log INFO only otherwise its OTT # Enable this to get detailed connection error/retry logging. #$HConnectionImplementation=TRACE # Uncomment this line to enable tracing on _every_ RPC call (this can be a lot of output) # Uncomment the below if you want to remove logging of client region caching' # and scan of .META. messages #$HConnectionImplementation=INFO #