AWS CLI error: Member must satisfy regular expression pattern

0

Hello,

i'm on this issue since yesterday without any means to understand what's going wrong.
I install awscli via pip, setup my credentials, and now i'm able to retrieve my the whole list of logs hosted on Cloudwatch:

        {
            "arn": "arn:aws:logs:eu-west-1:077720739816:log-group:testloginstance:*",
            "creationTime": 1563357673443,
            "metricFilterCount": 0,
            "logGroupName": "testloginstance",
            "storedBytes": 129594
        },

But when i try to display logs, i always have the same error:
An error occurred (InvalidParameterException) when calling the GetLogEvents operation: 1 validation error detected: Value 'log-group:testloginstance' at 'logStreamName' failed to satisfy constraint: Member must satisfy regular expression pattern

Here my command and debug output:

aws logs --debug get-log-events --log-group-name testloginstance --log-stream-name log-group:testloginstance

2019-08-21 12:14:16,298 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.16.221 Python/2.7.16 Linux/3.10.0-514.2.2.el7.x86_64 botocore/1.12.212
2019-08-21 12:14:16,298 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['logs', '--debug', 'get-log-events', '--log-group-name', 'testloginstance', '--log-stream-name', 'log-group:testloginstance']
2019-08-21 12:14:16,299 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_scalar_parsers at 0x7f5ee91bd050>
2019-08-21 12:14:16,299 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x7f5ee96b95f0>
2019-08-21 12:14:16,299 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x7f5ee9692668>
2019-08-21 12:14:16,300 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x7f5eeda0c398>
2019-08-21 12:14:16,301 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /opt/rh/python27/root/usr/lib/python2.7/site-packages/botocore/data/logs/2014-03-28/service-2.json
2019-08-21 12:14:16,323 - MainThread - botocore.hooks - DEBUG - Changing event name from building-command-table.logs to building-command-table.cloudwatch-logs
2019-08-21 12:14:16,323 - MainThread - botocore.hooks - DEBUG - Event building-command-table.cloudwatch-logs: calling handler <function add_waiters at 0x7f5ee91c5410>
2019-08-21 12:14:16,332 - MainThread - awscli.clidriver - DEBUG - OrderedDict([(u'log-group-name', <awscli.arguments.CLIArgument object at 0x7f5ee8f2d550>), (u'log-stream-name', <awscli.arguments.CLIArgument object at 0x7f5ee8f2d5d0>), (u'start-time', <awscli.arguments.CLIArgument object at 0x7f5ee8f2d250>), (u'end-time', <awscli.arguments.CLIArgument object at 0x7f5ee8f2d650>), (u'next-token', <awscli.arguments.CLIArgument object at 0x7f5ee8f2d690>), (u'limit', <awscli.arguments.CLIArgument object at 0x7f5ee8f2d6d0>), (u'start-from-head', <awscli.arguments.BooleanArgument object at 0x7f5ee8f2d710>), (u'no-start-from-head', <awscli.arguments.BooleanArgument object at 0x7f5ee8f2d7d0>)])
2019-08-21 12:14:16,332 - MainThread - botocore.hooks - DEBUG - Changing event name from building-argument-table.logs.get-log-events to building-argument-table.cloudwatch-logs.get-log-events
2019-08-21 12:14:16,333 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.cloudwatch-logs.get-log-events: calling handler <function add_streaming_output_arg at 0x7f5ee91bd500>
2019-08-21 12:14:16,333 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.cloudwatch-logs.get-log-events: calling handler <function add_cli_input_json at 0x7f5ee969b398>
2019-08-21 12:14:16,333 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.cloudwatch-logs.get-log-events: calling handler <function unify_paging_params at 0x7f5ee923dde8>
2019-08-21 12:14:16,340 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /opt/rh/python27/root/usr/lib/python2.7/site-packages/botocore/data/logs/2014-03-28/paginators-1.json
2019-08-21 12:14:16,341 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.cloudwatch-logs.get-log-events: calling handler <function add_generate_skeleton at 0x7f5ee9232758>
2019-08-21 12:14:16,341 - MainThread - botocore.hooks - DEBUG - Changing event name from before-building-argument-table-parser.logs.get-log-events to before-building-argument-table-parser.cloudwatch-logs.get-log-events
2019-08-21 12:14:16,342 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.cloudwatch-logs.get-log-events: calling handler <bound method CliInputJSONArgument.override_required_args of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x7f5ee8f2d350>>
2019-08-21 12:14:16,342 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.cloudwatch-logs.get-log-events: calling handler <bound method GenerateCliSkeletonArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x7f5ee8f2da90>>
2019-08-21 12:14:16,343 - MainThread - botocore.hooks - DEBUG - Changing event name from operation-args-parsed.logs.get-log-events to operation-args-parsed.cloudwatch-logs.get-log-events
2019-08-21 12:14:16,343 - MainThread - botocore.hooks - DEBUG - Changing event name from load-cli-arg.logs.get-log-events.log-group-name to load-cli-arg.cloudwatch-logs.get-log-events.log-group-name
2019-08-21 12:14:16,344 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.cloudwatch-logs.get-log-events.log-group-name: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f5ee90d3050>
2019-08-21 12:14:16,344 - MainThread - botocore.hooks - DEBUG - Changing event name from process-cli-arg.logs.get-log-events to process-cli-arg.cloudwatch-logs.get-log-events
2019-08-21 12:14:16,344 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.cloudwatch-logs.get-log-events: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f5ee966f090>
2019-08-21 12:14:16,344 - MainThread - awscli.arguments - DEBUG - Unpacked value of u'testloginstance' for parameter "log_group_name": u'testloginstance'
2019-08-21 12:14:16,344 - MainThread - botocore.hooks - DEBUG - Changing event name from load-cli-arg.logs.get-log-events.log-stream-name to load-cli-arg.cloudwatch-logs.get-log-events.log-stream-name
2019-08-21 12:14:16,344 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.cloudwatch-logs.get-log-events.log-stream-name: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f5ee90d3050>
2019-08-21 12:14:16,344 - MainThread - botocore.hooks - DEBUG - Changing event name from process-cli-arg.logs.get-log-events to process-cli-arg.cloudwatch-logs.get-log-events
2019-08-21 12:14:16,344 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.cloudwatch-logs.get-log-events: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f5ee966f090>
2019-08-21 12:14:16,345 - MainThread - awscli.arguments - DEBUG - Unpacked value of u'log-group:testloginstance' for parameter "log_stream_name": u'log-group:testloginstance'
2019-08-21 12:14:16,345 - MainThread - botocore.hooks - DEBUG - Changing event name from load-cli-arg.logs.get-log-events.start-time to load-cli-arg.cloudwatch-logs.get-log-events.start-time
2019-08-21 12:14:16,345 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.cloudwatch-logs.get-log-events.start-time: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f5ee90d3050>
2019-08-21 12:14:16,345 - MainThread - botocore.hooks - DEBUG - Changing event name from load-cli-arg.logs.get-log-events.end-time to load-cli-arg.cloudwatch-logs.get-log-events.end-time
2019-08-21 12:14:16,345 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.cloudwatch-logs.get-log-events.end-time: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f5ee90d3050>
2019-08-21 12:14:16,345 - MainThread - botocore.hooks - DEBUG - Changing event name from load-cli-arg.logs.get-log-events.next-token to load-cli-arg.cloudwatch-logs.get-log-events.next-token
2019-08-21 12:14:16,345 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.cloudwatch-logs.get-log-events.next-token: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f5ee90d3050>
2019-08-21 12:14:16,346 - MainThread - botocore.hooks - DEBUG - Changing event name from load-cli-arg.logs.get-log-events.limit to load-cli-arg.cloudwatch-logs.get-log-events.limit
2019-08-21 12:14:16,346 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.cloudwatch-logs.get-log-events.limit: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f5ee90d3050>
2019-08-21 12:14:16,346 - MainThread - botocore.hooks - DEBUG - Changing event name from load-cli-arg.logs.get-log-events.start-from-head to load-cli-arg.cloudwatch-logs.get-log-events.start-from-head
2019-08-21 12:14:16,346 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.cloudwatch-logs.get-log-events.start-from-head: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f5ee90d3050>
2019-08-21 12:14:16,346 - MainThread - botocore.hooks - DEBUG - Changing event name from load-cli-arg.logs.get-log-events.cli-input-json to load-cli-arg.cloudwatch-logs.get-log-events.cli-input-json
2019-08-21 12:14:16,346 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.cloudwatch-logs.get-log-events.cli-input-json: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f5ee90d3050>
2019-08-21 12:14:16,346 - MainThread - botocore.hooks - DEBUG - Changing event name from load-cli-arg.logs.get-log-events.generate-cli-skeleton to load-cli-arg.cloudwatch-logs.get-log-events.generate-cli-skeleton
2019-08-21 12:14:16,346 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.cloudwatch-logs.get-log-events.generate-cli-skeleton: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f5ee90d3050>
2019-08-21 12:14:16,347 - MainThread - botocore.hooks - DEBUG - Changing event name from calling-command.logs.get-log-events to calling-command.cloudwatch-logs.get-log-events
2019-08-21 12:14:16,347 - MainThread - botocore.hooks - DEBUG - Event calling-command.cloudwatch-logs.get-log-events: calling handler <bound method CliInputJSONArgument.add_to_call_parameters of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x7f5ee8f2d350>>
2019-08-21 12:14:16,347 - MainThread - botocore.hooks - DEBUG - Event calling-command.cloudwatch-logs.get-log-events: calling handler <bound method GenerateCliSkeletonArgument.generate_json_skeleton of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x7f5ee8f2da90>>
2019-08-21 12:14:16,347 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2019-08-21 12:14:16,347 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2019-08-21 12:14:16,347 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity
2019-08-21 12:14:16,347 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2019-08-21 12:14:16,348 - MainThread - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials
2019-08-21 12:14:16,348 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /opt/rh/python27/root/usr/lib/python2.7/site-packages/botocore/data/endpoints.json
2019-08-21 12:14:16,425 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f5eea84be60>
2019-08-21 12:14:16,428 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.cloudwatch-logs: calling handler <function add_generate_presigned_url at 0x7f5eea89d848>
2019-08-21 12:14:16,428 - MainThread - botocore.args - DEBUG - The s3 config key is not a dictionary type, ignoring its value of: None
2019-08-21 12:14:16,433 - MainThread - botocore.endpoint - DEBUG - Setting logs timeout as (60, 60)
2019-08-21 12:14:16,434 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /opt/rh/python27/root/usr/lib/python2.7/site-packages/botocore/data/_retry.json
2019-08-21 12:14:16,438 - MainThread - botocore.client - DEBUG - Registering retry handlers for service: logs
2019-08-21 12:14:16,439 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.cloudwatch-logs.GetLogEvents: calling handler <function generate_idempotent_uuid at 0x7f5eea84c140>
2019-08-21 12:14:16,440 - MainThread - botocore.hooks - DEBUG - Event before-call.cloudwatch-logs.GetLogEvents: calling handler <function inject_api_version_header_if_needed at 0x7f5eea84d7d0>
2019-08-21 12:14:16,440 - MainThread - botocore.endpoint - DEBUG - Making request for OperationModel(name=GetLogEvents) with params: {'body': '{"logStreamName": "log-group:testloginstance", "logGroupName": "testloginstance"}', 'url': u'https://logs.eu-west-1.amazonaws.com/', 'headers': {'User-Agent': 'aws-cli/1.16.221 Python/2.7.16 Linux/3.10.0-514.2.2.el7.x86_64 botocore/1.12.212', 'Content-Type': u'application/x-amz-json-1.1', 'X-Amz-Target': u'Logs_20140328.GetLogEvents'}, 'context': {'auth_type': None, 'client_region': 'eu-west-1', 'has_streaming_input': False, 'client_config': <botocore.config.Config object at 0x7f5ee8bc0950>}, 'query_string': '', 'url_path': '/', 'method': u'POST'}
2019-08-21 12:14:16,440 - MainThread - botocore.hooks - DEBUG - Event request-created.cloudwatch-logs.GetLogEvents: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7f5ee8bc0910>>
2019-08-21 12:14:16,441 - MainThread - botocore.hooks - DEBUG - Event choose-signer.cloudwatch-logs.GetLogEvents: calling handler <function set_operation_specific_signer at 0x7f5eea84c050>
2019-08-21 12:14:16,441 - MainThread - botocore.auth - DEBUG - Calculating signature using v4 auth.
2019-08-21 12:14:16,442 - MainThread - botocore.auth - DEBUG - CanonicalRequest:
POST
/

