We have some Datadog Vector applications with vector datasources. We would like to run some performance tests using k6 for breakpoint and load tests. However there there is not existing plugin in k6 for this use case.
The datasource implementation is a GRPC endpoint, therefore it should be possible to use k6 GRPC client for this purpose.
I would really appreciate if anybody who did this would share their example.
We would need 2 proto buf definitions from Datadog vector git repo: https://github.com/vectordotdev/vector/blob/master/lib/vector-core/proto/event.proto https://github.com/vectordotdev/vector/blob/master/proto/vector.proto
Put them into following folder structure:
./definitions/vector.proto
./definitions/vector.proto
./k6_test.js
Contents for k6 test
import {check, sleep} from 'k6';
import grpc from 'k6/net/grpc';
import encoding from 'k6/encoding';
const client = new grpc.Client();
client.load(['definitions'], 'event.proto', 'vector.proto');
export default () => {
client.connect('vector-logs:6000', {
plaintext: true
});
const data = {
events: [
{log: {
fields: {
field1: {integer: 111},
field2: {boolean: true},
},
value: {
map: {
fields: {
message: {raw_bytes: encoding.b64encode("message from k6")}
}
}
},
metadata: {
map: {
fields: {
key111: {
raw_bytes: encoding.b64encode("value1")
},
key2: {
raw_bytes: encoding.b64encode("value2")
}
}
}
}
}
}
]
}
const response = client.invoke('vector.Vector/PushEvents', data);
check(response, {
'status is OK': (r) => r && r.status === grpc.StatusOK,
});
console.log(JSON.stringify(response.message));
client.close();
sleep(1);
};
I've create example for messages with int, boolean, string and map content types. In case if you need any other types, you might need to consult with: https://protobuf.dev/programming-guides/proto3/#json
PS: I have almost zero experience with rust, k6 and protobuf therefore treat it just as an example.