Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude keyspaces matching regex patterns #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ The available command line options may be seen by passing `-h`/`--help`:
Record the cumulative time taken to run each collector
and export the results.
--exclude-keyspaces=<excludedKeyspaces>

Exclude keyspaces matching the specified regex pattern.
-e, --exclude=EXCLUSION...
Exclude a metric family or MBean from exposition.
EXCLUSION may be the full name of a metric family
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ private Iterator<Factory> tableMetricFactory(final Set<TableMetricScope> tableMe

final String keyspaceName = keyPropertyList.get("keyspace");

if (excludedKeyspaces.contains(keyspaceName)) {
if (excludedKeyspaces.stream().anyMatch(p -> keyspaceName.matches(p))) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public void setNoFastFloat(final boolean noFastFloat) {
public boolean collectorTimingEnabled;


@Option(names = "--exclude-keyspaces")
@Option(names = "--exclude-keyspaces",
description = "Exclude keyspaces matching the specified regex pattern.")
public Set<String> excludedKeyspaces = new HashSet<>();

@Option(names = "--exclude-system-tables",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Stream<MetricFamily> collect() {

{
final Stream<NumericMetric> ownershipMetricStream = metadataFactory.keyspaces().stream()
.filter(keyspace -> !excludedKeyspaces.contains(keyspace))
.filter(keyspace -> !excludedKeyspaces.stream().anyMatch(p -> keyspace.matches(p)))
.flatMap(keyspace -> {
try {
return storageServiceMBean.effectiveOwnership(keyspace).entrySet().stream()
Expand Down
12 changes: 9 additions & 3 deletions install-ccm.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/usr/bin/env bash

HERE="$(dirname "$(readlink -f "$0")")"

AGENT="$HERE/agent/target/cassandra-exporter-agent-0.9.11-SNAPSHOT.jar"

find . -path '*/node*/conf/cassandra-env.sh' | while read file; do
echo "Processing $file"

port=$((19499+$(echo ${file} | sed 's/[^0-9]*//g')))

sed -i -e "/cassandra-exporter/d" "${file}"

echo "JVM_OPTS=\"\$JVM_OPTS -javaagent:/home/adam/Projects/cassandra-exporter/agent/target/cassandra-exporter-agent-0.9.4-SNAPSHOT.jar=--listen=:${port},--cache=true,--enable-collector-timing\"" >> \
"${file}"
done;
cat <<EOF >> "${file}"
JVM_OPTS="\$JVM_OPTS -javaagent:$AGENT=--listen=:${port},--enable-collector-timing"
EOF

done;