Git Product home page Git Product logo

snap-plugin-publisher-cassandra's Introduction

DISCONTINUATION OF PROJECT.

This project will no longer be maintained by Intel.

This project has been identified as having known security escapes.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

DISCONTINUATION OF PROJECT

This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this project, including but not limited to, maintenance, bug fixes, new releases or updates. Patches to this project are no longer accepted by Intel. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the community, please create your own fork of the project.

Snap Cassandra publisher plugin

This plugin publishes snap metric data into Cassandra database.

It's used in the snap framework.

  1. Getting Started
  1. Documentation
  1. Community Support
  2. Contributing
  3. License
  4. Acknowledgements

Getting Started

System Requirements

Operating systems

All OSs currently supported by snap:

  • Linux/amd64
  • Darwin/amd64

Installation

Download cassandra publisher plugin binary:

You can get the pre-built binaries for your OS and architecture at snap's Github Releases page.

Building from source

  • Get the package: go get github.com/intelsdi-x/snap-plugin-publisher-cassandra
  • Build the snap-plugin-publisher-cassandra plugin
  1. From the root of the snap-plugin-publisher-cassandra path type make all.
  • This builds the plugin in /build/rootfs/.

Configuration and Usage

  • Set up the snap framework
  • Ensure $SNAP_PATH is exported export SNAP_PATH=$GOPATH/src/github.com/intelsdi-x/snap/build
  • Ensure 'server' is defined in the task manifest.
  • $SNAP_CASSANDRA_HOST may be exported only for the integration/unit testing

Install Cassandra

  • install Cassandra using Docker
 docker run --name snap-cassandra -p 9042:9042 -d cassandra:latest
  • install Cassandra on Mac OSX
 brew install cassandra

Documentation

Suitable Metrics

All metrics exposed by snap collector plugins. Currently, it only supports the number, string, and boolean data types. Number data types are integers and floats. Plugin stores numbers inside Cassandra as doubles.

Plugin Database Schema

Metric data always goes in the table metrics of the keyspace snap. The primary key for table metrics is the combination of a metric namespace, version, and the running host.

CREATE TABLE snap.metrics (
	ns  text, 
	ver int, 
	host text, 
	time timestamp, 
    valtype text,
	doubleVal double, 
    boolVal boolean,
    strVal text,
	tags map<text,text>, 
	PRIMARY KEY ((ns, ver, host), time))
) WITH CLUSTERING ORDER BY (time DESC);

Metric data goes into the table tag only when the tagIndex is giving in a publisher config. tagIndex is a comma separatored tag list. Please refer to here for details.

CREATE TABLE snap.tags (
    key text,  
    val text,  
    time timestamp, 
    ns  text, 
    ver int,   
    host text,  
    valType text,   
    doubleVal double,   
    strVal text,   
    boolVal boolean,   
    tags map<text,text>,   
    PRIMARY KEY ((key, val), time, ns, ver, host))
) WITH CLUSTERING ORDER BY (time DESC);

Examples

Let's get started. For example:

Dockerized example

Install Cassandra

$  docker run --name snap-cassandra-1 -p 9042:9042 -d cassandra:latest
17d007776bcd9efa55d89640dcfe9e3ff4baf54468eb3ab8716270d95adc262c

Verify Cassandra Instance

$ docker run -it --rm --net container:snap-cassandra-1 cassandra cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.3 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cqlsh> desc keyspaces;

system_traces  system_schema  system_auth  system  system_distributed

cqlsh> 

In one terminal window, start the snap daemon (in this case with logging set to 1 and trust disabled):

$ $SNAP_PATH/bin/snapd -l 1 -t 0
INFO[0000] Starting snapd (version: v0.11.0-beta-84-g3b1ae75) 
INFO[0000] setting GOMAXPROCS to: 1 core(s)             
INFO[0000] control started                               _block=start _module=control
INFO[0000] module started                                _module=snapd block=main snap-module=control