content-type:application/x-amz-json-1.1
host:logs.eu-west-1.amazonaws.com
x-amz-date:20190821T121416Z
x-amz-target:Logs_20140328.GetLogEvents

content-type;host;x-amz-date;x-amz-target
5805b397761c476c536330c368cacca09997d48cfbce5db67ed1f8aa234d614a
2019-08-21 12:14:16,442 - MainThread - botocore.auth - DEBUG - StringToSign:
AWS4-HMAC-SHA256
20190821T121416Z
20190821/eu-west-1/logs/aws4_request
1483a200291d08b0125fc0daebd2b48d6f722339577c0603f7ced0b590d67863
2019-08-21 12:14:16,442 - MainThread - botocore.auth - DEBUG - Signature:
a36784e173f011cb88c5370239f99a99998af6974b6736897590501a7625dd89
2019-08-21 12:14:16,442 - MainThread - botocore.endpoint - DEBUG - Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://logs.eu-west-1.amazonaws.com/, headers={'Content-Length': '81', 'X-Amz-Target': 'Logs_20140328.GetLogEvents', 'X-Amz-Date': '20190821T121416Z', 'User-Agent': 'aws-cli/1.16.221 Python/2.7.16 Linux/3.10.0-514.2.2.el7.x86_64 botocore/1.12.212', 'Content-Type': 'application/x-amz-json-1.1', 'Authorization': 'AWS4-HMAC-SHA256 Credential=XXX/20190821/eu-west-1/logs/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=a36784e173f011cb88c5370239f99a99998af6974b6736897590501a7625dd89'}>
2019-08-21 12:14:16,444 - MainThread - urllib3.util.retry - DEBUG - Converted retries value: False -> Retry(total=False, connect=None, read=None, redirect=0, status=None)
2019-08-21 12:14:16,444 - MainThread - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): logs.eu-west-1.amazonaws.com:443
2019-08-21 12:14:16,927 - MainThread - urllib3.connectionpool - DEBUG - https://logs.eu-west-1.amazonaws.com:443 "POST / HTTP/1.1" 400 217
2019-08-21 12:14:16,928 - MainThread - botocore.parsers - DEBUG - Response headers: {'x-amzn-RequestId': '96e94edc-f5db-4320-9f82-f92d11b8800e', 'Date': 'Wed, 21 Aug 2019 12:14:16 GMT', 'Content-Length': '217', 'Content-Type': 'application/x-amz-json-1.1', 'Connection': 'close'}
2019-08-21 12:14:16,928 - MainThread - botocore.parsers - DEBUG - Response body:
{"__type":"InvalidParameterException","message":"1 validation error detected: Value 'log-group:testloginstance' at 'logStreamName' failed to satisfy constraint: Member must satisfy regular expression pattern: [^:*]*"}
2019-08-21 12:14:16,929 - MainThread - botocore.hooks - DEBUG - Event needs-retry.cloudwatch-logs.GetLogEvents: calling handler <botocore.retryhandler.RetryHandler object at 0x7f5ee8b42a10>
2019-08-21 12:14:16,929 - MainThread - botocore.retryhandler - DEBUG - No retry needed.
2019-08-21 12:14:16,931 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/awscli/clidriver.py", line 217, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/awscli/clidriver.py", line 358, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/awscli/clidriver.py", line 530, in __call__
    call_parameters, parsed_globals)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/awscli/clidriver.py", line 650, in invoke
    client, operation_name, parameters, parsed_globals)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/awscli/clidriver.py", line 662, in _make_client_call
    **parameters)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/botocore/client.py", line 661, in _make_api_call
    raise error_class(parsed_response, operation_name)
