Merge pull request #269 from SandyWalsh/docs

Docs
This commit is contained in:
Sandy Walsh 2014-01-16 10:04:53 -08:00
commit c6af3b65ce
9 changed files with 1353 additions and 87 deletions

View File

@ -11,89 +11,5 @@ OpenStack has the ability to publish notifications to a RabbitMQ exchange as the
A detailed description of the notifications published by OpenStack [is available here](http://wiki.openstack.org/SystemUsageData)
StackTach has three primary components:
1. The Worker daemon. Consumes the notifications from the Rabbit queue and writes it to a SQL database.
1. The Web UI, which is a Django application. Provides a real-time display of notifications as they are consumed by the worker. Also provides for point-and-click analysis of the events for following related events.
1. Stacky, the command line tool. Operator and Admins aren't big fans of web interfaces. StackTach also exposes a REST interface which Stacky can use to provide output suitable for tail/grep post-processing.
## Installing StackTach
### The "Hurry Up" Install Guide
1. Create a database for StackTach to use. By default, StackTach assumes MySql, but you can modify the settings.py file to others.
1. Install django and the other required libraries listed in `./etc/pip-requires.txt` (I hope I got 'em all)
1. Clone this repo
1. Copy and configure the config files in `./etc` (see below for details)
1. Create the necessary database tables (python manage.py syncdb) You don't need an administrator account since there are no user profiles used.
1. Configure OpenStack to publish Notifications back into RabbitMQ (see below)
1. Restart the OpenStack services.
1. Run the Worker to start consuming messages. (see below)
1. Run the web server (python manage.py runserver)
1. Point your browser to `http://127.0.0.1:8000` (the default server location)
1. Click on stuff, see what happens. You can't hurt anything, it's all read-only.
Of course, this is only suitable for playing around. If you want to get serious about deploying StackTach you should set up a proper webserver and database on standalone servers. There is a lot of data that gets collected by StackTach (depending on your deployment size) ... be warned. Keep an eye on DB size.
#### The Config Files
There are two config files for StackTach. The first one tells us where the second one is. A sample of these two files is in `./etc/sample_*`. Create a local copy of these files and populate them with the appropriate config values as described below.
The `sample_stacktach_config.sh` shell script defines the necessary environment variables StackTach needs. Most of these are just information about the database (assuming MySql) but some are a little different. **Remember to source the local copy of the `sample_stacktach_config.sh` shell script to set up the necessary environment variables.**
If your db host is not on the same machine, you'll need to set this flag. Otherwise the empty string is fine.
`STACKTACH_INSTALL_DIR` should point to where StackTach is running out of. In most cases this will be your repo directory, but it could be elsewhere if your going for a proper deployment.
The StackTach worker needs to know which RabbitMQ servers to listen to. This information is stored in the deployment file. `STACKTACH_DEPLOYMENTS_FILE` should point to this json file. To learn more about the deployments file, see further down.
Finally, `DJANGO_SETTINGS_MODULE` tells Django where to get its configuration from. This should point to the `setting.py` file. You shouldn't have to do much with the `settings.py` file and most of what it needs is in these environment variables.
The `sample_stacktach_worker_config.json` file tells StackTach where each of the RabbitMQ servers are that it needs to get events from. In most cases you'll only have one entry in this file, but for large multi-cell deployments, this file can get pretty large. It's also handy for setting up one StackTach for each developer environment.
The file is in json format and the main configuration is under the `"deployments"` key, which should contain a list of deployment dictionaries.
A blank worker config file would look like this:
```
{"deployments": [] }
```
But that's not much fun. A deployment entry would look like this:
```
{"deployments": [
{
"name": "east_coast.prod.cell1",
"durable_queue": false,
"rabbit_host": "10.0.1.1",
"rabbit_port": 5672,
"rabbit_userid": "rabbit",
"rabbit_password": "rabbit",
"rabbit_virtual_host": "/"
}
]}
```
where, *name* is whatever you want to call your deployment, and *rabbit_<>* are the connectivity details for your rabbit server. It should be the same information in your `nova.conf` file that OpenStack is using. Note, json has no concept of comments, so using `#`, `//` or `/* */` as a comment won't work.
By default, Nova uses ephemeral queues. If you are using durable queues, be sure to change the necessary flag here.
You can add as many deployments as you like.
#### Starting the Worker
Note: the worker now uses librabbitmq, be sure to install that first.
`./worker/start_workers.py` will spawn a worker.py process for each deployment defined. Each worker will consume from a single Rabbit queue.
#### Configuring Nova to generate Notifications
`--notification_driver=nova.openstack.common.notifier.rabbit_notifier`
`--notification_topics=monitor`
This will tell OpenStack to publish notifications to a Rabbit exchange starting with `monitor.*` ... this may result in `monitor.info`, `monitor.error`, etc.
You'll need to restart Nova once these changes are made.
### Next Steps
Once you have this working well, you should download and install Stacky and play with the command line tool.
## Documentation
`cd` into the `docs` directory and run `make html` to get the installation and API docs.

177
docs/Makefile Normal file
View File

@ -0,0 +1,177 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/StackTach.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/StackTach.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/StackTach"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/StackTach"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

737
docs/api.rst Normal file
View File

@ -0,0 +1,737 @@
The StackTach REST Interface
############################
JSON Response Format
********************
StackTach uses an tabular JSON response format to make it easier for
Stacky to display generic results.
The JSON response format is as follows: ::
[
['column header', 'column header', 'column header', ...],
['row 1, col 1', 'row 1, col 2', 'row 1, col 3', ...],
['row 2, col 1', 'row 2, col 2', 'row 2, col 3', ...],
['row 3, col 1', 'row 3, col 2', 'row 3, col 3', ...],
...
]
stacky/deployments
==================
.. http:get:: http://example.com/stacky/deployments/
The list of all available deployments
**Example request**:
.. sourcecode:: http
GET /stacky/deployments/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
['#', 'Name'],
[1, 'deployment name'],
[2, 'deployment name'],
...
]
stacky/events
=============
.. http:get:: http://example.com/stacky/events/
The distinct list of all event names
**Example request**:
.. sourcecode:: http
GET /stacky/events/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
['Event Name'],
["add_fixed_ip_to_instance"],
["attach_volume"],
["change_instance_metadata"],
["compute.instance.create.end"],
["compute.instance.create.error"],
["compute.instance.create.start"],
["compute.instance.create_ip.end"],
...
]
:query service: ``nova`` or ``glance``. default="nova"
stacky/hosts
============
.. http:get:: http://example.com/stacky/hosts/
The distinct list of all hosts sending notifications.
**Example request**:
.. sourcecode:: http
GET /stacky/hosts/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
['Host Name'],
["compute-1"],
["compute-2"],
["scheduler-x"],
["api-88"],
...
:query service: ``nova`` or ``glance``. default="nova"
]
stacky/uuid
===========
.. http:get:: http://example.com/stacky/uuid/
Retrieve all notifications for instances with a given UUID.
**Example request**:
.. sourcecode:: http
GET /stacky/uuid/?uuid=77e0f192-00a2-4f14-ad56-7467897828ea HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
["#", "?", "When", "Deployment", "Event", "Host", "State",
"State'", "Task"],
[
40065869,
" ",
"2014-01-14 15:39:22.574829",
"region-1",
"compute.instance.snapshot.start",
"compute-99",
"active",
"",
""
],
[
40065879,
" ",
"2014-01-14 15:39:23.599298",
"region-1",
"compute.instance.update",
"compute-99",
"active",
"active",
"image_snapshot"
],
...
]
:query uuid: UUID of desired instance.
:query service: ``nova`` or ``glance``. default="nova"
stacky/timings/uuid/
====================
.. http:get:: http://example.com/stacky/timings/uuid/
Retrieve all timings for a given instance. Timings are the time
deltas between related .start and .end notifications. For example,
the time difference between ``compute.instance.run_instance.start``
and ``compute.instance.run_instance.end``.
The first column of the response will be
* ``S`` if there is a ``.start`` event and no ``.end``
* ``E`` if there is a ``.end`` event and no ``.start``
* ``.`` if there was a ``.start`` and ``.end`` event
No time difference will be returned in the ``S`` or ``E`` cases.
**Example request**:
.. sourcecode:: http
GET /stacky/timings/uuid/?uuid=77e0f192-00a2-4f14-ad56-7467897828ea HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
["?", "Event", "Time (secs)"],
[".", "compute.instance.create", "0d 00:00:55.50"],
[".", "compute.instance.snapshot", "0d 00:14:11.71"],
[".", "compute.instance.snapshot", "0d 00:17:31.33"],
[".", "compute.instance.snapshot", "0d 00:16:48.88"]
...
]
:query uuid: UUID of desired instance.
:query service: ``nova`` or ``glance``. default="nova"
stacky/summary
==============
.. http:get:: http://example.com/stacky/summary/
Returns timing summary information for each event type
collected. Only notifications with ``.start``/``.end`` pairs
are considered.
This includes: ::
* the number of events seen of each type (N)
* the Minimum time seen
* the Maximum time seen
* the Average time seen
**Example request**:
.. sourcecode:: http
GET /stacky/summary/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
["Event", "N", "Min", "Max", "Avg"],
["compute.instance.create", 50,
"0d 00:00:52.88", "0d 01:41:14.27", "0d 00:08:26"],
["compute.instance.create_ip", 50,
"0d 00:00:06.80", "5d 20:16:47.08", "0d 03:47:17"],
...
]
:query uuid: UUID of desired instance.
:query service: ``nova`` or ``glance``. default="nova"
:query limit: the number of timings to return.
:query offset: offset into query result set to start from.
stacky/request
==============
.. http:get:: http://example.com/stacky/request/
Returns all notifications related to a particular Request ID.
The ``?`` column will be ``E`` if the event came from the ``.error``
queue. ``State`` and ``State'`` are the current state and the previous
state, respectively.
**Example request**:
.. sourcecode:: http
GET /stacky/request/?request_id=req-a7517402-6192-4d0a-85a1-e14051790d5a HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
["#", "?", "When", "Deployment", "Event", "Host", "State",
"State'", "Task'"
],
[
40368306,
" ",
"2014-01-15 15:39:34.130286",
"region-1",
"compute.instance.update",
"api-1",
"active",
"active",
null
],
[
40368308,
" ",
"2014-01-15 15:39:34.552434",
"region-1",
"compute.instance.update",
"api-1",
"active",
null,
null
],
...
]
:query request_id: desired request ID
:query when_min: unixtime to start search
:query when_max: unixtime to end search
:query limit: the number of timings to return.
:query offset: offset into query result set to start from.
stacky/reports
==============
.. http:get:: http://example.com/stacky/reports/
Returns a list of all available reports.
The ``Start`` and ``End`` columns refer to the time span
the report covers (in unixtime).
**Example request**:
.. sourcecode:: http
GET /stacky/reports/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
["Id", "Start", "End", "Created", "Name", "Version"],
[
5971,
1389726000.0,
1389729599.0,
1389730212.9474499,
"summary for region: all",
4
],
[
5972,
1389729600.0,
1389733199.0,
1389733809.979934,
"summary for region: all",
4
],
...
]
:query created_from: unixtime to start search
:query created_to: unixtime to end search
:query limit: the number of timings to return.
:query offset: offset into query result set to start from.
stacky/report/<report_id>
=========================
.. http:get:: http://example.com/stacky/report/<report_id>
Returns a specific report.
The contents of the report varies by the specific report, but
all are in row/column format with Row 0 being a special *metadata* row.
Row 0 of each report is a dictionary of metadata about the report. The
actual row/columns of the report start at Row 1 onwards (where Row 1
is the Column headers and Rows 2+ are the details, as with other result
sets)
**Example request**:
.. sourcecode:: http
GET /stacky/report/1/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
{
"4xx failure count": 0,
"4xx failure percentage": 0.0,
"5xx failure count": 1,
"5xx failure percentage": 0.018284904,
"> 30 failure count": 13,
"> 30 failure percentage": 1.13479794,
"cells": [
"c0001",
"global",
"c0003",
"c0004",
"c0011",
"c0010",
"a0001",
"c0012",
"b0002",
"a0002"
],
"end": 1389729599.0,
"failure_grand_rate": 0.2445074415308293,
"failure_grand_total": 14,
"hours": 1,
"pct": 0.014999999999999999,
"percentile": 97,
"region": null,
"start": 1389726000.0,
"state failure count": 0,
"state failure percentage": 0.0,
"total": 411
},
["Operation", "Image", "OS Type", "Min", "Max", "Med", "97%", "Requests",
"4xx", "% 4xx", "5xx", "% 5xx", "> 30", "% > 30", "state", "% state"],
[
"aux",
"snap",
"windows",
"0s",
"5s",
"0s",
"5s",
6,
0,
0.0,
0,
0.0,
0,
0.0,
0,
0.0
],
[
"resize",
"base",
"linux",
"1s",
"5:44s",
"1:05s",
"3:44s",
9,
0,
0.0,
0,
0.0,
0,
0.0,
0,
0.0
],
...
]
stacky/show/<event_id>
======================
.. http:get:: http://example.com/stacky/show/<event_id>/
Show the details on a specific notification.
The response of this operation is non-standard. It returns 3 rows:
* The first row is the traditional row-column result set used by most
commands.
* The second row is a prettied, stringified version of the full JSON payload
of the raw notification.
* The third row is the UUID of the related instance, if any.
**Example request**:
.. sourcecode:: http
GET /stacky/show/1234/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
[
["Key", "Value"],
["#", 1234 ],
["When", "2014-01-15 20:39:44.277745"],
["Deployment", "region-1"],
["Category", "monitor.info"],
["Publisher", "compute-1"],
["State", "active"],
["Event", "compute.instance.update"],
["Service", "compute"],
["Host", "compute-1"],
["UUID", "8eba1a6d-43eb-1343-8d1a-5e596f5233b5"],
["Req ID", "req-1368539d-f645-4d96-842e-03b5c5c9dc8c"],
...
],
"[\n \"monitor.info\", \n {\n \"_context_request_id\": \"req-13685e9d-f645-4d96-842e-03b5c5c9dc8c\", \n \"_context_quota_class\": null, \n \"event_type\": \"compute.instance.update\", \n \"_context_service_catalog\": [], \n \"_context_auth_token\": \"d81a25d03bb340bb82b4b67d105cc42d\", \n \"_context_user_id\": \"b83e2fac644c4215bc449fb4b5c9bbfa\", \n \"payload\": {\n \"state_description\": \"\", \n \"availability_zone\": null, \n \"terminated_at\": \"\", \n \"ephemeral_gb\": 300, \n ...",
"8eba1a6d-43eb-1343-8d1a-5e596f5233b5"
]
:query service: ``nova`` or ``glance``. default="nova"
:query event_id: desired Event ID
stacky/watch/<deployment_id>
============================
.. http:get:: http://example.com/stacky/watch/<deployment_id>/
Get a real-time feed of notifications.
Once again, this is a non-standard response (not the typical row-column format).
This call returns a tuple of information:
* A list of column widths, to be used as a hint for formatting.
* A list of events that meet the query criteria.
* the db id of the event
* the type of event (``E`` for errors, ``.`` otherwise)
* stringified date of the event
* stringified time of the event
* deployment name
* the event name
* the instance UUID, if available
* The ending unixtime timestamp. The last time covered by this query
(utcnow, essentially)
**Example request**:
.. sourcecode:: http
GET /stacky/watch/14/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
[10, 1, 15, 20, 50, 36],
[
... events ...
]
"1389892207"
]
:query service: ``nova`` or ``glance``. default="nova"
:query since: get all events since ``unixtime``. Defaults to 2 seconds ago.
:query event_name: only watch for ``event_name`` notifications. Defaults to all events.
stacky/search
=============
.. http:get:: http://example.com/stacky/search/
Search for notifications.
Returns:
* Event ID
* ``E`` for errors, ``.`` otherwise
* unixtime for when the event was generated
* the deployment name
* the event name
* the host name
* the instance UUID
* the request ID
**Example request**:
.. sourcecode:: http
GET /stacky/search/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
[...event info as listed above...]
]
:query service: ``nova`` or ``glance``. default="nova"
:query field: notification field to search on.
:query value: notification values to find.
:query when_min: unixtime to start search
:query when_max: unixtime to end search
stacky/usage/launches
=====================
.. http:get:: http://example.com/stacky/launches/
Return a list of all instance launches.
**Example request**:
.. sourcecode:: http
GET /stacky/usages/launches/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
["UUID", "Launched At", "Instance Type Id", "Instance Flavor Id"],
[
... usage launch records ...
]
]
:query instance: desired instance UUID (optional)
stacky/usage/deletes
====================
.. http:get:: http://example.com/stacky/deletes/
Return a list of all instance deletes.
**Example request**:
.. sourcecode:: http
GET /stacky/usages/deletes/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
["UUID", "Launched At", "Deleted At"]
[
... usage deleted records ...
]
]
:query instance: desired instance UUID (optional)
stacky/usage/exists
===================
.. http:get:: http://example.com/stacky/exists/
Return a list of all instance exists notifications.
**Example request**:
.. sourcecode:: http
GET /stacky/usages/exists/ HTTP/1.1
Host: example.com
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/json
[
["UUID", "Launched At", "Deleted At", "Instance Type Id",
"Instance Flavor Id", "Message ID", "Status"]
[
... usage exists records ...
]
]
:query instance: desired instance UUID (optional)