In another terminal window: Load snap collector plugins. For example:

$ $SNAP_PATH/bin/snapctl plugin load $SNAP_PATH/../../snap-plugin-collector-psutil/build/rootfs/snap-plugin-collector-psutil
Plugin loaded
Name: psutil
Version: 5
Type: collector
Signed: false
Loaded Time: Thu, 25 Feb 2016 13:00:24 PST

Load snap passthrough processor plugin

$ $SNAP_PATH/bin/snapctl plugin load $SNAP_PATH/plugin/snap-plugin-processor-passthru
Plugin loaded
Name: passthru
Version: 1
Type: processor
Signed: false
Loaded Time: Thu, 25 Feb 2016 13:00:35 PST

Load snap cassandra publisher plugin

$ $SNAP_PATH/bin/snapctl plugin load <path to snap-plugin-publisher-cassandra plugin binary>
Plugin loaded
Name: cassandra
Version: 1
Type: publisher
Signed: false
Loaded Time: Thu, 25 Feb 2016 13:00:48 PST

Create tasks. For example:

$ $SNAP_PATH/bin/snapctl task create -t /tmp/cassandra-task.json
Using task manifest to create task
Task created
ID: f5dda751-c4db-4361-8a63-ced153aa6550
Name: Task-f5dda751-c4db-4361-8a63-ced153aa6550
State: Running

The example task manifest file, cassandra-task.json. Note that server in the publisher config is mandatory but tagIndex is optional. Specifying tagIndex only when you like to do read queries for tags.

{
    "_comment": "tagIndex in the publish config is optional",
    "version": 1,
    "schedule": {
        "type": "simple",
        "interval": "1s"
    },
    "workflow": {
        "collect": {
            "metrics": {
                "/intel/psutil/load/load1": {},
                "/intel/psutil/load/load5": {},
                "/intel/psutil/load/load15": {},
                "/intel/psutil/vm/available": {},
                "/intel/psutil/vm/free": {},
                "/intel/psutil/vm/used": {}
            },
            "config": {},
            "process": null,
            "publish": [
                {
                    "plugin_name": "cassandra",                            
                    "config": {
                        "server": "SNAP_CASSANDRA_HOST",
                        "tagIndex": "experimentId,scope"
                    }
                }
            ]                                            
        }
    }
}

Snap cassandra publisher allows also for configuring ssl encryption. To enable ssl, a flag ssl has to be set to true in the plugin config. It is possible to configure following ssl options:

  • username - Name of a user used to authenticate to Cassandra
  • password - Password used to authenticate to the Cassandra
  • keyPath - Path to the private key for the Cassandra client
  • certPath - Path to the self signed certificate for the Cassandra client
  • caPath - Path to the CA certificate for the Cassandra server
  • serverCertVerification - If true, verify a hostname and a server key, default: true

Sample snap cassandra CQL shown:

cqlsh:snap> select * from metrics limit 100;

 ns                      | ver | host          | time                     | boolval | doubleval | strval | tags | valtype
-------------------------+-----+---------------+--------------------------+---------+-----------+--------+------+---------
 intel/psutil/load/load1 |   0 | egu-mac01.lan | 2016-03-29 03:04:52+0000 |    null |      2.44 |   null | null |  double
 intel/psutil/load/load1 |   0 | egu-mac01.lan | 2016-03-29 03:04:51+0000 |    null |      2.44 |   null | null |  double
 intel/psutil/load/load1 |   0 | egu-mac01.lan | 2016-03-29 03:04:50+0000 |    null |      2.57 |   null | null |  double
 intel/psutil/load/load1 |   0 | egu-mac01.lan | 2016-03-29 03:04:49+0000 |    null |      2.57 |   null | null |  double
 intel/psutil/load/load1 |   0 | egu-mac01.lan | 2016-03-29 03:04:48+0000 |    null |      2.57 |   null | null |  double
 ...
 intel/psutil/load/load1 |   0 | egu-mac01.lan | 2016-03-29 03:03:15+0000 |    null |      3.22 |   null | null |  double
 intel/psutil/load/load1 |   0 | egu-mac01.lan | 2016-03-29 03:03:14+0000 |    null |      3.22 |   null | null |  double
 intel/psutil/load/load1 |   0 | egu-mac01.lan | 2016-03-29 03:03:13+0000 |    null |      3.22 |   null | null |  double

