I'm trying to get the Spring Profile Arbiter working. According to the documentation you can place an arbiter almost anywhere:
So an Arbiter could encapsulate something as simple as a single property declaration or a whole set of Appenders or Loggers.
Unfortunately, the documentation doesn't provide any example code how this can be done in modern yaml-config files. This is what I have at the moment:
Configuration:
name: Default
//...
Properties:
Property:
- name: log-dir
value: "./logs"
- name: log-file-name
value: "logfile"
- name: log-file-ext
value: "log"
- name: connection-factory-method
value: "getDbConnection"
SpringProfile:
name: development
- name: connection-factory-method
value: "getDbConnection4dev"
- name: con-pattern-logger
value: "%-50.50c{1.}"
//...
Sadly, not working as expected. Played for a while, but couldn't find a working solution. All I get are initialization errors.
I am grateful for any information that could help me get ahead.
In your configuration each YAML object represents a Log4j2 component.
The type of object (short plugin name) to instantiate must be provided as type property of the YAML object. If no such property exist, the key associated to the object is used.
To define a SpringProfileArbiter component that contains a Property component you can either use:
key1:
type: SpringProfile
name: development
property1:
type: Property
name: connection-factory-method
value: "getDbConnection4dev"
or
SpringProfile:
name: development
Property:
name: connection-factory-method
value: "getDbConnection4dev"
You can use arrays if you want to define multiple components of the same type.
Remark: if your application runs under the "development" profile, the "connection-factory-method" property will be defined twice. To prevent this you can use SelectArbiter and DefaultArbiter to provide the equivalent of an if ... else clause:
Select:
SpringProfile:
name: development
Property:
name: connection-factory-method
value: "getDbConnection4dev"
DefaultArbiter:
Property:
name: connection-factory-method
value: "getDbConnection"
Related
I'm getting stuck on this issue. Essentially I want to output the list of 'Namespace' key/values like below:
MyCloudWatchMetricStream:
Type: AWS::CloudWatch::MetricStream
Properties:
IncludeFilters:
- Namespace: AWS/ELB
- Namespace: AWS/Events
- Namespace: AWS/Logs
When it's declared like this:
MyCWMIncludeFilters:
Type: String
Default: 'Namespace: AWS/ELB,Namespace: AWS/Events,Namespace: AWS/Logs'
I've tried this to no avail:
MyCloudWatchMetricStream:
Type: AWS::CloudWatch::MetricStream
Properties:
IncludeFilters: !Split [",", !Ref MyCWMIncludeFilters]
and getting this error on stack creation:
Embedded stack arn:aws:cloudformation:<redacted> was not successfully created:
The following resource(s) failed to create: [MyCloudWatchMetricStream].
Any ideas of what I can do? Alternatives? Best practices?
Thanks in advance!
Can I use my own custom formats in my OpenAPI definition and have the AWS API Gateway validate using them? I can't find any reference for this so I assume not?
For example, I would only like to greet guys named Dave:
swagger: "2.0"
info:
version: "1.0"
title: "Hello World API"
paths:
/hello/{user}:
get:
description: Returns a greeting to the user!
parameters:
- name: user
in: path
type: string
required: true
description: The name of the user to greet.
format: "guys-named-dave"
The documentation on this is a bit implicit, indeed. If you combine this
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-validation-set-up.html
with this
https://swagger.io/specification/#schema-object
the following should be a solution, that works (and it does!)
paths:
/hello
get:
x-amazon-apigateway-request-validator: params
parameters:
- name: user
in: path
required: true
schema:
type: string
pattern: ^.*dave.*$
x-amazon-apigateway-request-validators:
params:
validateRequestParameters: true
To allow for case insensitive names like "Dave" and "DAVE", try the pattern /.*dave.*/i. I don't know if this will work.
I am running "docker.elastic.co/beats/filebeat:7.9.1"
In filebeat.yml I configured to append some fields to the template
setup.template.overwrite: true
setup.template.append_fields:
- name: level
type: text
- name: msg
type: text
- name: stacktrace
type: text
- name: uri
type: text
- name: headers
type: text
This works fine. But as soon as I add the field:
- name: hash
type: keyword
I get the following error:
INFO template/load.go:169 Existing template will be overwritten, as overwrite is enabled.
ERROR [publisher_pipeline_output] pipeline/output.go:154 Failed to connect to backoff(elasticsearch(https://whatever.eu-central-1.aws.cloud.es.io:443)): Connection marked as failed because the onConnect call back failed: error loading template: error creating template: 1 error: fields contain key <hash>
The Elasticsearch version is v7.10.0.
What is going on?
The problem is that a field named "hash" is already defined in the "Elastic Common Schema (ECS)" fields in the default "fields.yml" file.
(see: https://www.elastic.co/guide/en/beats/filebeat/current/exported-fields-ecs.html)
Cannot create a google deployment manager runtime config variable
resources:
- name: star-config
type: runtimeconfig.v1beta1.config
properties:
name: star-config
- name: igurl_variable
type: runtimeconfig.v1beta1.variable
properties:
name: igurl_variable
value: 'trek'
parent: $(ref.star-config.name)
I checked the logs and I see that the status is set to bad_request when I create the above deployment.
Audit log
status: {
message: "BAD_REQUEST"
}
What could be the reason for the error ?
You should try the with the properties fields as in the official documentation for both the config and variable resources.
The resource file should be something like:
resources:
- name: star-config
type: runtimeconfig.v1beta1.config
properties:
config: star-config
- name: igurl_variable
type: runtimeconfig.v1beta1.variable
properties:
variable: igurl_variable
text: 'trek'
parent: $(ref.star-config.name)
I am using serverless-aws-documentation plugin to auto-generate swagger-doc. Followed all the steps provided at : https://github.com/9cookies/serverless-aws-documentation. Under documentation key I am defining tags but it is not getting generated in the output swagger doc. Following is the sample handler :
functions:
get_tickets:
handler: handler.ticket_handler.get_tickets
events:
- http:
path: tickets
method: get
cors: true
documentation:
tags:
- private
- admin
summary: "Get list of ticket"
description: "This ticket will provide you list of tickets"
I want to segrigate APIs depending on the tags, but not able to achieve it. Thanks in advance for the help.
Try to add the serverless-aws-documentation plugin in the serverless.yml
plugins:
- serverless-aws-documentation
Add the infor and models documentation in the custom section:
custom:
myStage: ${opt:stage, self:provider.stage}
profiles:
dev: road-we-go
prod: road-we-
documentation:
info:
version: "1.0.0"
name: "Example API"
description: "Example API description"
termsOfService: "https://example.com/terms-of-service"
contact:
name: "Example API"
url: "https://example.com"
email: "dev#example.com"
licence:
name: "Licensing"
url: "https://example.com/licensing"
models:
-
name: "StoreAudioSuccess"
description: "Model for store audio"
contentType: "application/json"
schema: ${file(swagger/audios/storeResponse.
Add the function documentation:
If you want to add the custom models like RequestStore and StoreAudioSuccess check the serverless-aws-documentation documentation and the json-schema docs
functions:
Update:
handler: src/functions/update.handler
timeout: 30
memory: 128
events:
- http:
method: put
private: true
cors: true
path: api/v1/update
documentation:
summary: "Update "
description: "Update a record"
tags:
- "Users"
requestModels:
"application/json": "RequestStore"
methodResponses:
-
statusCode: "200"
responseModels:
"application/json": "StoreUserSuccess"
To download the swagger documentation you need to run this command:
First you need to deploy you project
sls downloadDocumentation --outputFileName=swagger.json
Which version are you using?
According to their latest documentation https://github.com/9cookies/serverless-aws-documentation, you need to provide tags as follows i.e. within double quotes.
documentation:
tags:
- "private"
- "admin"