258
docs/conf.py Normal file
View File

@ -0,0 +1,258 @@
# -*- coding: utf-8 -*-
#
# StackTach documentation build configuration file, created by
# sphinx-quickstart on Tue Jan 14 14:34:29 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinxcontrib.httpdomain']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'StackTach'
copyright = u'2014, Sandy Walsh'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '1.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'StackTachdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'StackTach.tex', u'StackTach Documentation',
u'Sandy Walsh', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'stacktach', u'StackTach Documentation',
[u'Sandy Walsh'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'StackTach', u'StackTach Documentation',
u'Sandy Walsh', 'StackTach', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False

BIN
docs/images/diagram.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

24
docs/index.rst Normal file
View File

@ -0,0 +1,24 @@
.. StackTach documentation master file, created by
sphinx-quickstart on Tue Jan 14 14:34:29 2014.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to StackTach's documentation!
=====================================
Contents:
.. toctree::
:maxdepth: 3
intro
setup
api
Indices and tables
==================
* :ref:`genindex`
* :ref:`search`

39
docs/intro.rst Normal file
View File

@ -0,0 +1,39 @@
An Introduction to StackTach
============================
StackTach was initially created as a browser-based debugging tool
for OpenStack Nova. Since that time, StackTach has evolved into a
tool that can do debugging, performance monitoring and perform
audit, validation and reconcilation of Nova and Glance usage in a
manner suitable for billing.
How it works
************
Nearly all OpenStack components are capable of generating
*notifications* when significant events occur. Notifications
are messages placed on the OpenStack queue (generally RabbitMQ)
for consumption by downstream systems.
The OpenStack wiki has info on the `notification format`_.
.. _notification format: http://wiki.openstack.org/SystemUsageData
StackTach has a *worker* that is configured to read these notifications
and store them in a database (ideally a database separate from the
OpenStack production database). From there, StackTach reviews the stream
of notifications to glean usage information and assemble it in an
easy-to-query fashion.
Users can inquire on instances, requests, servers, etc using the
browser interface or command line tool (`Stacky`_).
.. _Stacky: https://github.com/rackerlabs/stacky
.. image:: images/diagram.gif
To get a general sense of notification adoption across OpenStack projects `read this blog post`_
.. _read this blog post: http://www.sandywalsh.com/2013/09/notification-usage-in-openstack-report.html

114
docs/setup.rst Normal file
View File

@ -0,0 +1,114 @@
Installing StackTach
####################
The "Hurry Up" Install Guide
****************************
#. Create a database for StackTach to use. By default, StackTach assumes MySql, but you can modify the settings.py file to others.
#. Install django and the other required libraries listed in ``./etc/pip-requires.txt`` (please let us know if any are missing)
#. Clone this repo
#. Copy and configure the config files in ``./etc`` (see below for details)
#. Create the necessary database tables (python manage.py syncdb) You don't need an administrator account since there are no user profiles used.
#. Configure OpenStack to publish Notifications back into RabbitMQ (see below)
#. Restart the OpenStack services.
#. Run the Worker to start consuming messages. (see below)
#. Run the web server (``python manage.py runserver``)
#. Point your browser to ``http://127.0.0.1:8000`` (the default server location)
#. Click on stuff, see what happens. You can't hurt anything, it's all read-only.
Of course, this is only suitable for playing around. If you want to get serious about deploying StackTach you should set up a proper webserver and database on standalone servers. There is a lot of data that gets collected by StackTach (depending on your deployment size) ... be warned. Keep an eye on DB size.
The Config Files
****************
There are two config files for StackTach. The first one tells us where the second one is. A sample of these two files is in ``./etc/sample_*``. Create a local copy of these files and populate them with the appropriate config values as described below.
The ``sample_stacktach_config.sh`` shell script defines the necessary environment variables StackTach needs. Most of these are just information about the database (assuming MySql) but some are a little different. Copy this file and modify it for your environment. ``source`` this
``stacktach_config.sh`` shell script to set up the necessary environment variables.
``STACKTACH_INSTALL_DIR`` should point to where StackTach is running out of. In most cases this will be your repo directory, but it could be elsewhere if your going for a proper deployment.
The StackTach worker needs to know which RabbitMQ servers to listen to. This information is stored in the deployment file. ``STACKTACH_DEPLOYMENTS_FILE`` should point to this json file. To learn more about the deployments file, see further down.
Finally, ``DJANGO_SETTINGS_MODULE`` tells Django where to get its configuration from. This should point to the ``setting.py`` file. You shouldn't have to do much with the ``settings.py`` file and most of what it needs is in these environment variables.
The ``sample_stacktach_worker_config.json`` file tells StackTach where each of the RabbitMQ servers are that it needs to get events from. In most cases you'll only have one entry in this file, but for large multi-cell deployments, this file can get pretty large. It's also handy for setting up one StackTach for each developer environment.
The file is in json format and the main configuration is under the ``deployments`` key, which should contain a list of deployment dictionaries.
A blank worker config file would look like this: ::
{"deployments": [] }
But that's not much fun. A deployment entry would look like this: ::
{"deployments": [
{
"name": "east_coast.prod.cell1",
"durable_queue": false,
"rabbit_host": "10.0.1.1",
"rabbit_port": 5672,
"rabbit_userid": "rabbit",
"rabbit_password": "rabbit",
"rabbit_virtual_host": "/",
"topics": {
"nova": [
{"queue": "notifications.info", "routing_key": "notifications.info"},
{"queue": "notifications.error", "routing_key": "notifications.error"},
]
}
}
]}
where, *name* is whatever you want to call your deployment, and *rabbit_\** are the connectivity details for your rabbit server. It should be the same information in your `nova.conf` file that OpenStack is using. Note, json has no concept of comments, so using ``#``, ``//`` or ``/* */`` as a comment won't work.
By default, Nova uses ephemeral queues. If you are using durable queues, be sure to change the necessary flag here.
The topics section defines which queues to pull notifications from. You should
pull notifications from all related queues (``.error``, ``.info``, ``.warn``, etc)
You can add as many deployments as you like.
Starting the Worker
===================
Note: the worker now uses librabbitmq, be sure to install that first.
``./worker/start_workers.py`` will spawn a worker.py process for each deployment defined. Each worker will consume from a single Rabbit queue.
Configuring Nova to Generate Notifications
==========================================
In the OpenStack service you wish to have generate notifications, add the
following to its ``.conf`` file: ::
--notification_driver=nova.openstack.common.notifier.rpc_notifier
--notification_topics=monitor
**Note:** *This will likely change once the various project switch to ``oslo.messaging``
which uses endpoints to define the notification drivers.*
This will tell OpenStack to publish notifications to a Rabbit exchange starting with
``monitor.*`` ... this may result in ``monitor.info``, ``monitor.error``, etc.
You'll need to restart Nova once these changes are made.
If you're using `DevStack`_ you may want to set up your ``local.conf`` to include the following: ::
[[post-config|$NOVA_CONF]]
[DEFAULT]
notification_driver=nova.openstack.common.notifier.rpc_notifier
notification_topics=notifications,monitor
notify_on_state_change=vm_and_task_state
notify_on_any_change=True
instance_usage_audit=True
instance_usage_audit_period=hour
.. _DevStack: http://devstack.org/
Next Steps
==========
Once you have this working well, you should download and install ``Stacky`` and play with the command line tool.

View File

@ -7,4 +7,5 @@ prettytable>=0.7.2
argparse
Pympler
requests
south
south
sphinxcontrib-httpdomain