Skip to content

Commit

Permalink
Add back tutorials to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jshaughn committed Aug 30, 2017
1 parent cbdfec0 commit 067198a
Show file tree
Hide file tree
Showing 22 changed files with 2,602 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/tutorial/README.adoc
@@ -0,0 +1,29 @@

== Hawkular Alerting Tutorial

Welcome to the Hawkular Alerting (hAlerting) tutorial! This step by step lesson guide will help you quickly become productive with hAlerting. The lessons are designed to build knowledge by going through then in order. Of course it's also fine to jump around to brush up on a specific topic as needed. Even if you've been here before you'll probably want to check in with lesson-01, just to make sure your tutorial environment is where you need it to be. Thanks, and Enjoy!

There are two directories here:
----
./tutorial/docker
./tutorial/lessons
----

All of the student materials are in `./lessons` and that is where you will want your home directory to be while working with the tutorial. You can ignore the `./docker` directory, it is the source code for building the tutorial's docker container. The docker container is already published and should be freely available for use. Just follow the directions in lesson-01.

We are adding lessons as time permits, there is plenty here to get started! The tutorial today:

. link:lessons/lesson-01-plumbing.adoc[Lesson 01 - Plumbing]
. link:lessons/lesson-02-first-alert.adoc[Lesson 02 - First Alert]
. link:lessons/lesson-03-dampening.adoc[Lesson 03 - Dampening]
. link:lessons/lesson-04-lifecycle.adoc[Lesson 04 - Alert Life-cycle]
. link:lessons/lesson-05-actions.adoc[Lesson 05 - Actions]
. link:lessons/lesson-06-events.adoc[Lesson 06 - Events]
. link:lessons/lesson-07-alerters.adoc[Lesson 07 - External Alerters]

On Deck (want to contribute?):

. Lesson 08 - Group Triggers
. Lesson 09 - Clustering
. more...

78 changes: 78 additions & 0 deletions examples/tutorial/docker/Dockerfile
@@ -0,0 +1,78 @@
#
# Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed 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.
#


# Hawkular Alerting is the alerting component used in Hawkular Metrics, The
# Hawkular Alerting Tutorial uses a Standalone Hawkular Metrics docker
# container to more easily demonstrate alerting scenarios for incoming
# metric data. This builds the Metrics container.
#
# NOTE: Building the Hawkular Metrics Docker Container is not part of
# the tutorial. This is here only to be used when a new version of the
# tutorial container is to be built, typically by a developer.


FROM jboss/wildfly:10.1.0.Final

MAINTAINER Hawkular Alerting <hawkular-dev@lists.jboss.org>

ENV HAWKULAR_METRICS_ENDPOINT_PORT="8080" \
HAWKULAR_METRICS_VERSION="0.27.0.Final" \
HAWKULAR_METRICS_DIRECTORY="/opt/hawkular-alerting-tutorial" \
HAWKULAR_METRICS_SCRIPT_DIRECTORY="/opt/hawkular-alerting-tutorial/scripts/" \
PATH=$PATH:$HAWKULAR_METRICS_SCRIPT_DIRECTORY \
JAVA_OPTS_APPEND="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heapdump"


# http, https, management, debug ports
EXPOSE 8080 9990 8787


# Get and copy the hawkular metrics ear to the deployment directory
#RUN cd $JBOSS_HOME/standalone/deployments/ && \
# curl -Lo hawkular-metrics.ear https://origin-repository.jboss.org/nexus/service/local/artifact/maven/content?r=public\&g=org.hawkular.metrics\&a=hawkular-metrics-#standalone-dist\&e=ear\&v=${HAWKULAR_METRICS_VERSION}
COPY hawkular-metrics.ear \
$JBOSS_HOME/standalone/deployments/

COPY hawkular-metrics-wrapper.sh \
$HAWKULAR_METRICS_SCRIPT_DIRECTORY

COPY config.properties \
$HAWKULAR_METRICS_SCRIPT_DIRECTORY

COPY standalone.conf \
$JBOSS_HOME/bin/


# Overwrite the welcome-content to display a more appropriate status page
COPY welcome-content $JBOSS_HOME/welcome-content/


# Overwrite the default Standalone.xml file with one that activates the HTTPS endpoint
COPY standalone.xml $JBOSS_HOME/standalone/configuration/standalone.xml


# Overwrite the default logging.properties file
COPY logging.properties $JBOSS_HOME/standalone/configuration/logging.properties

# Change the permissions so that the user running the image can start up Hawkular Metrics
USER root
RUN chmod -R 777 /opt

USER 1000

CMD $HAWKULAR_METRICS_SCRIPT_DIRECTORY/hawkular-metrics-wrapper.sh -b 0.0.0.0 -Dhawkular-metrics.cassandra-nodes=hawkular-cassandra
107 changes: 107 additions & 0 deletions examples/tutorial/docker/build-images.sh
@@ -0,0 +1,107 @@
#!/bin/bash
#
# Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed 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.
#


