Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

Helping platform leaders, architects, engineers, and operators build scalable real time data platforms.

7/15/2021

Reading time:1 min

esatterly/splunk-cassandra

by esatterly

Splunk Cassandra ConnectRequiresSplunk Python SDK libs intalled or splunk-sdk-python on PYTHONPATHCassandraResources:$CASSANDRA_HOME/README.txthttp://wiki.apache.org/cassandra/GettingStartedContribpycassa 1.7.2Installed in {app}/bin/pycassaCQL 1.4.0Installed in {app}/bin/cqlRunning the applicationStart Cassandra Cluster and verify listening on 9160Inspecting CassandraLaunch the Cassandra CLIcd $CASSANDRA_HOME/bin./cassandra-cli --host localhostGet listing of available keyspaces:show keyspaces;Initial App Setupedit {app}/bin/setting.pyset Cassandra Host and Port## Note v.Next will have UI setup for multi clusterInstall universal forwarder on all cassandra nodes Add a splunk forwarder and this entry to /loca/inputs.conf [monitor:///var/log/cassandra/*] index=casslogsVerify logs are coming into the casslogs indexRun {app}/bin/python dbschema.py and verify keyspace config shows upRun {app}/bin/python dbdiscover.py and verify all Column_Families show upCommands Info[dbcql]dbcql.pyUSAGE: dbcql {query}# A query may consist of multiple expressions. We execute each of# the expressions in order and output the results from the final# expression. The primary scenario is:## "USE {keyspace}; SELECT * FROM {Column_family} WHERE {Conditions}""#[dbinsert]dbinsert.pyUsage: dbinsert {cfpath} {key} {fields}# cfpath must be Keyspace.Column_family notation[dblookup]dblookup.pyUsage: dblookup {cfpath} {key}# cfpath must be Keyspace.Column_family notation[dbschema]dbschema.pyUSAGE: dbschema << None OR Keyspace OR Keyspace Column_Family# Can use No parameters for cluster, a Keyspace or a Keyspace Column_family# dbschema ## Returns all schema information on cluster# dbschema {Keyspace} ## Returns all schema information for Keyspace = schema1# dbschema {Keyspace} {Column_family} ## Returns all schema information for Column_Family[dbgetkeys]dbgetkeys.pyUsage: dbgetkeys {Keyspace Column_Family}# Must be run with both elements Keyspace and Column_family# Returns a complete list of Row Keys in format Keyspace,Column_Family,Key[dbdiscover]dbdiscover.pyUsage: dbdiscover# Collects all keyspaces and column_families on the cluster in# keyspace=system,column_family=schema_keyspaces formatConfiguration Verification| dbcql "create keyspace test with strategy_class='LocalStrategy'"| dbschema| dbcql "use test; create columnfamily test (KEY varchar PRIMARY KEY)"| dbschema test.test| dbinsert test.test user_id "johnsmith,jsmith"| dbcql "use test; select * from test"| dbcql "use test; select * from test" | search jsmith | stats count| dbcql "use test; drop columnfamily test"| dbschema test| dbcql "drop keyspace test"| dbschema

Illustration Image

Splunk Cassandra Connect

Requires

Contrib

  • pycassa 1.7.2

    • Installed in {app}/bin/pycassa
  • CQL 1.4.0

    • Installed in {app}/bin/cql

Running the application

Start Cassandra Cluster and verify listening on 9160

Inspecting Cassandra

Launch the Cassandra CLI

cd $CASSANDRA_HOME/bin
./cassandra-cli --host localhost

Get listing of available keyspaces:

show keyspaces;

Initial App Setup

edit {app}/bin/setting.py
set Cassandra Host and Port
## Note v.Next will have UI setup for multi cluster
Install universal forwarder on all cassandra nodes 
Add a splunk forwarder and this entry to /loca/inputs.conf
           [monitor:///var/log/cassandra/*] 
           index=casslogs
Verify logs are coming into the casslogs index
Run {app}/bin/python dbschema.py and verify keyspace config shows up
Run {app}/bin/python dbdiscover.py and verify all Column_Families show up

Commands Info

[dbcql] dbcql.py USAGE: dbcql {query} # A query may consist of multiple expressions. We execute each of # the expressions in order and output the results from the final # expression. The primary scenario is: # # "USE {keyspace}; SELECT * FROM {Column_family} WHERE {Conditions}"" #

[dbinsert] dbinsert.py Usage: dbinsert {cfpath} {key} {fields} # cfpath must be Keyspace.Column_family notation

[dblookup] dblookup.py Usage: dblookup {cfpath} {key} # cfpath must be Keyspace.Column_family notation

[dbschema] dbschema.py USAGE: dbschema << None OR Keyspace OR Keyspace Column_Family # Can use No parameters for cluster, a Keyspace or a Keyspace Column_family # dbschema ## Returns all schema information on cluster # dbschema {Keyspace} ## Returns all schema information for Keyspace = schema1 # dbschema {Keyspace} {Column_family} ## Returns all schema information for Column_Family

[dbgetkeys] dbgetkeys.py Usage: dbgetkeys {Keyspace Column_Family} # Must be run with both elements Keyspace and Column_family # Returns a complete list of Row Keys in format Keyspace,Column_Family,Key

[dbdiscover] dbdiscover.py Usage: dbdiscover # Collects all keyspaces and column_families on the cluster in
# keyspace=system,column_family=schema_keyspaces format

Configuration Verification

| dbcql "create keyspace test with strategy_class='LocalStrategy'"

| dbschema

| dbcql "use test; create columnfamily test (KEY varchar PRIMARY KEY)"

| dbschema test.test

| dbinsert test.test user_id "johnsmith,jsmith"

| dbcql "use test; select * from test"

| dbcql "use test; select * from test" | search jsmith | stats count

| dbcql "use test; drop columnfamily test"

| dbschema test

| dbcql "drop keyspace test"

| dbschema

Related Articles

cluster
troubleshooting
datastax

GitHub - arodrime/Montecristo: Datastax Cluster Health Check Tooling

arodrime

4/3/2024

Checkout Planet Cassandra

Claim Your Free Planet Cassandra Contributor T-shirt!

Make your contribution and score a FREE Planet Cassandra Contributor T-Shirt! 
We value our incredible Cassandra community, and we want to express our gratitude by sending an exclusive Planet Cassandra Contributor T-Shirt you can wear with pride.

Join Our Newsletter!

Sign up below to receive email updates and see what's going on with our company

Explore Related Topics

AllKafkaSparkScyllaSStableKubernetesApiGithubGraphQl

Explore Further

cassandra