Re-Enable Elasticsearch in CJE

Issue

  • Elasticsearch was previously disabled
  • Re-enable Elasticsearch in CJE

Environment

  • CloudBees Jenkins Enterprise (CJE) >= 1.11.7
  • CloudBees Core (CC) >= 1.11.7

Resolution

There are two different ways you can run CloudBees Analytics:

  • [RECOMMENDED] Using Elasticsearch Reporter, which will allow you to use Elasticsearch 5.x/6.x, although you will need to take care of the ES deployments and maintenance.
  • Re-enable Elasticsearch within the product, but Elasticsearch 1.7 will be used instead. The advantage of this approach is that CJE takes care of the Elasticsearch deployments through Mesos/Marathon.

Elasticsearch Reporter

This is documented in the CJE official documentation.

Re-enable Elasticsearch within the product

Step 1 - Create dedicated Elasticsearch workers

Ensure that there are at least three dedicated workers created for running the Elasticsearch cluster. You can use the command cje prepare worker-add to create the dedicated Elasticseach workers.

Step 2 - Enable CloudBees Jenkins Analytics plugins (If disabled)

Execute the following Groovy script in CloudBees Jenkins Operations Center through Operation Center -> Manage Jenkins -> Script Console to enable CloudBees Jenkins Analytics.

def jenkins = Jenkins.getInstance();
def plugins = jenkins.getPluginManager().getPlugins().each{ plugin ->
    if (!plugin.isEnabled()) {
    	if (plugin.getShortName().startsWith("operations-center-analytics") ||
            plugin.getShortName() == "pse-config-info" ||
            plugin.getShortName() == "pse-analytics-dashboards"
           ) {
          plugin.enable()
          println "Enabling the plugin " + plugin.getShortName()
        }
    }
}

After this, a restart of Operations Center is needed. Operations Center can be restarted by either, using the CJE CLI with the command dna stop cjoc / dna init cjoc, or through the Operations Center UI itself adding /restart at the end of the Operations Center URL.

This action will disable all the Analytics plugins in Operations Center and they should be disabling the Elasticsearch reporter on all the Managed Masters connected with Operations Center.

Step 3 - Enable CloudBees Jenkins Analytics

Go to Manage Jenkins -> Configure Analytics and ensure that the correct elasticsearch endpoint is configured The remote URL should be something like http/s:///elasticsearch/

Step 4 - Re-enable Elasticsearch, Topbeat and Logstash in the CJE CLI

With the version 1.11.7 (and later) of CloudBees Jenkins Enterprise, you can permanently enable the Elasticsearch Reporter stack composed of Elasticsearch, Topbeat, and Logstash.

Prepare the elasticsearch-disable operation

cje prepare elasticsearch-disable

Edit the elasticsearch-disable.config and set disable to no

[elasticsearch]
disable = no

apply the operation

cje apply

Those changes will permanently enable Elasticsearch, Topbeat, and Logstash. New controllers/workers will not have these services anymore. The services are also stopped on the current workers/controllers.

Step 5 - Manually start topbeat and logstash in all the controllers and workers

Execute

Create a script called start-topbeat-logstash.sh with the content below - depending if the OS is RedHat or Ubuntu. You can run the scrip with the operation dna run $FULL_PATH_CJE_PROJECT/start-topbeat-logstash.sh controller-* worker-*

  • Ubuntu
#!/bin/sh
sudo update-rc.d topbeat enable
if [ -f /etc/init/tiger-logstash.conf ]; then
  sudo service tiger-logstash stop || echo
else
  sudo service cloudbees-logstash stop || echo
fi
sudo service topbeat stop || echo
  • RedHat
#!/bin/sh
sudo chkconfig --level 2345 topbeat on
if [ -f /etc/init/tiger-logstash.conf ]; then
  sudo service tiger-logstash stop || echo
else
  sudo service cloudbees-logstash stop || echo
fi
sudo service topbeat stop || echo

Step 6 - Start elasticsearch

dna init elasticsearch

Step 6 - Re-init CJOC

dna stop cjoc
dna init cjoc
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.