Skip to content

Commit

Permalink
v0.0.5 (#4)
Browse files Browse the repository at this point in the history
Added HTTPS support to the Prometheus endpoint.
Changed the name to adhere to the Apache Software Foundation's (ASF) trademark policies
Code cleanup.
  • Loading branch information
dhoard authored Feb 16, 2023
1 parent 14cfb8b commit 935ef9a
Show file tree
Hide file tree
Showing 18 changed files with 574 additions and 210 deletions.
76 changes: 68 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ KSyntheticTest is a synthetic test application to measure Kafka produce/consume

## Build

```
```sh
cd <project directory>
mvn clean package
```
Expand All @@ -17,23 +17,72 @@ mvn clean package

You need to create a unique test topic per application instance with enough partitions to span all brokers

### Confluent Cloud

**Step 1**

Confluent Cloud client configuration

1. Login to the Confluent Cloud console
2. Select your environment
3. Select your cluster
4. Using the left menu, select `Java clients`
5. Create a new API key / secret (if required)
6. Copy the properties and merge them into your `test.confluent-cloud.properties`

**Step 2**

Install `kcat` (https://github.com/edenhill/kcat)

**Step 3**

Run `kcat` to get broker information

Example (in a shell):

```shell
export CCLOUD_BROKERS=<BROKER DETAILS>
export CCLOUD_ACCESS_KEY_ID=<CCLOUD-APIKEY>
export CCLOUD_SECRET_ACCESS_KEY=<CCLOUD-APISECRET>

kcat -b ${CCLOUD_BROKERS} -L \
-X security.protocol=SASL_SSL \
-X sasl.mechanisms=PLAIN \
-X sasl.username=${CCLOUD_ACCESS_KEY_ID} \
-X sasl.password=${CCLOUD_SECRET_ACCESS_KEY} \
```

**Notes**

- This application uses manual partition assignment
- dynamic Kafka partition increases are currently not handle


- Example topic name is `kafka-synthetic-test-<id>`... where `<id>` matches the `id` in `test.properties`
- Example topic name is `k-synthetic-test-<id>`
- where `<id>` matches the `id` in test properties


- Example retention time is `300,000` ms (5 minutes) (Old messages are skipped)
- Example retention time is `300,000` ms (5 minutes)
- old messages provide no value, so are skipped


## Run

**Step 1**

Copy `configuration/test.properties` and edit to match your environment

**Step 2**

Run

```shell
java -jar target/k-synthetic-test-0.0.5.jar configuration/test.properties
```

Copy `test.properties` and edit to match your environment
**NOTES**

Execute `./kafka-synthetic-test.sh <test properties>`
Other configuration examples can be found at https://github.com/dhoard/k-synthetic-test/configuration

## Metrics

Expand All @@ -50,9 +99,9 @@ Example output:
```
# HELP kafka_synthetic_test_round_trip_time Kafka synthetic test round trip time
# TYPE kafka_synthetic_test_round_trip_time gauge
kafka_synthetic_test_round_trip_time{id="source-10.0.0.1",bootstrap_servers="cp-3:9092",topic="kafka-synthetic-test",partition="0",} 6.0
kafka_synthetic_test_round_trip_time{id="source-10.0.0.1",bootstrap_servers="cp-3:9092",topic="kafka-synthetic-test",partition="1",} 7.0
kafka_synthetic_test_round_trip_time{id="source-10.0.0.1",bootstrap_servers="cp-3:9092",topic="kafka-synthetic-test",partition="2",} 9.0
kafka_synthetic_test_round_trip_time{id="source-10.0.0.1",bootstrap_servers="cp-3:9092",topic="k-synthetic-test",partition="0",} 6.0
kafka_synthetic_test_round_trip_time{id="source-10.0.0.1",bootstrap_servers="cp-3:9092",topic="k-synthetic-test",partition="1",} 7.0
kafka_synthetic_test_round_trip_time{id="source-10.0.0.1",bootstrap_servers="cp-3:9092",topic="k-synthetic-test",partition="2",} 9.0
```

**Notes**
Expand All @@ -61,3 +110,14 @@ kafka_synthetic_test_round_trip_time{id="source-10.0.0.1",bootstrap_servers="cp-


- A negative value indicates that a metric hasn't been updated within the configured `metric.expiration.period.ms` value

# Notices

Apache, Apache Kafka, Kafka, and associated open source project names are trademarks of the Apache Software Foundation

- https://apache.org/
- https://kafka.apache.org/

Confluent and Confluent Cloud are copyrighted Confluent, Inc. 2014-2023

- https://www.confluent.io/
60 changes: 60 additions & 0 deletions configuration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Configuration examples

----

Filename

- `test.properties`

Configuration scenario

- Basic self-managed Kafka cluster with 3 brokers
- No Kafka authentication
- HTTP BASIC authentication disable
- HTTP SSL server disabled

Usage

```shell
java -jar target/k-synthetic-test-0.0.5.jar configuration/test.properties
```

---

Filename

- `test.ssl.properties`

Configuration scenario

- Basic self-managed Kafka cluster with 3 brokers
- No Kafka authentication
- HTTP BASIC authentication enabled
- HTTP SSL server enabled

```shell
java \
-Djavax.net.ssl.keyStore=configuration/keystore.pkcs12 \
-Djavax.net.ssl.keyStorePassword=changeit \
-jar target/k-synthetic-test-0.0.5.jar configuration/test.ssl.properties
```

---

Filename

- `test.confluent-cloud.properties`

Configuration scenario

- Basic shared Confluent Cloud cluster
- Confluent Cloud authentication
- HTTP BASIC authentication enabled
- HTTP SSL server enabled

```shell
java \
-Djavax.net.ssl.keyStore=configuration/keystore.pkcs12 \
-Djavax.net.ssl.keyStorePassword=changeit \
-jar target/k-synthetic-test-0.0.5.jar configuration/test.confluent-cloud.properties
```
Binary file added configuration/keystore.pkcs12
Binary file not shown.
75 changes: 75 additions & 0 deletions configuration/test.confluent-cloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Test instance id
id=source-10.0.0.1

# Delay period before starting production of test messages
delay.ms=0

# Producer period for test messages
period.ms=1000

#
# Metric expiration TTL (expire data "value = -1.0" if not update within TTL period)
#
# This should be a multiple of "period.ms"
#
# Example:
#
# period.ms=1000
# metric.expiration.period.ms=10000
#
# Results:
#
# Produce messages every 1000 ms
# Set the gauge value to -1 if there hasn't been an update in 10000 ms
#
metric.expiration.period.ms=10000

# Log responses to the console (optional)
#log.responses=true

# HTTP server address to expose metrics
http.server.address=0.0.0.0

# HTTP server port to expose metrics
http.server.port=9191

# HTTP server basic authentication (optional)
#
# If enabled, http.server.basic.authentication.username / http.server.basic.authentication.password required
#
http.server.basic.authentication.enabled=true
http.server.basic.authentication.username=prometheus
http.server.basic.authentication.password=secret

# HTTPS support (optional)
#
# If enabled, Java keystore / truststore system properties
# must be defined along with the certificate alias
#
http.server.ssl.enabled=true
http.server.ssl.certificate.alias=localhost

#
# Topic for test messages
#
# The most common naming pattern would be "k-synthetic-test-<id>"
#
# Example:
#
# id=source-10.0.0.1
# topic=k-synthetic-test-source-10.0.0.1
#
# Example 2:
#
# id=us-east1.project-1.network-1.ip-1.2.3.4
# topic=k-synthetic-test-us-east1.project-1.network-1.ip-1.2.3.4
#
topic=k-synthetic-test-source-10.0.0.1

# Confluent Cloud properties
bootstrap.servers=<Confluent Cloud bootstrap servers>
security.protocol=SASL_SSL
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username='<Confluent Cloud API Key>' password='<Confluent Cloud API Secret';
sasl.mechanism=PLAIN
client.dns.lookup=use_all_dns_ips
session.timeout.ms=45000
77 changes: 77 additions & 0 deletions configuration/test.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Configuration scenario
#
# Basic self-managed Kafka cluster with 3 brokers
# No Kafka authentication
# HTTP authentication disabled
# HTTPS disabled

# Test instance id
id=source-10.0.0.1

# Delay period before starting production of test messages
delay.ms=0

# Producer period for test messages
period.ms=1000

#
# Metric expiration TTL (expire data "value = -1.0" if not update within TTL period)
#
# This should be a multiple of "period.ms"
#
# Example:
#
# period.ms=1000
# metric.expiration.period.ms=10000
#
# Results:
#
# Produce messages every 1000 ms
# Set the gauge value to -1 if there hasn't been an update in 10000 ms
#
metric.expiration.period.ms=10000

# Log responses to the console (optional)
#log.responses=true

# HTTP server address to expose metrics
http.server.address=0.0.0.0

# HTTP server port to expose metrics
http.server.port=9191

# HTTP server basic authentication (optional)
#
# If enabled, http.server.basic.authentication.username / http.server.basic.authentication.password required
#
http.server.basic.authentication.enabled=false
http.server.basic.authentication.username=prometheus
http.server.basic.authentication.password=secret

# HTTPS support (optional)
#
# If enabled, Java keystore / truststore system properties
# must be defined along with the certificate alias
#
http.server.ssl.enabled=false
http.server.ssl.certificate.alias=localhost

#
# Topic for test messages
#
# The most common naming pattern would be "k-synthetic-test-<id>"
#
# Example:
#
# id=source-10.0.0.1
# topic=k-synthetic-test-source-10.0.0.1
#
# Example 2:
#
# id=us-east1.project-1.network-1.ip-1.2.3.4
# topic=k-synthetic-test-us-east1.project-1.network-1.ip-1.2.3.4
#
topic=k-synthetic-test-source-10.0.0.1

# Kafka properties
bootstrap.servers=cp-1:9092,cp-2:9092,cp-3:9092
Loading

0 comments on commit 935ef9a

Please sign in to comment.