(100 rows)
cqlsh:snap>

Roadmap

This plugin is still in active development. As we launch this plugin, we have a few items in mind for the next few releases:

  • Additional error handling
  • Testing in a large cluster

If you have a feature request, please add it as an issue and/or submit a pull request.

Community Support

This repository is one of many plugins in snap, a powerful telemetry framework. See the full project at http://github.com/intelsdi-x/snap.

To reach out to other users, head to the main framework.

Contributing

We love contributions!

There's more than one way to give back, from examples to blogs to code updates. See our recommended process in CONTRIBUTING.md.

License

snap, along with this plugin, is an Open Source software released under the Apache 2.0 License.

Acknowledgements

And thank you! Your contribution, through code and participation, is incredibly important to us.

snap-plugin-publisher-cassandra's People

Contributors

candysmurf avatar daria-lewandowska avatar iwankgb avatar izabellaraulin avatar katarzyna-z avatar marcin-krolik avatar marcintao avatar nanliu avatar rdower avatar squall0gd avatar taotod avatar zhengqingyuan avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snap-plugin-publisher-cassandra's Issues

Medium tests are flaky

What happened:

Publish integer metric FATA[0001] gocql: no response received from cassandra within timeout period 

What you expected to happen:
Tests to pass.

Steps to reproduce it (as minimally and precisely as possible):

  1. make test-medium

Wrong timestamp in database

In line 121 of client go (and two more lines in the same function) metric timestamp is set to time.Now(). This is not true and cause same metric to be insterted multiple time into the database. Consider following scenario:

As the primary key is defined as:

Snap version (use snapctl -v): any

Environment:

  • Cloud provider or hardware configuration: irrelevant
  • OS (e.g. from /etc/os-release): irrelevant
  • Kernel (e.g. uname -a): irrelevant
  • Relevant tools (e.g. plugins used with Snap): no relevant tools
  • Others (e.g. deploying with Ansible): none

What happened:

  1. Collector returns a metric, eg:
NAMESPACE                                                                DATA            TIMESTAMP
/intel/swan/mutilate/ip-172-31-60-18/avg                                 55              2016-12-01 15:38:18.031344414 +0000 UTC
  1. Publisher attempts to insert the metric with modified timestamp.
  2. Collector returns same metric as in step 1.
  3. Publisher attempts to insert the metric with modified timestamp (and succeeds as primary key is unique)

What you expected to happen:

  1. Collector returns a metric, eg:
NAMESPACE                                                                DATA            TIMESTAMP
/intel/swan/mutilate/ip-172-31-60-18/avg                                 55              2016-12-01 15:38:18.031344414 +0000 UTC
  1. Publisher inserts the metric with original timestamp.
  2. Collector returns same metric as in step 1.
  3. Publisher attempts to insert the metric with original timestamp (and insert is not performed as primary key would not be unique)

Steps to reproduce it (as minimally and precisely as possible):

Described above.

Anything else do we need to know (e.g. issue happens only occasionally):

None.

Tags indexing

As of now schema of metrics table make executing following query impossible:

select * from metrics where tags['swan_experiment'] = 'example-experiment'; 

The query is invalid because of following error: InvalidRequest: code=2200 [Invalid query] message="No supported secondary index found for the non primary key columns restrictions". It would be great if tags column where indexed as it would allow us to query by tags without exploiting ALLOW FILTERING that may affect performance significantly.

