Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Is there an ability to programmatically get the same OSGI Configuration JSON available in Cloud Manager Developer Console ?


Level 1

Cloud Manager Developer Console allows developers to download the entire OSGI Configuration JSON and I am looking for a way to programmatically get the same OSGI Configuration JSON. Is there such an ability ? 


We have a requirement to monitor and alert on configuration drift, hence looking for ways to automate the drift check.


Cloud manager API does not seem to provide an API, even though developer console seem to internally use a service to get the entire list. Would this service be available for use if we are open to write an AEM custom job or servlet to provide this information ?


Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution


Correct answer by
Community Advisor

Hi @anjanam 
I have created something long back, you can have a look to get the idea.



Note : This utility is created as PoC, this is not production ready, please test before you use it.

Arun Patidar

View solution in original post

6 Replies


Level 10

HI @anjanam ,

To programmatically obtain the same OSGi Configuration JSON available in the Cloud Manager Developer Console, you can leverage AEM's existing APIs and services. While the Cloud Manager API itself may not provide a direct endpoint for this, AEM exposes several endpoints and APIs that you can use to access OSGi configurations. Here's how you can approach this:

1. Using the OSGi Web Console API

AEM provides an OSGi Web Console API that you can use to access configuration details. This API can be accessed via HTTP requests to the AEM instance. The relevant endpoint for fetching configurations is /system/console/configMgr.

You can make a GET request to this endpoint and parse the resulting HTML to extract configuration details. However, parsing HTML is not the most robust solution. Instead, you might want to use the JSON format provided by the Apache Felix Web Management Console.

2. Using Sling's JMX MBean Server

AEM's OSGi configurations can also be accessed via the JMX MBean Server. Here's a high-level approach to creating a custom servlet to fetch these configurations in JSON format:

Step-by-Step Implementation:

  1. Create a Custom Servlet: Write a servlet that registers at a specific path and is accessible via HTTP. This servlet will use the JMX API to fetch OSGi configurations.

  2. Fetch OSGi Configurations via JMX: Use the JMX MBean Server to query the configuration details. The ConfigurationAdmin MBean can be used for this purpose.

  3. Convert Configuration to JSON: Collect the configuration details and convert them into a JSON format.

Here’s an example of how you can implement such a servlet:


import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.json.JSONObject;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.service.cm.ConfigurationAdmin;

import javax.servlet.Servlet;
import java.io.IOException;
import java.util.Dictionary;
import java.util.Enumeration;

    @Property(name = "sling.servlet.paths", value = "/bin/osgi-config")
public class OsgiConfigServlet extends SlingAllMethodsServlet {

    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {
        BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
        ConfigurationAdmin configAdmin = bundleContext.getService(bundleContext.getServiceReference(ConfigurationAdmin.class));

        JSONObject configs = new JSONObject();
        try {
            for (String pid : configAdmin.getFactoryConfigurationPids()) {
                Dictionary<String, Object> config = configAdmin.getConfiguration(pid).getProperties();
                JSONObject configJson = new JSONObject();
                Enumeration<String> keys = config.keys();
                while (keys.hasMoreElements()) {
                    String key = keys.nextElement();
                    configJson.put(key, config.get(key));
                configs.put(pid, configJson);
        } catch (Exception e) {
            response.getWriter().write("Error fetching configurations: " + e.getMessage());



3. Using AEM's System Console Configuration Endpoint

You can also write a script or use tools like curl to fetch configuration details directly from the /system/console/configMgr endpoint. For example:


curl -u admin:admin http://localhost:4502/system/console/configMgr/.json


4. Monitoring and Alerting on Configuration Drift

Once you have a way to programmatically fetch the OSGi configuration JSON, you can set up a monitoring system to compare the current configuration with a baseline. If any differences are detected, you can trigger alerts.

  • Custom Servlet: A custom servlet can be implemented to programmatically fetch OSGi configurations using the JMX API or the ConfigurationAdmin service.
  • System Console Endpoint: Use the /system/console/configMgr/.json endpoint to fetch configurations.
  • Monitoring Setup: Implement a monitoring system to compare current configurations with a baseline and alert on drift.

By creating a custom servlet, you can tailor the functionality to your specific needs and integrate it seamlessly with your existing monitoring and alerting systems.


Level 7

Thanks ChatGPT, I've been following you, and this is considered spamming, I am reporting you.


Correct answer by
Community Advisor

Hi @anjanam 
I have created something long back, you can have a look to get the idea.



Note : This utility is created as PoC, this is not production ready, please test before you use it.

Arun Patidar


Community Advisor



I think you could look at this from another angle. You must keep in mind that the OSGi configurations will only be updated through a code deployment, meaning that there must be a code change that will alter them. So instead of trying to get the list of configs and compare, you could rely on your source control tool and check if there are changes under a specific path, depending on the source control you use (and I am assuming you have set up your project with your own repository which mirrors Adobe's). You could use out-of-the-box features to trigger "actions" or build a manual check. For example: https://dev.to/omar16100/trigger-bitbucket-pipeline-only-if-certain-files-are-changed-with-google-cl...

Hope this helps 

Esteban Bustamante