Skip to content
Jesse White edited this page Oct 8, 2015 · 3 revisions

Running a REST Service

Newts provides a REST endpoint service based on the popular Dropwizard project.

A one-time initialization must be performed before starting the service for the first time; The init script accepts as it's only argument, a Newts config file, and when invoked creates all necessary Cassandra schema.

bin/init etc/config.yaml

Running the bin/newts with no arguments outputs command synopsis.

bin/newts
Usage: java NewtsDaemon -c CFGFILE [-D] [-p PIDFILE] [-h]
  -D (--daemonize)      : Detach and run in the background
  -c (--config) CFGFILE : Path to configuration file (required).
  -h (--help)           : Print usage informations.
  -p (--pid) PIDFILE    : Path to PID file (default: newtsd.pid)

To run Newts in the foreground (the default):

bin/newts -c etc/config.yaml

To daemonize, and store the PID in /var/run/newts.pid:

bin/newts -D -p /var/run/newts.pid -f etc/config.yaml
cassandra:
  keyspace: newts
  host: localhost
  port:9042
  username: cassandra
  password: cassandra
  time-to-live: 31536000
  compression: none
Name Default Description
keyspace newts Cassandra keyspace name.
host localhost Hostname of Cassandra node/cluster.
port 9042 TCP port number of Cassandra node/cluster.
username cassandra Username used to connect to the Cassandra node/cluster.
password cassandra Password used to connect to the Cassandra node/cluster.
time-to-live 31536000 Seconds to expiration of Cassandra columns.
compression none Compression scheme to use for Cassandra queries. One of none, lzr, or snappy.
search:
  enabled: true
  maxCacheEntries: 1000000
  hierarchical-indexing: true
  separatorEscaping: false
Name Default Description
enabled false Determines whether search indexing should be enabled.
maxCacheEntries 1000000 The number of previously indexed resources to maintain a cached state of (avoids unnecessary, redundant (re)indexing).
hierarchical-indexing true Indexes additional terms that allow the resource tree to be discovered. See NEWTS-57 for details.
separatorEscaping false Allows resource id separators (:) to be escaped using a backslash (:)
reports:
  temps:
    interval: 300s
    datasources:
      - label: inlet
        source: inletTemp
        function: AVERAGE
        heartbeat: 600s
      - label: outlet
        source: outletTemp
        function: AVERAGE
        heartbeat: 600s
    expressions:
      - label: diff
        expression: outlet - inlet
    exports:
      - inlet
      - outlet
      - diff
Name Default Description
interval (none) The expected sample interval. Intervals are specified as a numeric value followed by one of w, d, h, m, s, and ms (for weeks, days, hours, minutes, seconds, and millseconds respectively).
Name Default Description
label (none) The name of the aggregated datasource.
source (none) Stored metric name.
function (none) Aggregate function (currently one of MIN, MAX, AVERAGE).
heartbeat (none) Upper bound on sample intervals; Values outside heartbeat yield a NaN during aggregation. Specified as a numeric value followed by one of w, d, h, m, s, and ms (for weeks, days, hours, minutes, seconds, and millseconds respectively).
Name Default Description
label (none) Name of the expression result.
expression (none) The expression to evaluate.

Exports consist of a list of valid datasource and expression labels from the report scope that should be exported to the result set.

The complete Dropwizard Configuration Reference.