Cassandra version: 3.3.

schema improvements

The current schema won't hold up under real usage.

The partitions need a bucketing strategy applied so to prevent rows from ever growing. A time bucket resolution should be chosen so to avoid partitions larger than 100MB.

And the TimeWindowCompactionStrategy should be applied given this is a time-series datamodel.

For example:

CREATE TABLE snap.metrics (
    time_bucket timestamp,
    ns text,
    ver int,
    host text,
    time timestamp,
    boolval boolean,
    doubleval double,
    strval text,
    tags map<text, text>,
    valtype text,
    PRIMARY KEY ((time_bucket, ns, ver, host), time)
) WITH CLUSTERING ORDER BY (time DESC)
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'}';

CREATE TABLE snap.tags (
    time_bucket timestamp,
    key text,
    val text,
    time timestamp,
    boolval boolean,
    doubleval double,
    host text,
    ns text,
    strval text,
    tags map<text, text>,
    valtype text,
    ver int,
    PRIMARY KEY ((time_bucket, key, val), time)
) WITH CLUSTERING ORDER BY (time DESC)
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'}

Plugin release failing

The s3 binary upload/gh release process is failing in this repo. The s3 api keys have been verified, but it's failing in travis ci. At this point merges will not publish new binaries. Please do not attempt to release version 5 until this is resolved.

Failing unit tests

Currently unit tests are failing, locally and on Travis. This is the issue with how unit tests are written, not Travis itself. Some obvious problems:

  • main() is panicking because Close() is calling cas.client.session.Close() without checking if client is not null
  • in cassandra_test.go &cassandraPublisher{} should be &CassandraPublisher{}
  • unit tests require SNAP_CASSANDRA_HOST env. variable to be set - should not be needed for unit test
  • unit tests are failing on following checks: "So config policy should process testConfig and return a config" and "So testConfig processing should return no errors"

Errors in integration tests

Executing make check TEST=integration I'm receiving following output:

make test
make[1]: Entering directory '/home/kzab/work/src/github.com/intelsdi-x/snap-plugin-publisher-cassandra'
bash -c "./scripts/test.sh integration"
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/gcc.dg/cpp: read /home/kzab/Downloads/gcc-6.1.0/gcc/testsuite/gcc.dg/cpp/dir-only-6.c: syntax error
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/gcc.dg/cpp/trad: read /home/kzab/Downloads/gcc-6.1.0/gcc/testsuite/gcc.dg/cpp/trad/comment.c: syntax error
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test: found packages main (235.go) and _ (blank1.go) in /home/kzab/Downloads/gcc-6.1.0/gcc/testsuite/go.test/test
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/bench/shootout: C source files not allowed when not using cgo or SWIG: binary-tree.c chameneosredux.c fannkuch.c fasta.c k-nucleotide.c mandelbrot.c meteor-contest.c nbody.c pidigits.c regex-dna.c reverse-complement.c spectral-norm.c threadring.c
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/ddd2.dir: found packages ddd (ddd2.go) and main (ddd3.go) in /home/kzab/Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/ddd2.dir
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/dwarf: found packages ignored (dwarf.go) and main (linedirectives.go) in /home/kzab/Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/dwarf
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs: 
Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/bug050.go:7:1: expected 'package', found 'func'
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/bug083.dir: found packages bug0 (bug0.go) and bug1 (bug1.go) in /home/kzab/Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/bug083.dir
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/bug088.dir: found packages bug0 (bug0.go) and main (bug1.go) in /home/kzab/Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/bug088.dir
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/bug106.dir: found packages bug0 (bug0.go) and bug1 (bug1.go) in /home/kzab/Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/bug106.dir
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/bug133.dir: found packages bug0 (bug0.go) and bug1 (bug1.go) in /home/kzab/Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/bug133.dir
can't load package: package ./Downloads/gcc-6.1.0/gcc/testsuite/go.test/test/fixedbugs/b
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.