InvalidParameterException: An error occurred (InvalidParameterException) when calling the GetLogEvents operation: 1 validation error detected: Value 'log-group:testloginstance' at 'logStreamName' failed to satisfy constraint: Member must satisfy regular expression pattern: [^:*]*
2019-08-21 12:14:16,932 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

An error occurred (InvalidParameterException) when calling the GetLogEvents operation: 1 validation error detected: Value 'log-group:testloginstance' at 'logStreamName' failed to satisfy constraint: Member must satisfy regular expression pattern: [^:*]*

I especially try to take a simple log ressource name, without special characters, trying several syntax, same result or API response that this log doesn't exist.

Any help would be greatly appreciated.

Thx

Edited by: nicnictout on Aug 21, 2019 5:50 AM

gefragt vor 5 Jahren4630 Aufrufe
1 Antwort
0

Hi,
Change your invocation
From:

aws logs get-log-events --log-group-name testloginstance --log-stream-name log-group:testloginstance

To:

aws logs get-log-events --log-group-name testloginstance --log-stream-name testloginstance

FYI: I was able to reproduce the same error.

C:\Users\randy\aws\sam\projects\nodejs>aws logs get-log-events --log-group-name CloudWatchLogGroup --log-stream-name log-group::MyLogStream

An error occurred (InvalidParameterException) when calling the GetLogEvents operation: 1 validation error detected: Value 'log-group::MyLogStream' at 'logStreamName' failed to satisfy constraint: Member must satisfy regular expression pattern: [^:*]*

And after I fixed the --log-stream-name

C:\Users\randy\aws\sam\projects\nodejs>aws logs get-log-events --log-group-name CloudWatchLogGroup --log-stream-name MyLogStream
{
    "events": [
        {
            "timestamp": 1566284476276,
            "message": "[System] [Information] [7036] [Service Control Manager] [EC2AMAZ-7JBQ892] [The Microsoft Account Sign-in Assistant service entered the stopped state.]",
            "ingestionTime": 1566284525380
        },

Hope this helps!
-randy

EXPERTE
beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen