hostname or IP address of carbon server
Optionalport: numberport of carbon server, [[DEFAULT_PORT]] if not given
Optionaltransport: IPTransporttransport layer protocol to use, [[DEFAULT_TRANSPORT]] if not given
OptionalautoConnect: booleanautomatically connect on write if not connected, false if not given
path of Unix domain socket
always 'IPC'
OptionalautoConnect: booleanautomatically connect on write if not connected, false if not given
ReadonlyaddressFor 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 ReadonlyfamilyFor 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.
ReadonlyportServer port to connect to. Will be -1 if [[CarbonClient.transport]] is 'IPC'.
ReadonlyprefixPrefix added to all metric paths.
ReadonlyretryNumber of automatic retries on network error. Defaults to 0.
Error handlers are still called.
ReadonlyretryTime to wait before retrying after error. Defaults to [[DEFAULT_RETRY_TIMEOUT]].
ReadonlysendSize of send buffer. If set to 0 metrics are sent immediately.
Defaults to [[DEFAULT_SEND_BUFFER_SIZE]].
ReadonlysendBuffer wait time. If set to 0 metrics are sent immediately.
Defaults to [[DEFAULT_SEND_INTERVAL]].
ReadonlytransportTransport layer protocol to use.
Optional ReadonlyudpIf [[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 awaiting the returned Promise.
The metrics to write.
Optionaltimestamp: 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.
Optionaltimestamp: 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.
Optionaltags: 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.
Optionaltags: TagsMetric tags.
Send a metric to the carbon server.
Optionaltags: 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 awaiting the returned Promise.
Optionaltags: 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-encodingis 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:
COM1COM2COM3COM4COM5COM6COM7COM8COM9LPT1LPT2LPT3LPT4LPT5LPT6LPT7LPT8LPT9CONNULPRNAlso the tag name
nameis used to store the metric path.This library does not take care of these cases.
See