set -o errexit
set -o nounset
set -o pipefail

STARTTIME=$(date +%s)
source_root=$(dirname "${0}")/..

prefix="jshaughn/"
# set to the alerting version in the target metrics ear
version="1.7.0.Final"
verbose=false
options=""
help=false

for args in "$@"
do
case $args in
--prefix=*)
prefix="${args#*=}"
;;
--version=*)
version="${args#*=}"
;;
--no-cache)
options="${options} --no-cache"
;;
--verbose)
verbose=true
;;
--help)
help=true
;;
esac
done

# allow ENV to take precedent over switches
prefix="${PREFIX:-$prefix}"
version="${OS_TAG:-$version}"

if [ "$help" = true ]; then
echo "Builds the docker images for Hawkular Alerting Tutorial"
echo
echo "Options: "
echo " --prefix=PREFIX"
echo " The prefix to use for the image names."
echo " default: jshaughn/"
echo
echo " --version=VERSION"
echo " The version used to tag the image"
echo " default: 1.7.0.Final"
echo
echo " --no-cache"
echo " If set will perform the build without a cache."
echo
echo " --verbose"
echo " Enables printing of the commands as they run."
echo
echo " --help"
echo " Prints this help message"
echo
exit 0
fi

if [ "$verbose" = true ]; then
set -x
fi

for component in hawkular-alerting-tutorial; do
BUILD_STARTTIME=$(date +%s)
comp_path=.
docker_tag=${prefix}${component}:${version}
echo
echo
echo "--- Building component '$comp_path' with docker tag '$docker_tag' ---"
docker build ${options} -t $docker_tag $comp_path
BUILD_ENDTIME=$(date +%s); echo "--- $docker_tag took $(($BUILD_ENDTIME - $BUILD_STARTTIME)) seconds ---"
echo
echo
done

echo
echo
echo "++ Active images"
docker images | grep ${prefix} | grep ${version} | sort
echo


ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"
18 changes: 18 additions & 0 deletions examples/tutorial/docker/config.properties
@@ -0,0 +1,18 @@
#
# Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed 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.
#

# Hawkular properties
28 changes: 28 additions & 0 deletions examples/tutorial/docker/hawkular-metrics-wrapper.sh
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed 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.
#

echo $(date "+%Y-%m-%d %H:%M:%S") Starting Hawkular Metrics

chmod a+rw hawkular-metrics.*

exec 2>&1 /opt/jboss/wildfly/bin/standalone.sh \
-Djboss.node.name=$HOSTNAME \
--debug 8787 \
--properties=/opt/hawkular-alerting-tutorial/scripts/config.properties \
$@

51 changes: 51 additions & 0 deletions examples/tutorial/docker/logging.properties
@@ -0,0 +1,51 @@
#
# Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed 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.
#

# Note this file has been generated and will be overwritten if a
# logging subsystem has been defined in the XML configuration.


# Additional loggers to configure (the root logger is always configured)
loggers=sun.rmi,org.jboss.as.config,com.arjuna

logger.level=INFO
logger.handlers=CONSOLE

logger.sun.rmi.level=WARN
logger.sun.rmi.useParentHandlers=true

logger.org.jboss.as.config.level=DEBUG
logger.org.jboss.as.config.useParentHandlers=true

logger.com.arjuna.level=WARN
logger.com.arjuna.useParentHandlers=true

handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.level=ALL
handler.CONSOLE.formatter=COLOR-PATTERN
handler.CONSOLE.properties=autoFlush,target,enabled
handler.CONSOLE.autoFlush=true
handler.CONSOLE.target=SYSTEM_OUT
handler.CONSOLE.enabled=true

formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%e%n

formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.COLOR-PATTERN.properties=pattern
formatter.COLOR-PATTERN.pattern=%K{level}%d{yyyy-MM-dd HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%e%n
55 changes: 55 additions & 0 deletions examples/tutorial/docker/standalone.conf
@@ -0,0 +1,55 @@
#
# Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed 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.
#

## -*- shell-script -*- ######################################################
## ##
## JBoss Bootstrap Script Configuration ##
## ##
##############################################################################

#
# This file is optional; it may be removed if not needed.
#

#
# Specify the location of the Java home directory. If set then $JAVA will
# be defined to $JAVA_HOME/bin/java, else $JAVA will be "java".
#
#JAVA_HOME="/opt/java/jdk"

#
# Specify the exact Java VM executable to use.
#
#JAVA=""

if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman"
fi

#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi

# Sample JPDA settings for remote socket debugging
JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"

1 comment on commit 067198a

@lucasponce
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't bring the tutorial in 2.x until it is updated to the 2.x version.
I see that having a tutorial in master is better than having nothing, but for 2.x it should use the latest images and not use the integrated images with metrics (IMO).
If not we enter in the risk tnat a new user might get a wrong perception of what is needed.

Please sign in to comment.