AMBARI-14902 Make AMS Grafana component available as a repo package (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ad67efd2 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ad67efd2 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ad67efd2 Branch: refs/heads/branch-dev-patch-upgrade Commit: ad67efd2d67dfefb2fb20249bfc42e4d569b7a07 Parents: d89f8a5 Author: Dmytro Sen <d...@apache.org> Authored: Thu Feb 4 01:09:56 2016 +0200 Committer: Dmytro Sen <d...@apache.org> Committed: Thu Feb 4 01:09:56 2016 +0200 ---------------------------------------------------------------------- ambari-metrics/ambari-metrics-assembly/pom.xml | 289 ++++++------------- .../src/main/assembly/grafana.xml | 59 ++++ .../conf/unix/ambari-metrics-grafana | 172 +++++++++++ .../conf/unix/ams-grafana-env.sh | 38 +++ .../conf/unix/ams-grafana.ini | 255 ++++++++++++++++ ambari-metrics/ambari-metrics-grafana/pom.xml | 124 ++++++++ .../src/main/assemblies/empty.xml | 21 ++ ambari-metrics/pom.xml | 4 + pom.xml | 4 +- 9 files changed, 769 insertions(+), 197 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ad67efd2/ambari-metrics/ambari-metrics-assembly/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-assembly/pom.xml b/ambari-metrics/ambari-metrics-assembly/pom.xml index e963b00..dfc9351 100644 --- a/ambari-metrics/ambari-metrics-assembly/pom.xml +++ b/ambari-metrics/ambari-metrics-assembly/pom.xml @@ -30,11 +30,12 @@ <name>Ambari Metrics Assembly</name> <packaging>pom</packaging> <version>2.0.0.0-SNAPSHOT</version> - <description>Ambari Metrics</description> + <description>Ambari Metrics Assembly</description> <properties> <collector.dir>${project.basedir}/../ambari-metrics-timelineservice</collector.dir> <monitor.dir>${project.basedir}/../ambari-metrics-host-monitoring</monitor.dir> + <grafana.dir>${project.basedir}/../ambari-metrics-grafana</grafana.dir> <hadoop-sink.dir>${project.basedir}/../ambari-metrics-hadoop-sink</hadoop-sink.dir> <storm-sink.dir>${project.basedir}/../ambari-metrics-storm-sink</storm-sink.dir> <flume-sink.dir>${project.basedir}/../ambari-metrics-flume-sink</flume-sink.dir> @@ -119,6 +120,22 @@ </configuration> </execution> <execution> + <id>grafana</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <attach>false</attach> + <finalName>ambari-metrics-grafana-${project.version}</finalName> + <appendAssemblyId>false</appendAssemblyId> + <descriptors> + <descriptor>src/main/assembly/grafana.xml</descriptor> + </descriptors> + <tarLongFileMode>gnu</tarLongFileMode> + </configuration> + </execution> + <execution> <id>hadoop-sink</id> <phase>package</phase> <goals> @@ -191,85 +208,39 @@ <defaultGroupname>root</defaultGroupname> </configuration> <executions> - <!--ambari-metrics-monitor--> + <!--ambari-metrics-grafana--> <execution> - <id>ambari-metrics-monitor</id> + <id>ambari-metrics-grafana</id> <!-- unbinds rpm creation from maven lifecycle --> <phase>package</phase> <goals> <goal>rpm</goal> </goals> <configuration> - <name>ambari-metrics-monitor</name> + <name>ambari-metrics-grafana</name> <group>Development</group> <needarch>x86_64</needarch> <autoRequires>false</autoRequires> - <requires> - <require>${python.ver}</require> - <require>gcc</require> - <require>${python.devel}</require> - </requires> - <preremoveScriptlet> - <scriptFile>src/main/package/rpm/preremove.sh</scriptFile> - <fileEncoding>utf-8</fileEncoding> - </preremoveScriptlet> <mappings> <mapping> - <directory>${resmonitor.install.dir}</directory> - <username>root</username> - <groupname>root</groupname> + <!--grafana--> + <directory>/usr/lib/ambari-metrics-grafana/</directory> <sources> <source> - <location> - ${monitor.dir}/src/main/python/__init__.py - </location> - </source> - <source> - <location> - ${monitor.dir}/src/main/python/main.py - </location> + <location>${grafana.dir}/target/grafana/${grafana.folder}</location> </source> </sources> </mapping> <mapping> - <directory>${resmonitor.install.dir}/core</directory> - <sources> - <source> - <location> - ${monitor.dir}/src/main/python/core - </location> - </source> - </sources> - </mapping> - <mapping> - <directory>${resmonitor.install.dir}/psutil</directory> - <sources> - <source> - <location> - ${monitor.dir}/src/main/python/psutil - </location> - <excludes> - <exclude>build/**</exclude> - <exclude>build/*</exclude> - </excludes> - </source> - </sources> - </mapping> - <mapping> - <directory>${resmonitor.install.dir}/ambari_commons</directory> + <directory>/usr/lib/ambari-metrics-grafana/bin</directory> + <filemode>755</filemode> <sources> <source> - <location> - ${project.basedir}/../../ambari-common/src/main/python/ambari_commons - </location> + <location>${grafana.dir}/target/grafana/${grafana.folder}/bin</location> </source> </sources> </mapping> <mapping> - <directory>/etc/ambari-metrics-monitor/conf</directory> - <configuration>true</configuration> - </mapping> - <mapping> <directory>/usr/sbin</directory> <filemode>755</filemode> <username>root</username> @@ -277,219 +248,144 @@ <directoryIncluded>false</directoryIncluded> <sources> <source> - <location> - ${monitor.dir}/conf/unix/ambari-metrics-monitor - </location> - <filter>true</filter> - </source> - </sources> - </mapping> - </mappings> - </configuration> - </execution> - - <!--ambari-metrics-collector--> - <execution> - <id>ambari-metrics-collector</id> - <phase>package</phase> - <goals> - <goal>rpm</goal> - </goals> - <configuration> - <name>ambari-metrics-collector</name> - <copyright>2012, Apache Software Foundation</copyright> - <group>Development</group> - <description>Maven Recipe: RPM Package.</description> - <autoRequires>false</autoRequires> - <requires> - <require>${python.ver}</require> - </requires> - - <defaultFilemode>644</defaultFilemode> - <defaultDirmode>755</defaultDirmode> - <defaultUsername>root</defaultUsername> - <defaultGroupname>root</defaultGroupname> - - <mappings> - <mapping> - <!--jars--> - <directory>/usr/lib/ambari-metrics-collector/</directory> - <sources> - <source> - <location>${collector.dir}/target/lib</location> - </source> - <source> - <location> - ${collector.dir}/target/ambari-metrics-timelineservice-${project.version}.jar - </location> - </source> - </sources> - </mapping> - <mapping> - <!--embedded applications--> - <directory>/usr/lib/ams-hbase/</directory> - <sources> - <source> - <location>${collector.dir}/target/embedded/${hbase.folder}</location> - <excludes> - <exclude>bin/**</exclude> - <exclude>bin/*</exclude> - </excludes> - </source> - </sources> - </mapping> - <mapping> - <directory>/usr/lib/ams-hbase/bin</directory> - <filemode>755</filemode> - <sources> - <source> - <location>${collector.dir}/target/embedded/${hbase.folder}/bin</location> - </source> - </sources> - </mapping> - <mapping> - <directory>/usr/lib/ams-hbase/lib/</directory> - <sources> - <source> - <location>${collector.dir}/target/lib</location> - <includes> - <include>phoenix*.jar</include> - <include>antlr*.jar</include> - </includes> - </source> - </sources> - </mapping> - <mapping> - <directory>/usr/lib/ams-hbase/lib/hadoop-native/</directory> - <sources> - <source> - <location>${project.build.directory}/ambari-metrics-collector-${project.version}/ambari-metrics-collector-${project.version}/hbase/lib/hadoop-native</location> + <location>${grafana.dir}/conf/unix/ambari-metrics-grafana</location> + <filter>false</filter> </source> </sources> </mapping> <mapping> - <directory>/usr/sbin</directory> + <directory>/etc/ambari-metrics-grafana/conf</directory> <filemode>755</filemode> <username>root</username> <groupname>root</groupname> <directoryIncluded>false</directoryIncluded> <sources> <source> - <location>${collector.dir}/conf/unix/ambari-metrics-collector</location> + <location>${grafana.dir}/conf/unix/ams-grafana-env.sh</location> <filter>false</filter> </source> </sources> </mapping> <mapping> - <directory>/etc/ambari-metrics-collector/conf</directory> + <directory>/etc/ambari-metrics-grafana/conf</directory> <configuration>true</configuration> <sources> <source> - <location>${collector.dir}/conf/unix/ams-env.sh</location> - </source> - <source> - <location>${collector.dir}/conf/unix/ams-site.xml</location> - </source> - <source> - <location>${collector.dir}/conf/unix/log4j.properties</location> - </source> - <source> - <location>${collector.dir}/target/embedded/${hbase.folder}/conf/hbase-site.xml</location> + <location>${grafana.dir}/conf/unix/ams-grafana.ini</location> </source> </sources> </mapping> <mapping> - <directory>/etc/ams-hbase/conf</directory> - <configuration>true</configuration> - <sources> - <source> - <location>${collector.dir}/target/embedded/${hbase.folder}/conf</location> - <includes> - <include>*.*</include> - </includes> - </source> - </sources> + <directory>/var/run/ambari-metrics-grafana</directory> </mapping> <mapping> - <directory>/var/run/ams-hbase</directory> + <directory>/var/lib/ambari-metrics-grafana</directory> </mapping> <mapping> - <directory>/var/lib/ambari-metrics-collector</directory> + <directory>/var/log/ambari-metrics-grafana</directory> </mapping> </mappings> </configuration> </execution> - <!--hadoop-sink--> + <!--ambari-metrics-monitor--> <execution> - <id>ambari-metrics-hadoop-sink</id> + <id>ambari-metrics-monitor</id> + <!-- unbinds rpm creation from maven lifecycle --> <phase>package</phase> <goals> <goal>rpm</goal> </goals> - <configuration> - <name>ambari-metrics-hadoop-sink</name> - <copyright>2012, Apache Software Foundation</copyright> + <name>ambari-metrics-monitor</name> <group>Development</group> - <description>Maven Recipe: RPM Package.</description> - - <defaultDirmode>755</defaultDirmode> - <defaultFilemode>644</defaultFilemode> - <defaultUsername>root</defaultUsername> - <defaultGroupname>root</defaultGroupname> - - <postinstallScriptlet> - <scriptFile>${project.build.directory}/resources/rpm/sink/postinstall.sh</scriptFile> + <needarch>x86_64</needarch> + <autoRequires>false</autoRequires> + <requires> + <require>${python.ver}</require> + <require>gcc</require> + <require>${python.devel}</require> + </requires> + <preremoveScriptlet> + <scriptFile>src/main/package/rpm/preremove.sh</scriptFile> <fileEncoding>utf-8</fileEncoding> - </postinstallScriptlet> - + </preremoveScriptlet> <mappings> <mapping> - <directory>/usr/lib/ambari-metrics-hadoop-sink</directory> + <directory>${resmonitor.install.dir}</directory> + <username>root</username> + <groupname>root</groupname> <sources> <source> - <location>${hadoop-sink.dir}/target/ambari-metrics-hadoop-sink-with-common-${project.version}.jar</location> + <location> + ${monitor.dir}/src/main/python/__init__.py + </location> + </source> + <source> + <location> + ${monitor.dir}/src/main/python/main.py + </location> </source> </sources> </mapping> <mapping> - <directory>/usr/lib/flume/lib</directory> + <directory>${resmonitor.install.dir}/core</directory> <sources> <source> - <location>${flume-sink.dir}/target/ambari-metrics-flume-sink-with-common-${project.version}.jar</location> + <location> + ${monitor.dir}/src/main/python/core + </location> </source> </sources> </mapping> <mapping> - <directory>/usr/lib/storm/lib</directory> + <directory>${resmonitor.install.dir}/psutil</directory> <sources> <source> - <location>${storm-sink.dir}/target/ambari-metrics-storm-sink-with-common-${project.version}.jar</location> + <location> + ${monitor.dir}/src/main/python/psutil + </location> + <excludes> + <exclude>build/**</exclude> + <exclude>build/*</exclude> + </excludes> </source> </sources> </mapping> <mapping> - <directory>/usr/lib/ambari-metrics-kafka-sink</directory> + <directory>${resmonitor.install.dir}/ambari_commons</directory> <sources> <source> - <location>${kafka-sink.dir}/target/${kafka.sink.jar}</location> + <location> + ${project.basedir}/../../ambari-common/src/main/python/ambari_commons + </location> </source> </sources> </mapping> - <mapping> - <directory>/usr/lib/ambari-metrics-kafka-sink/lib</directory> + <mapping> + <directory>/etc/ambari-metrics-monitor/conf</directory> + <configuration>true</configuration> + </mapping> + <mapping> + <directory>/usr/sbin</directory> + <filemode>755</filemode> + <username>root</username> + <groupname>root</groupname> + <directoryIncluded>false</directoryIncluded> <sources> <source> - <location>${kafka-sink.dir}/target/lib</location> + <location> + ${monitor.dir}/conf/unix/ambari-metrics-monitor + </location> + <filter>true</filter> </source> </sources> </mapping> </mappings> </configuration> - </execution> + </executions> </plugin> </plugins> @@ -844,6 +740,7 @@ <assemblydescriptor.collector>src/main/assembly/collector.xml</assemblydescriptor.collector> <assemblydescriptor.monitor>src/main/assembly/monitor.xml</assemblydescriptor.monitor> <assemblydescriptor.sink>src/main/assembly/sink.xml</assemblydescriptor.sink> + <assemblydescriptor.grafana>src/main/assembly/grafana.xml</assemblydescriptor.grafana> <packagingFormat>jar</packagingFormat> </properties> <build> http://git-wip-us.apache.org/repos/asf/ambari/blob/ad67efd2/ambari-metrics/ambari-metrics-assembly/src/main/assembly/grafana.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-assembly/src/main/assembly/grafana.xml b/ambari-metrics/ambari-metrics-assembly/src/main/assembly/grafana.xml new file mode 100644 index 0000000..fe6da7f --- /dev/null +++ b/ambari-metrics/ambari-metrics-assembly/src/main/assembly/grafana.xml @@ -0,0 +1,59 @@ +<?xml version="1.0"?> + +<!-- + ~ 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 + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ 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. + --> + +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd"> + <id>grafana</id> + <formats> + <format>dir</format> + <format>tar.gz</format> + </formats> + + <fileSets> + <fileSet> + <directory>${grafana.dir}/target/grafana/${grafana.folder}</directory> + <outputDirectory>lib</outputDirectory> + </fileSet> + </fileSets> + + <files> + <file> + <source>${grafana.dir}/conf/unix/ams-grafana.ini</source> + <outputDirectory>conf</outputDirectory> + </file> + <file> + <source>${grafana.dir}/conf/unix/ams-grafana-env.sh</source> + <outputDirectory>conf</outputDirectory> + </file> + <file> + <source>${grafana.dir}/conf/unix/ambari-metrics-grafana</source> + <outputDirectory>bin</outputDirectory> + </file> + </files> + + <dependencySets> + <dependencySet> + <useProjectArtifact>false</useProjectArtifact> + <excludes> + <exclude>*</exclude> + </excludes> + </dependencySet> + </dependencySets> + +</assembly> http://git-wip-us.apache.org/repos/asf/ambari/blob/ad67efd2/ambari-metrics/ambari-metrics-grafana/conf/unix/ambari-metrics-grafana ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-grafana/conf/unix/ambari-metrics-grafana b/ambari-metrics/ambari-metrics-grafana/conf/unix/ambari-metrics-grafana new file mode 100644 index 0000000..1de5401 --- /dev/null +++ b/ambari-metrics/ambari-metrics-grafana/conf/unix/ambari-metrics-grafana @@ -0,0 +1,172 @@ +#!/usr/bin/env bash + +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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 + +# chkconfig: 2345 80 05 +# description: Grafana web server & backend +# processname: grafana +# config: /etc/grafana/ams-grafana.ini +# pidfile: /var/run/grafana.pid + +### BEGIN INIT INFO +# Provides: grafana +# Required-Start: $all +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start grafana at boot time +### END INIT INFO + +# tested on +# 1. New lsb that define start-stop-daemon +# 3. Centos with initscripts package installed + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +NAME=grafana-server +DESC="Grafana Server" + +if [ -f "/etc/ambari-metrics-grafana/conf/ams-grafana-env.sh" ]; then + . "/etc/ambari-metrics-grafana/conf/ams-grafana-env.sh" +fi + +GRAFANA_USER=${AMS_USER} +GRAFANA_GROUP=${AMS_USER_GROUP} +GRAFANA_HOME=${AMS_GRAFANA_HOME_DIR} +CONF_DIR=${AMS_GRAFANA_CONF_DIR} +WORK_DIR=$GRAFANA_HOME +DATA_DIR=${AMS_GRAFANA_DATA_DIR} +LOG_DIR=${AMS_GRAFANA_LOG_DIR} +CONF_FILE=$CONF_DIR/ams-grafana.ini +MAX_OPEN_FILES=10000 +PID_FILE=${AMS_GRAFANA_PID_DIR}/$NAME.pid +DAEMON=$GRAFANA_HOME/bin/$NAME + +if [ `id -u` -ne 0 ]; then + echo "You need root privileges to run this script" + exit 4 +fi + +if [ ! -x $DAEMON ]; then + echo "Program not installed or not executable" + exit 5 +fi + +# +# init.d / servicectl compatibility (openSUSE) +# +if [ -f /etc/rc.status ]; then + . /etc/rc.status + rc_reset +fi + +# +# Source function library. +# +if [ -f /etc/rc.d/init.d/functions ]; then + . /etc/rc.d/init.d/functions +fi + +# overwrite settings from default file +[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME + +DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR}" + +function isRunning() { + status -p $PID_FILE $NAME > /dev/null 2>&1 +} + +case "$1" in + start) + echo -n $"Starting $DESC: .... " + + isRunning + if [ $? -eq 0 ]; then + echo "Already running." + exit 0 + fi + + # Prepare environment + mkdir -p "$LOG_DIR" "$DATA_DIR" && chown "$GRAFANA_USER":"$GRAFANA_GROUP" "$LOG_DIR" "$DATA_DIR" + touch "$PID_FILE" && chown "$GRAFANA_USER":"$GRAFANA_GROUP" "$PID_FILE" + + if [ -n "$MAX_OPEN_FILES" ]; then + ulimit -n $MAX_OPEN_FILES + fi + + # Start Daemon + cd $GRAFANA_HOME + su -s /bin/sh -c "nohup ${DAEMON} ${DAEMON_OPTS} >> /dev/null 3>&1 &" $GRAFANA_USER 2> /dev/null + return=$? + if [ $return -eq 0 ] + then + sleep 1 + # check if pid file has been written two + if ! [[ -s $PID_FILE ]]; then + echo "FAILED" + exit 1 + fi + i=0 + timeout=10 + # Wait for the process to be properly started before exiting + until { cat "$PID_FILE" | xargs kill -0; } >/dev/null 2>&1 + do + sleep 1 + i=$(($i + 1)) + if [ $i -gt $timeout ]; then + echo "FAILED" + exit 1 + fi + done + fi + + echo "OK" + exit $return + ;; + stop) + echo -n "Stopping $DESC ..." + + if [ -f "$PID_FILE" ]; then + killproc -p $PID_FILE -d 20 $NAME + if [ $? -eq 1 ]; then + echo -n "$DESC is not running but pid file exists, cleaning up" + elif [ $? -eq 3 ]; then + PID="`cat $PID_FILE`" + echo -n "Failed to stop $DESC (pid $PID)" + exit 1 + fi + rm -f "$PID_FILE" + echo "OK" + exit 0 + else + echo -n "(not running)" + fi + exit 0 + ;; + status) + status -p $PID_FILE $NAME + exit $? + ;; + restart|force-reload) + if [ -f "$PID_FILE" ]; then + $0 stop + sleep 1 + fi + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart|force-reload|status}" + exit 3 + ;; +esac http://git-wip-us.apache.org/repos/asf/ambari/blob/ad67efd2/ambari-metrics/ambari-metrics-grafana/conf/unix/ams-grafana-env.sh ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-grafana/conf/unix/ams-grafana-env.sh b/ambari-metrics/ambari-metrics-grafana/conf/unix/ams-grafana-env.sh new file mode 100644 index 0000000..20986cb --- /dev/null +++ b/ambari-metrics/ambari-metrics-grafana/conf/unix/ams-grafana-env.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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 + +# Set environment variables here. + +# AMS user +export AMS_USER=ams + +# AMS user group +export AMS_USER_GROUP=hadoop + +# AMS Grafana Home Dir +export AMS_GRAFANA_HOME_DIR=/usr/lib/ambari-metrics-grafana + +# AMS Grafana Conf Dir +export AMS_GRAFANA_CONF_DIR=/etc/ambari-metrics-grafana/conf + +# AMS Grafana Data Dir +export AMS_GRAFANA_DATA_DIR=/var/lib/ambari-metrics-grafana + +# AMS Grafana Log Dir +export AMS_GRAFANA_LOG_DIR=/var/log/ambari-metrics-grafana + +# AMS Grafana PID Dir +export AMS_GRAFANA_PID_DIR=/var/run/ambari-metrics-grafana http://git-wip-us.apache.org/repos/asf/ambari/blob/ad67efd2/ambari-metrics/ambari-metrics-grafana/conf/unix/ams-grafana.ini ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-grafana/conf/unix/ams-grafana.ini b/ambari-metrics/ambari-metrics-grafana/conf/unix/ams-grafana.ini new file mode 100644 index 0000000..e42a92f --- /dev/null +++ b/ambari-metrics/ambari-metrics-grafana/conf/unix/ams-grafana.ini @@ -0,0 +1,255 @@ + +##################### Grafana Configuration Example ##################### +# +# Everything has defaults so you only need to uncomment things you want to +# change + +# possible values : production, development +; app_mode = production + +#################################### Paths #################################### +[paths] +# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) +# +;data = /var/lib/grafana +data = /var/lib/ambari-metrics-grafana +# +# Directory where grafana can store logs +# +;logs = /var/log/grafana +logs = /var/log/ambari-metrics-grafana + + +#################################### Server #################################### +[server] +# Protocol (http or https) +;protocol = http + +# The ip address to bind to, empty will bind to all interfaces +;http_addr = + +# The http port to use +;http_port = 3000 + +# The public facing domain name used to access grafana from a browser +;domain = localhost + +# Redirect to correct domain if host header does not match domain +# Prevents DNS rebinding attacks +;enforce_domain = false + +# The full public facing url +;root_url = %(protocol)s://%(domain)s:%(http_port)s/ + +# Log web requests +;router_logging = false + +# the path relative working path +;static_root_path = public +static_root_path = /usr/lib/ambari-metrics-grafana/public + +# enable gzip +;enable_gzip = false + +# https certs & key file +;cert_file = +;cert_key = + +#################################### Database #################################### +[database] +# Either "mysql", "postgres" or "sqlite3", it's your choice +;type = sqlite3 +;host = 127.0.0.1:3306 +;name = grafana +;user = root +;password = + +# For "postgres" only, either "disable", "require" or "verify-full" +;ssl_mode = disable + +# For "sqlite3" only, path relative to data_path setting +;path = grafana.db + +#################################### Session #################################### +[session] +# Either "memory", "file", "redis", "mysql", "postgres", default is "file" +;provider = file + +# Provider config options +# memory: not have any config yet +# file: session dir path, is relative to grafana data_path +# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana` +# mysql: go-sql-driver/mysql dsn config string, e.g. `user:password@tcp(127.0.0.1:3306)/database_name` +# postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable +;provider_config = sessions + +# Session cookie name +;cookie_name = grafana_sess + +# If you use session in https only, default is false +;cookie_secure = false + +# Session life time, default is 86400 +;session_life_time = 86400 + +#################################### Analytics #################################### +[analytics] +# Server reporting, sends usage counters to stats.grafana.org every 24 hours. +# No ip addresses are being tracked, only simple counters to track +# running instances, dashboard and error counts. It is very helpful to us. +# Change this option to false to disable reporting. +;reporting_enabled = true + +# Google Analytics universal tracking code, only enabled if you specify an id here +;google_analytics_ua_id = + +#################################### Security #################################### +[security] +# default admin user, created on startup +;admin_user = admin + +# default admin password, can be changed before first start of grafana, or in profile settings +;admin_password = admin + +# used for signing +;secret_key = SW2YcwTIb9zpOOhoPsMm + +# Auto-login remember days +;login_remember_days = 7 +;cookie_username = grafana_user +;cookie_remember_name = grafana_remember + +# disable gravatar profile images +;disable_gravatar = false + +# data source proxy whitelist (ip_or_domain:port seperated by spaces) +;data_source_proxy_whitelist = + +#################################### Users #################################### +[users] +# disable user signup / registration +;allow_sign_up = true + +# Allow non admin users to create organizations +;allow_org_create = true + +# Set to true to automatically assign new users to the default organization (id 1) +;auto_assign_org = true + +# Default role new users will be automatically assigned (if disabled above is set to true) +;auto_assign_org_role = Viewer + +# Background text for the user field on the login page +;login_hint = email or username + +#################################### Anonymous Auth ########################## +[auth.anonymous] +# enable anonymous access +;enabled = false + +# specify organization name that should be used for unauthenticated users +;org_name = Main Org. + +# specify role for unauthenticated users +;org_role = Viewer + +#################################### Github Auth ########################## +[auth.github] +;enabled = false +;allow_sign_up = false +;client_id = some_id +;client_secret = some_secret +;scopes = user:email,read:org +;auth_url = https://github.com/login/oauth/authorize +;token_url = https://github.com/login/oauth/access_token +;api_url = https://api.github.com/user +;team_ids = +;allowed_organizations = + +#################################### Google Auth ########################## +[auth.google] +;enabled = false +;allow_sign_up = false +;client_id = some_client_id +;client_secret = some_client_secret +;scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email +;auth_url = https://accounts.google.com/o/oauth2/auth +;token_url = https://accounts.google.com/o/oauth2/token +;api_url = https://www.googleapis.com/oauth2/v1/userinfo +;allowed_domains = + +#################################### Auth Proxy ########################## +[auth.proxy] +;enabled = false +;header_name = X-WEBAUTH-USER +;header_property = username +;auto_sign_up = true + +#################################### Basic Auth ########################## +[auth.basic] +;enabled = true + +#################################### Auth LDAP ########################## +[auth.ldap] +;enabled = false +;config_file = /etc/grafana/ldap.toml + +#################################### SMTP / Emailing ########################## +[smtp] +;enabled = false +;host = localhost:25 +;user = +;password = +;cert_file = +;key_file = +;skip_verify = false +;from_address = admin@grafana.localhost + +[emails] +;welcome_email_on_sign_up = false + +#################################### Logging ########################## +[log] +# Either "console", "file", default is "console" +# Use comma to separate multiple modes, e.g. "console, file" +;mode = console, file + +# Buffer length of channel, keep it as it is if you don't know what it is. +;buffer_len = 10000 + +# Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" +;level = Info + +# For "console" mode only +[log.console] +;level = + +# For "file" mode only +[log.file] +;level = +# This enables automated log rotate(switch of following options), default is true +;log_rotate = true + +# Max line number of single file, default is 1000000 +;max_lines = 1000000 + +# Max size shift of single file, default is 28 means 1 << 28, 256MB +;max_lines_shift = 28 + +# Segment log daily, default is true +;daily_rotate = true + +# Expired days of log file(delete after max days), default is 7 +;max_days = 7 + +#################################### AMPQ Event Publisher ########################## +[event_publisher] +;enabled = false +;rabbitmq_url = amqp://localhost/ +;exchange = grafana_events + +;#################################### Dashboard JSON files ########################## +[dashboards.json] +;enabled = false +;path = /var/lib/grafana/dashboards +path = /usr/lib/ambari-metrics-grafana/public/dashboards http://git-wip-us.apache.org/repos/asf/ambari/blob/ad67efd2/ambari-metrics/ambari-metrics-grafana/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-grafana/pom.xml b/ambari-metrics/ambari-metrics-grafana/pom.xml new file mode 100644 index 0000000..45ca1a0 --- /dev/null +++ b/ambari-metrics/ambari-metrics-grafana/pom.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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 + + http://www.apache.org/licenses/LICENSE-2.0 + + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>ambari-metrics</artifactId> + <groupId>org.apache.ambari</groupId> + <version>2.0.0.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>ambari-metrics-grafana</artifactId> + <name>Ambari Metrics Grafana</name> + <packaging>pom</packaging> + <version>2.1.0.0.0</version> + <description>Ambari Metrics Grafana</description> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.8</version> + <executions> + <execution> + <id>parse-version</id> + <phase>validate</phase> + <goals> + <goal>parse-version</goal> + </goals> + </execution> + <execution> + <id>regex-property</id> + <goals> + <goal>regex-property</goal> + </goals> + <configuration> + <name>ambariVersion</name> + <value>${project.version}</value> + <regex>^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)(\.|-).*</regex> + <replacement>$1.$2.$3.$4</replacement> + <failIfNoMatch>false</failIfNoMatch> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <configuration> + <excludes> + <exclude>conf/unix/ams-grafana.ini</exclude> + </excludes> + </configuration> + <executions> + <execution> + <phase>test</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.7</version> + <executions> + <execution> + <phase>generate-resources</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <target name="Download Ambari Grafana"> + <mkdir dir="${project.build.directory}/grafana" /> + <get + src="${grafana.tar}" + dest="${project.build.directory}/grafana/grafana.tgz" + usetimestamp="true" + /> + <untar + src="${project.build.directory}/grafana/grafana.tgz" + dest="${project.build.directory}/grafana" + compression="gzip" + /> + <get + src="${ambari-grafana.tar}" + dest="${project.build.directory}/grafana/ambari-grafana.tgz" + usetimestamp="true" + /> + <untar + src="${project.build.directory}/grafana/ambari-grafana.tgz" + dest="${project.build.directory}/grafana/${grafana.folder}/public/app/plugins/datasource" + compression="gzip" + /> + </target> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + + </build> + +</project> http://git-wip-us.apache.org/repos/asf/ambari/blob/ad67efd2/ambari-metrics/ambari-metrics-grafana/src/main/assemblies/empty.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-grafana/src/main/assemblies/empty.xml b/ambari-metrics/ambari-metrics-grafana/src/main/assemblies/empty.xml new file mode 100644 index 0000000..35738b1 --- /dev/null +++ b/ambari-metrics/ambari-metrics-grafana/src/main/assemblies/empty.xml @@ -0,0 +1,21 @@ +<!-- + 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 + + http://www.apache.org/licenses/LICENSE-2.0 + + 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. +--> +<assembly> + <id>empty</id> + <formats/> +</assembly> http://git-wip-us.apache.org/repos/asf/ambari/blob/ad67efd2/ambari-metrics/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/pom.xml b/ambari-metrics/pom.xml index 44964d4..3ca8d54 100644 --- a/ambari-metrics/pom.xml +++ b/ambari-metrics/pom.xml @@ -34,6 +34,7 @@ <module>ambari-metrics-storm-sink</module> <module>ambari-metrics-timelineservice</module> <module>ambari-metrics-host-monitoring</module> + <module>ambari-metrics-grafana</module> <module>ambari-metrics-assembly</module> </modules> <properties> @@ -49,6 +50,9 @@ <hbase.winpkg.folder>hbase-0.98.4.2.2.4.2-0002-hadoop2</hbase.winpkg.folder> <hadoop.winpkg.zip>https://msibuilds.blob.core.windows.net/hdp/2.x/2.2.4.2/2/hadoop-2.6.0.2.2.4.2-0002.winpkg.zip</hadoop.winpkg.zip> <hadoop.winpkg.folder>hadoop-2.6.0.2.2.4.2-0002</hadoop.winpkg.folder> + <grafana.folder>grafana-2.6.0</grafana.folder> + <grafana.tar>https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0.linux-x64.tar.gz</grafana.tar> + <ambari-grafana.tar>https://github.com/u39kun/ambari-grafana/raw/master/dist/ambari-grafana.tgz</ambari-grafana.tar> <resmonitor.install.dir> /usr/lib/python2.6/site-packages/resource_monitoring </resmonitor.install.dir> http://git-wip-us.apache.org/repos/asf/ambari/blob/ad67efd2/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index fe139b8..57c6de7 100644 --- a/pom.xml +++ b/pom.xml @@ -335,7 +335,7 @@ <exclude>contrib/views/slider/src/main/resources/ui/app/assets/javascripts/**</exclude> <exclude>contrib/views/slider/src/main/resources/ui/bower_components/**</exclude> <exclude>contrib/views/slider/src/main/resources/ui/runner.js</exclude> - <exclude>contrib/views/storm/src/main/resources/libs/**</exclude> + <exclude>contrib/views/storm/src/main/resources/libs/**</exclude> <exclude>contrib/views/storm/src/main/resources/styles/default.css</exclude> <exclude>contrib/views/storm/src/main/resources/templates/**</exclude> <exclude>contrib/addons/package/deb/nagios_addon_deb_control</exclude> @@ -355,6 +355,8 @@ <exclude>**/velocity.log*</exclude> <!-- Metrics module --> + <!-- grafana --> + <exclude>ambari-metrics/ambari-metrics-grafana/conf/unix/ams-grafana.ini</exclude> <!-- psutil : external lib, Apache 2.0 license included as a source file --> <exclude>ambari-metrics/target/**</exclude> <exclude>ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil/**</exclude>