Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/configuration/http_conn_man/access_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ format
.. _config_http_conn_man_access_log_filter_param:

filter
*(optional, string)* :ref:`Filter <config_http_con_manager_access_log_filters>` which is used to
*(optional, object)* :ref:`Filter <config_http_con_manager_access_log_filters>` which is used to
determine if the access log needs to be written.

.. _config_http_con_manager_access_log_format:
Expand Down Expand Up @@ -175,7 +175,7 @@ Duration
Filters on total request duration in milliseconds.

op
*(required, string)* Comparison operator. Currently *>=* is the only supported operator.
*(required, string)* Comparison operator. Currently *>=* and *=* are the only supported operator.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operators?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.


value
*(required, integer)* Default value to compare against if runtime values is not available.
Expand Down
108 changes: 102 additions & 6 deletions source/common/json/config_schemas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,93 @@ const std::string Json::Schema::HTTP_CONN_NETWORK_FILTER_SCHEMA(R"EOF(
{
"$schema": "http://json-schema.org/schema#",
"definitions" : {
"access_log": {
"status_code" : {
"type" : "object",
"properties" : {
"path" : {"type" : "string"},
"format" : {"type" : "string"},
"filter" : {"type" : "object"}
"type" : {
"type" : "string",
"enum" : ["status_code"]
},
"op" : {
"type" : "string",
"enum" : ["=>", "="]
},
"value" : {"type" : "integer"},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about mix and max here as well?
minimum 0 and maximum 600 (for http)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion. Added.

"runtime_key" : {"type" : "string"}
},
"required" : ["type", "op", "value"],
"additionalProperties" : false
},
"duration" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "string",
"enum" : ["duration"]
},
"op" : {
"type" : "string",
"enum" : ["=>", "="]
},
"value" : {"type" : "integer"},
"runtime_key" : {"type" : "string"}
},
"required" : ["type", "op", "value"],
"additionalProperties" : false
},
"not_healthcheck" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "string",
"enum" : ["not_healthcheck"]
}
},
"required" : ["type"],
"additionalProperties" : false
},
"logical_and" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "string",
"enum" : ["logical_and"]
},
"filters" : {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change looks good to me, if only we could extract "filters" from here and from logical_or into separate thing and reference it from here and other place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good call. I didn't think about putting those two together at the time. Thank you!

"type" : "array",
"minItems" : 2,
"items" : {
"anyOf" : [
{"$ref" : "#/defintions/status_code"},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

{"$ref" : "#/definitions/duration"},
{"$ref" : "#/definitions/not_healthcheck"}
]
}
}
},
"required" : ["path"],
"required" : ["type", "filters"],
"additionalProperties" : false
},
"logical_or" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "string",
"enum" : ["logical_or"]
},
"filters" : {
"type" : "array",
"minItems" : 2,
"items" : {
"anyOf" : [
{"$ref" : "#/defintions/status_code"},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any of the supported filter types can be here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

{"$ref" : "#/definitions/duration"},
{"$ref" : "#/definitions/not_healthcheck"}
]
}
}
},
"required" : ["type", "filters"],
"additionalProperties" : false
},
"tracing" : {
Expand Down Expand Up @@ -133,7 +212,24 @@ const std::string Json::Schema::HTTP_CONN_NETWORK_FILTER_SCHEMA(R"EOF(
"type" : "array",
"items" : {
"type" : "object",
"properties" : {"$ref" : "#/definitions/access_log"}
"properties" : {
"path" : {"type" : "string"},
"format" : {"type" : "string"},
"filter" : {
"type" : "object",
"properties" : {
"oneOf" : [
{"$ref" : "#/definitions/status_code"},

@RomanDzhabarov RomanDzhabarov Feb 2, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (type == "status_code") {
    return FilterPtr{new StatusCodeFilter(json, runtime)};
  } else if (type == "duration") {
    return FilterPtr{new DurationFilter(json, runtime)};
  } else if (type == "runtime") {
    return FilterPtr{new RuntimeFilter(json, runtime)};
  } else if (type == "logical_or") {
    return FilterPtr{new OrFilter(json, runtime)};
  } else if (type == "logical_and") {
    return FilterPtr{new AndFilter(json, runtime)};
  } else if (type == "not_healthcheck") {
    return FilterPtr{new NotHealthCheckFilter()};
  } else if (type == "traceable_request") {
    return FilterPtr{new TraceableRequestFilter(runtime)};

ref should be updated
these are all supported access log filters, why tests not catching it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll add a test for nested filters

{"$ref" : "#/definitions/duration"},
{"$ref" : "#/definitions/not_healthcheck"},
{"$ref" : "#/defintions/logical_and"},
{"$ref" : "#/defintions/logical_or"}
]
}
}
},
"required" : ["path"],
"additionalProperties" : false
}
},
"use_remote_address" : {"type" : "boolean"},
Expand Down
38 changes: 30 additions & 8 deletions test/config/integration/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,21 @@
"access_log": [
{
"path": "/dev/null",
"filters": [
{"type": "status_code", "op": ">=", "value": 500},
{"type": "duration", "op": ">=", "value": 1000000}
]
"filter" : {
"type": "logical_or",
"filters": [
{
"type": "status_code",
"op": ">=",
"value": 500
},
{
"type": "duration",
"op": ">=",
"value": 1000000
}
]
}
},
{
"path": "/dev/null"
Expand Down Expand Up @@ -107,10 +118,21 @@
"access_log": [
{
"path": "/dev/null",
"filters": [
{"type": "status_code", "op": ">=", "value": 500},
{"type": "duration", "op": ">=", "value": 1000000}
]
"filter" : {
"type": "logical_or",
"filters": [
{
"type": "status_code",
"op": ">=",
"value": 500
},
{
"type": "duration",
"op": ">=",
"value": 1000000
}
]
}
},
{
"path": "/dev/null"
Expand Down
38 changes: 30 additions & 8 deletions test/config/integration/server_http2.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,21 @@
"access_log": [
{
"path": "/dev/null",
"filters": [
{"type": "status_code", "op": ">=", "value": 500},
{"type": "duration", "op": ">=", "value": 1000000}
]
"filter" : {
"type": "logical_or",
"filters": [
{
"type": "status_code",
"op": ">=",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use '=' also in integration test configs, so that it'll have additional coverage

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already coverage for '=' within access_log_impl_tests.cc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup it's tested, just wanted extra test of that here, either way

"value": 500
},
{
"type": "duration",
"op": ">=",
"value": 1000000
}
]
}
},
{
"path": "/dev/null"
Expand Down Expand Up @@ -88,10 +99,21 @@
"access_log": [
{
"path": "/dev/null",
"filters": [
{"type": "status_code", "op": ">=", "value": 500},
{"type": "duration", "op": ">=", "value": 1000000}
]
"filter" : {
"type": "logical_or",
"filters": [
{
"type": "status_code",
"op": ">=",
"value": 500
},
{
"type": "duration",
"op": ">=",
"value": 1000000
}
]
}
},
{
"path": "/dev/null"
Expand Down
57 changes: 45 additions & 12 deletions test/config/integration/server_http2_upstream.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@
"access_log": [
{
"path": "/dev/null",
"filters": [
{"type": "status_code", "op": ">=", "value": 500},
{"type": "duration", "op": ">=", "value": 1000000}
]
"filter" : {
"type": "logical_or",
"filters": [
{
"type": "status_code",
"op": ">=",
"value": 500
},
{
"type": "duration",
"op": ">=",
"value": 1000000
}
]
}
},
{
"path": "/dev/null"
Expand Down Expand Up @@ -82,10 +93,21 @@
"access_log": [
{
"path": "/dev/null",
"filters": [
{"type": "status_code", "op": ">=", "value": 500},
{"type": "duration", "op": ">=", "value": 1000000}
]
"filter" : {
"type": "logical_or",
"filters": [
{
"type": "status_code",
"op": ">=",
"value": 500
},
{
"type": "duration",
"op": ">=",
"value": 1000000
}
]
}
},
{
"path": "/dev/null"
Expand Down Expand Up @@ -157,10 +179,21 @@
"access_log": [
{
"path": "/dev/null",
"filters": [
{"type": "status_code", "op": ">=", "value": 500},
{"type": "duration", "op": ">=", "value": 1000000}
]
"filter" : {
"type": "logical_or",
"filters": [
{
"type": "status_code",
"op": ">=",
"value": 500
},
{
"type": "duration",
"op": ">=",
"value": 1000000
}
]
}
},
{
"path": "/dev/null"
Expand Down
19 changes: 15 additions & 4 deletions test/config/integration/server_proxy_proto.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@
"access_log": [
{
"path": "/dev/null",
"filters": [
{"type": "status_code", "op": ">=", "value": 500},
{"type": "duration", "op": ">=", "value": 1000000}
]
"filter" : {
"type": "logical_or",
"filters": [
{
"type": "status_code",
"op": ">=",
"value": 500
},
{
"type": "duration",
"op": ">=",
"value": 1000000
}
]
}
},
{
"path": "/dev/null"
Expand Down
19 changes: 15 additions & 4 deletions test/config/integration/server_ssl.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@
"access_log": [
{
"path": "/dev/null",
"filters": [
{"type": "status_code", "op": ">=", "value": 500},
{"type": "duration", "op": ">=", "value": 1000000}
]
"filter" : {
"type": "logical_or",
"filters": [
{
"type": "status_code",
"op": ">=",
"value": 500
},
{
"type": "duration",
"op": ">=",
"value": 1000000
}
]
}
},
{
"path": "/dev/null"
Expand Down
Loading