|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "CCJPE: Jenkins Analytics" |
| 4 | +date: 2016-9-17 12:00:00 -0500 |
| 5 | +categories: Jenkins |
| 6 | +permalink: lessons/jenkins-analytics |
| 7 | +excerpt: "Overview of Jenkins Analytics Plugin" |
| 8 | +weight: 13 |
| 9 | +image: 'jenkinscourse.png' |
| 10 | +difficulty: hard |
| 11 | + |
| 12 | +--- |
| 13 | +{% include youtube.html id="NP8FNlmWgDg" %} |
| 14 | +{% include hired2.html %} |
| 15 | + |
| 16 | +1. Table of Contents |
| 17 | +{:title="Table of Contents"} |
| 18 | +{:toc} |
| 19 | + |
| 20 | +Cloud Config File Downloads |
| 21 | +--------------------------- |
| 22 | +* [CJOC Cloud Config](https://www.devopslibrary.com/scripts/cjoc.yaml) |
| 23 | +* [Jenkins Master01](https://www.devopslibrary.com/scripts/master01.yaml) |
| 24 | +* [Jenkins Master02](https://www.devopslibrary.com/scripts/master02.yaml) |
| 25 | +* [Jenkins Slave01](https://www.devopslibrary.com/scripts/slave01.yaml) |
| 26 | +* [ElasticSearch](https://www.devopslibrary.com/scripts/elasticsearch.yaml) |
| 27 | + |
| 28 | +Introduction |
| 29 | +------------ |
| 30 | +Welcome to the DevOps Library! This is Samantha, and in this episode, we're |
| 31 | +going to cover Cloudbees Jenkins Analytics or CJA for short. While it may not |
| 32 | +be necessary for smaller environments, Jenkins analytics is awesome once you |
| 33 | +start trying to scale. It'll help you answer questions such as "Why is my |
| 34 | +Jenkins master running slowly?" or "How fast are our jobs running?". It's |
| 35 | +also pretty easy to configure. |
| 36 | + |
| 37 | +Before we get started, though, we want to give a quick shout out to |
| 38 | +[Hired.com](http://www.hired.com/devopslibrary) for being kind enough to sponsor |
| 39 | +our Jenkins course. If you aren’t familiar with [Hired.com](http://www.hired.com/devopslibrary), it’s a great company that |
| 40 | +completely reverses the traditional job search, by having companies apply to |
| 41 | +you, instead of you always doing the tedious work of applying. Thousands of |
| 42 | +companies look to [Hired.com](http://www.hired.com/devopslibrary) to connect |
| 43 | +with the best of the best in our field, like you! OH. And if you do end up |
| 44 | +signing up through our personal link, and landing a new job, [Hired.com](http://www.hired.com/devopslibrary) will give you a 2k bonus for |
| 45 | +being a loyal supporter of the DevOps Library! |
| 46 | + |
| 47 | +Getting Started |
| 48 | +--------------- |
| 49 | +Alright, let's go ahead and get started! First, we're going to need to set up |
| 50 | +a Jenkins Operations Center. If you've been following along, you should already |
| 51 | +be good to go, but if not, don't worry! Just watch our last episode |
| 52 | +[here](https://www.devopslibrary.com/lessons/jenkins-cjoc), or you can sign up |
| 53 | +for a trial at [Cloudbees.com](https://www.cloudbees.com/get-started). |
| 54 | + |
| 55 | +Once that's setup, go to "Manage Jenkins," followed by "Configure Analytics." |
| 56 | +On this page, we need to tell Jenkins where to store our analytics data. While |
| 57 | +you do have the option of using an embedded form of [Elasticsearch](https://www.elastic.co/products/elasticsearch), it doesn't work |
| 58 | +that well, even for test instances. Because of that, we're going to set up a |
| 59 | +remote elastic search instance. First, spin up a new Ubuntu 14.04 server. Once |
| 60 | +it comes up, install Java JDK 8 by running the following commands. |
| 61 | + |
| 62 | +``` bash |
| 63 | +add-apt-repository ppa:webupd8team/java -y |
| 64 | +echo 'debconf shared/accepted-oracle-license-v1-1 select true' | debconf-set-selections |
| 65 | +echo 'debconf shared/accepted-oracle-license-v1-1 seen true' | debconf-set-selections |
| 66 | +apt-get update |
| 67 | +apt-get install oracle-java8-installer -y |
| 68 | +``` |
| 69 | + |
| 70 | +Next, let's install ElasticSearch. Run the following commands to |
| 71 | +install version 1.7.4. |
| 72 | + |
| 73 | +``` bash |
| 74 | +wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.4.deb |
| 75 | +dpkg -i elasticsearch-1.7.4.deb |
| 76 | +echo 'network.host: 0.0.0.0' > /etc/elasticsearch/elasticsearch.yml |
| 77 | +service elasticsearch start |
| 78 | +``` |
| 79 | + |
| 80 | +While you can use a newer version of Elasticsearch, **1.7.4** is the version |
| 81 | +that Cloudbees recommends, and we did run into issues on some of the newer |
| 82 | +releases. Lastly, once Elasticsearch finishes installing, we need to allow |
| 83 | +remote connections to Elasticsearch. Open up |
| 84 | +**/etc/elasticsearch/elasticsearch.yml**. |
| 85 | + |
| 86 | +Add `'network.host: 0.0.0.0'`, then save and close the file. Now run |
| 87 | + |
| 88 | +``` bash |
| 89 | +service elasticsearch start |
| 90 | +``` |
| 91 | + |
| 92 | +Then switch back to our Jenkins Operations server. |
| 93 | + |
| 94 | +Click the "Elasticsearch Configuration** dropdown, and select |
| 95 | +"Remote Elasticsearch Instance". For the URL, type "http://IpOfElasticSearch:9200". |
| 96 | +Then click "Test Connection". Perfect, there we go! Now scroll down a bit, |
| 97 | +and select "Enable" under the "Analytics Reporting Configuration". For |
| 98 | +the reporting endpoint, paste in the URL to our Jenkins Operations Center, |
| 99 | +followed by slash feeder, then hit save. |
| 100 | + |
| 101 | +Now we need to enable analytics reporting on our individual masters. On each |
| 102 | +master, go to "Manage Jenkins", "Configure Analytics", then select |
| 103 | +"Enable". The reporting endpoint is the same as what we used earlier, the URL |
| 104 | +to our operations center followed by /feeder. Now hit save. Great job!! We've |
| 105 | +finally finished setting up Jenkins analytics. Now go ahead and kick off some |
| 106 | +jobs to generate some data. Once the jobs finish running, switch to the CJOC |
| 107 | +and click the "Build Analytics" tab. |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +At this point, feel free to wander around and see what information might be |
| 112 | +useful for your team. Let's go through a few examples to get you started. What |
| 113 | +if we'd like to know which jobs are taking the longest to run? Click the "Node |
| 114 | +performance" tab. On the right, we can see that "slowjob" is by far our slowest |
| 115 | +job, and if we scroll down we can see the average duration of the top 10 longest |
| 116 | +running jobs. Or maybe someone is complaining about the performance of one of |
| 117 | +our Jenkins masters. If you go to the "Performance Analytics" tab, we can |
| 118 | +easily see how much CPU, memory, and executors are in use on each master. |
| 119 | + |
| 120 | +Pretty cool huh? Well, that's it for our lesson on Jenkins Analytics, great |
| 121 | +job following along. If you'd like to make more advanced dashboards, you can |
| 122 | +use the Analytics Dashboard creator to make pretty much anything you'd like; it |
| 123 | +just takes some experience with Kibana. We'd like to give another shout out to |
| 124 | +Hired for sponsoring this course. If you're into DevOps, there's a pretty good |
| 125 | +chance you've had to deal with pushy recruiters and countless emails, as well as |
| 126 | +spent many hours searching for DevOps opportunities. |
| 127 | + |
| 128 | +The reason we love using Hired is that it completely reverses this situation |
| 129 | +and puts the power back in your hands, by having companies send you interview |
| 130 | +requests that you can choose to pursue. (They even come with upfront salary and |
| 131 | +equity!) |
| 132 | + |
| 133 | +By having you fill out information that is specific to what you’re looking for |
| 134 | +and your individual strengths and talents, it ensures that the only companies |
| 135 | +you'll hear from will be a great fit for you. Plus, Hired is entirely free, |
| 136 | +and they’ll even give you a $2,000 bonus after you land a job, using our DevOps |
| 137 | +library link! |
| 138 | + |
| 139 | +We highly recommend giving them a shot, they do a fantastic job, especially for |
| 140 | +the DevOps community. |
| 141 | + |
| 142 | +Thanks again for watching today! If you like our videos, please subscribe to |
| 143 | +our Youtube channel! If you love them and want to help support us, visit |
| 144 | +patreon.com/devopslibrary, we’ll even list you on our high scores at the |
| 145 | +end of each video. Thanks again, see you again soon! |
| 146 | + |
| 147 | +Thanks for Watching! |
| 148 | +-------------------- |
| 149 | +[Subscribe to our YouTube channel](https://www.youtube.com/channel/UCOnioSzUZS-ZqsRnf38V2nA?sub_confirmation=1) or follow [DevOpsLibrary on Twitter](https://twitter.com/intent/user?screen_name=devopslibrary). |
| 150 | + |
| 151 | +{% include subscribe.html %} |
0 commit comments