hostname or IP address of carbon server
Optional
port: numberport of carbon server, [[DEFAULT_PORT]] if not given
Optional
transport: IPTransporttransport layer protocol to use, [[DEFAULT_TRANSPORT]] if not given
Optional
autoConnect: booleanautomatically connect on write if not connected, false
if not given
path of Unix domain socket
always 'IPC'
Optional
autoConnect: booleanautomatically connect on write if not connected, false
if not given
Readonly
addressFor TCP and UDP the hostname or IP address of the server, for IPC the file name of the Unix domain socket.
Automatically connect on write if not connected.
Also if ture
then calls of [[CarbonClient.connect]] when connected and
calls of [[CarbonClient.disconnect]] when not connected are not errors.
Optional
Readonly
familyFor TCP and UDP the IP address family to use.
If not given it will be auto-detected. For UDP if there are IPv6 and IPv4
addresses of a hostname the IPv6 address will be preferred. Explicitely
pass 4
if you do not want this.
Readonly
portServer port to connect to. Will be -1
if [[CarbonClient.transport]] is 'IPC'
.
Readonly
prefixPrefix added to all metric paths.
Readonly
retryNumber of automatic retries on network error. Defaults to 0
.
Error handlers are still called.
Readonly
retryTime to wait before retrying after error. Defaults to [[DEFAULT_RETRY_TIMEOUT]].
Readonly
sendSize of send buffer. If set to 0
metrics are sent immediately.
Defaults to [[DEFAULT_SEND_BUFFER_SIZE]].
Readonly
sendBuffer wait time. If set to 0
metrics are sent immediately.
Defaults to [[DEFAULT_SEND_INTERVAL]].
Readonly
transportTransport layer protocol to use.
Optional
Readonly
udpIf [[CarbonClient.transport]] is "UDP"
the
dgram.SocketOptions.sendBufferSize
of UDP sockets.
Returns the number of currently buffered bytes.
If [[CarbonClient.isBuffered]] is false
this is always 0
.
Returns true if the client bufferes multiple writes into one send.
Returns true if the underlying socket was created, is writeable and not connecting.
Returns true if the underlying socket was created and is connecting or if the client is in the process of retrying to connect.
Returns true if the socket is destroyed, or if it is not yet created and not in the process of connecting.
TLS certificate authoritie's certificate.
TLS client certificate.
TLS client private key.
Batch send multiple metrics all at once.
If you use UDP keep batch sizes small enough to fit into one UDP packet!
If timestamp
is not provided the current time (via Date.now()
) will be used.
NOTE: If [[CarbonClient.sendBufferSize]] is > 0
then any error (except for
[[IllegalArgument]]) might not happen during await
of the returned Promise, but
will only dispatched to any registered error handlers. See: [[CarbonClient.on]]
Also note that if the sent data doesn't fit into the buffer, this will issue a
send immediately and any promise rejections of that send will be directly returned
when await
ing the returned Promise.
The metrics to write.
Optional
timestamp: DateThe timestamp to use for metrics that don't define it directly.
Promise that resolves when the metric is sent.
Disconnect the client from the server.
NOTE: If you want currently buffered data to be sent before disconnect you need to call flush() first! Calling disconnect() cancels currently ongoing connection and send attempts.
This alternative exists because awaiting promises on graceful shutdown seems to not work (the await never returns and the process just quits). Normal callbacks do work.
Async callback for when the client is disconnected or an error during disconnect occured.
Disconnect the client from the server.
NOTE: If you want currently buffered data to be sent before disconnect you need to call flush() first! Calling disconnect() cancels currently ongoing connection and send attempts.
Await the returned promise to wait for the disconnect to finish.
Batch send multiple metrics all at once.
If you use UDP keep batch sizes small enough to fit into one UDP packet!
If timestamp
is not provided the current time (via Date.now()
) will be used.
In contrast to [[CarbonClient.batchWrite]] this doesn't return a promise, but
instead if an error occurs during sending this error will be dispatched
to any registered 'error'
even handlers.
The metrics to write.
Optional
timestamp: DateThe timestamp to use for metrics that don't define it directly.
Send a metric to the carbon server.
In contrast to [[CarbonClient.write]] this doesn't return a promise, but
instead if an error occurs during sending this error will be dispatched
to any registered 'error'
even handlers.
Metric path.
Metric value.
Metric timestamp.
Optional
tags: TagsMetric tags.
Send a metric to the carbon server.
The current time (via Date.now()
) will be used.
In contrast to [[CarbonClient.write]] this doesn't return a promise, but
instead if an error occurs during sending this error will be dispatched
to any registered 'error'
even handlers.
Metric path.
Metric value.
Optional
tags: TagsMetric tags.
Send a metric to the carbon server.
Optional
tags: TagsPromise that resolves when the metric is sent.
Send a metric to the carbon server.
The current time (via Date.now()
) will be used.
NOTE: If [[CarbonClient.sendBufferSize]] is > 0
then any error (except for
[[IllegalArgument]]) might not happen during await
of the returned Promise
, but
will only dispatched to any registered error handlers. See: [[CarbonClient.on]]
Also note that if the sent data doesn't fit into the buffer, this will issue a
send immediately and any promise rejections of that send will be directly returned
when await
ing the returned Promise
.
Optional
tags: TagsPromise that resolves when the metric is sent.
Implementing of the graphite carbon plain text protocol.
Allowed Names and Values
This graphite carbon protocol implementation is a bit strict about the characters allowed in metric paths, tag names, and tag values just to be safe. The plain text protocol documentation itself isn't extremely precise and doesn't mention any allowed or disallowed characters or encoding schemes. Given the protocol just consists of lines in the form of
<metric path> <metric value> <metric timestamp>
it is clear that the path may not contain any whitespace. Also since the tags are just appended to the path name using;
as a delimiter between the path and the tags and=
between tag name and value these characters can clearly also no occur in path names. Further the whisper server seems to store metric on the filesystem by splitting it on.
and creating a filesystem hierarchy based on the split path comonents. That means paths better not contain any characters not allowed in file names of any common operating systems. Also no double-.
, leading-.
or trailing-.
. For tags there are also certain limitations around the~
character.Therefore this library only allows paths and tag names in this schema:
Note that tag values may not be empty.
The
hex-encoding
is meant as a convention. If you really have to use metric paths or tag names with other characters you can pass them throughencodeURIComponent()
. Note that you have to also do the reverse (decodeURIComponent()
) when reading back metric paths, tag names and values.Note that if the whisper server would really run on Windows (don't know if it ever does) there are also problems with case-insensitivity (also true for macOS) and for certain special file names:
COM1
COM2
COM3
COM4
COM5
COM6
COM7
COM8
COM9
LPT1
LPT2
LPT3
LPT4
LPT5
LPT6
LPT7
LPT8
LPT9
CON
NUL
PRN
Also the tag name
name
is used to store the metric path.This library does not take care of these cases.
See