Mongo proxy

Fault injection

The Mongo proxy filter supports fault injection. See the v1 and v2 API reference for how to configure.

Statistics

Every configured MongoDB proxy filter has statistics rooted at mongo.. with the following statistics:

NameTypeDescription
decoding_errorCounterNumber of MongoDB protocol decoding errors
delay_injectedCounterNumber of times the delay is injected
op_get_moreCounterNumber of OP_GET_MORE messages
op_insertCounterNumber of OP_INSERT messages
op_kill_cursorsCounterNumber of OP_KILL_CURSORS messages
op_queryCounterNumber of OP_QUERY messages
op_query_tailable_cursorCounterNumber of OP_QUERY with tailable cursor flag set
op_query_no_cursor_timeoutCounterNumber of OP_QUERY with no cursor timeout flag set
op_query_await_dataCounterNumber of OP_QUERY with await data flag set
op_query_exhaustCounterNumber of OP_QUERY with exhaust flag set
op_query_no_max_timeCounterNumber of queries without maxTimeMS set
op_query_scatter_getCounterNumber of scatter get queries
op_query_multi_getCounterNumber of multi get queries
op_query_activeGaugeNumber of active queries
op_replyCounterNumber of OP_REPLY messages
op_reply_cursor_not_foundCounterNumber of OP_REPLY with cursor not found flag set
op_reply_query_failureCounterNumber of OP_REPLY with query failure flag set
op_reply_valid_cursorCounterNumber of OP_REPLY with a valid cursor
cx_destroy_local_with_active_rqCounterConnections destroyed locally with an active query
cx_destroy_remote_with_active_rqCounterConnections destroyed remotely with an active query
cx_drain_closeCounterConnections gracefully closed on reply boundaries during server drain

Scatter gets

Envoy defines a scatter get as any query that does not use an _id field as a query parameter. Envoy looks in both the top level document as well as within a $query field for _id.

Multi gets

Envoy defines a multi get as any query that does use an _id field as a query parameter, but where _id is not a scalar value (i.e., a document or an array). Envoy looks in both the top level document as well as within a $query field for _id.

$comment parsing

If a query has a top level $comment field (typically in addition to a $query field), Envoy will parse it as JSON and look for the following structure:

  1. {
  2. "callingFunction": "..."
  3. }

callingFunction

(required, string) the function that made the query. If available, the function will be used in callsite query statistics.

Per command statistics

The MongoDB filter will gather statistics for commands in the mongo..cmd.. namespace.

NameTypeDescription
totalCounterNumber of commands
reply_num_docsHistogramNumber of documents in reply
reply_sizeHistogramSize of the reply in bytes
reply_time_msHistogramCommand time in milliseconds

Per collection query statistics

The MongoDB filter will gather statistics for queries in the mongo..collection..query. namespace.

NameTypeDescription
totalCounterNumber of queries
scatter_getCounterNumber of scatter gets
multi_getCounterNumber of multi gets
reply_num_docsHistogramNumber of documents in reply
reply_sizeHistogramSize of the reply in bytes
reply_time_msHistogramQuery time in milliseconds

Per collection and callsite query statistics

If the application provides the calling function in the $comment field, Envoy will generate per callsite statistics. These statistics match the per collection statistics but are found in the mongo..collection..callsite..query. namespace.

Runtime

The Mongo proxy filter supports the following runtime settings:

mongo.connection_logging_enabled

% of connections that will have logging enabled. Defaults to 100. This allows only a % of connections to have logging, but for all messages on those connections to be logged.

mongo.proxy_enabled

% of connections that will have the proxy enabled at all. Defaults to 100.

mongo.logging_enabled

% of messages that will be logged. Defaults to 100. If less than 100, queries may be logged without replies, etc.

mongo.mongo.drain_close_enabled

% of connections that will be drain closed if the server is draining and would otherwise attempt a drain close. Defaults to 100.

mongo.fault.fixed_delay.percent

Probability of an eligible MongoDB operation to be affected by the injected fault when there is no active fault. Defaults to the percent specified in the config.

mongo.fault.fixed_delay.duration_ms

The delay duration in milliseconds. Defaults to the duration_ms specified in the config.

Access log format

The access log format is not customizable and has the following layout:

  1. {"time": "...", "message": "...", "upstream_host": "..."}

time

System time that complete message was parsed, including milliseconds.

message

Textual expansion of the message. Whether the message is fully expanded depends on the context. Sometimes summary data is presented to avoid extremely large log sizes.

upstream_host

The upstream host that the connection is proxying to, if available. This is populated if the filter is used along with the TCP proxy filter.