AWS ECS Fargate Logging: Facing issue with Firelens side-car container approach to push log files present inside application container to Cloudwatch - amazon-ecs

I want to push log files which are present in a specific folder inside a container to Cloudwatch. For this, I tried Firelens logdriver but had no luck.
As mentioned here : https://github.com/aws-samples/amazon-ecs-firelens-examples/tree/mainline/examples/fluent-bit/config-file-type-file
I created a custom docker image for fluentbit and deployed it as a side car container in task definition:
FROM public.ecr.aws/aws-observability/aws-for-fluent-bit:stable
COPY fluentbit.conf /extra.conf
fluentbit.conf (I tried exec for debugging purpose, aim is to use tail):
[INPUT]
Name exec
Tag exec_ls
Command ls /opt/apache-tomcat-8.5.72/my-app/logs
Interval_Sec 3
Interval_NSec 0
Buf_Size 8mb
[OUTPUT]
Name cloudwatch
Match *
region ap-south-1
log_group_name fluent-bit-adapter-logs
log_stream_prefix from-fluent-bit-
auto_create_group true
log_key log
This is my ECS Fargate task definition :
{
"ipcMode": null,
"executionRoleArn": "<role>",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awsfirelens",
"secretOptions": null,
"options": {
"log_group_name": "/aws/ecs/containerinsights/$(ecs_cluster)/application",
"auto_create_group": "true",
"log_key": "log",
"log_stream_prefix": "log_stream_name",
"region": "ap-south-1",
"Name": "cloudwatch"
}
},
"entryPoint": null,
"portMappings": [
{
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 8080
}
],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": null,
"volumesFrom": [],
"stopTimeout": null,
"image": "<image-url>",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "my-app"
},
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/log_router",
"awslogs-region": "ap-south-1",
"awslogs-create-group": "true",
"awslogs-stream-prefix": "firelens"
}
},
"entryPoint": null,
"portMappings": [],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": 50,
"volumesFrom": [],
"stopTimeout": null,
"image": "<image-url>",
"startTimeout": null,
"firelensConfiguration": {
"type": "fluentbit",
"options": {
"config-file-type": "file",
"config-file-value": "/extra.conf"
}
},
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": "0",
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "log_router"
}
],
"placementConstraints": [],
"memory": "8192",
"taskRoleArn": "<role>",
"compatibilities": [
"EC2",
"FARGATE"
],
"taskDefinitionArn": "<my-app arn>",
"family": "equbemi",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.firelens.options.config.file"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.logging-driver.awsfirelens"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-ecr-pull"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.task-eni"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.firelens.fluentbit"
}
],
"pidMode": null,
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "4096",
"revision": 19,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}
For my application container, I've given logconfiguration as firelens and deployed a side-car container as mentioned in documentation. I tried the tail command in firelens config but didn't work. So just to troubleshoot, I tried exec and found out in firelens container logs that it is giving "File not found" exception. I assume it is trying to find the path in its own container(the side-car one) and not in the application container. I'm not sure how to make the firelens container access the application container. Am I missing anything here?
*

Here, the problem is that the fluent-bit container does not have access to the application container file system. You need to configure a volume so that the log path will be shared between both of these containers.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_data_volumes.html
Add a volume at the parent level and add this volume as a mount point in both of the container definitions:
{
...
"volumes": [
{
"fsxWindowsFileServerVolumeConfiguration": null,
"efsVolumeConfiguration": null,
"name": "log_path",
"host": {
"sourcePath": null
},
"dockerVolumeConfiguration": null
}
],
...
"containerDefinitions": [
{
...
"mountPoints": [
{
"readOnly": null,
"containerPath": "/var/log",
"sourceVolume": "log_path"
}
],
...
},
{
...
"mountPoints": [
{
"readOnly": null,
"containerPath": "/var/log",
"sourceVolume": "log_path"
}
],
...
}
]
...
}

Related

MondoDB $locate

I have two collections, a policy collection, and a person collection
The Policy looks something like this:
[{
"_id": {
"$oid": "61169375e2145bbfd73dedbe"
},
"PolicyNumber": {
"Identifier": "A56B096A",
"Sequence": 1
},
"Persons": {
"61169362982ac4e8ae2ad768": null,
"60de07a8dc031e91ac5f35c0": null
},
}]
The Person:
[{
"_id": {
"$oid": "5f0c6d087937e0000145e5c3"
},
"UniqueCode": "PER0004",
"PassportExpiryDate": null,
"Age": 35,
"Gender": "M",
"Nationality": null,
"LanguageCode": null,
"Name": "NAME",
"Surname": "SURNAME",
"Initials": null,
"ContactDetails": {
"Addresses": {
"physicalAddress": {
"AddressType": null,
"UnitNumber": null,
"UnitName": null,
"PoBox": null,
"StreetNumber": null,
"StreetName": null,
"Suburb": null,
"Town": null,
"PostalCode": "7100",
"Country": null,
"Coordinates": null,
"InitialCenter": null
}
},
"EmailAddresses": {
"emailAddress": "EMAIL#EMAIL.COM"
},
"TelephoneNumbers": {
"cellphone": "0000000000"
},
"PreferredCommunicationMethod": "SMS"
},
"BankingDetails": [],
"Statistics": null,
"Imported": false,
"ImportReference": null
}]
I have tried various options with $locate, $let, $convert, etc to enable me to join the two collections on 'Persons' using the Policy collections as the entry point.
I know this is probably fundamentals, but I'm n SQL guy who got dumped with a MongoDB conversion.
Any assistance will be appreciated

Extract json key/value pairs with postgresql/snowflake, where value is not null/blank

I have a field called "filter" with json array like:
[
{
"after":"2021-10-14T00:00:00",
"column":"createddate",
"from":null,
"gt":null,
"gte":null,
"id":"928d57b0",
"lt":null,
"lte":null,
"not":null,
"prior":null,
"to":null,
"value":null
},
{
"after":null,
"column":"last_coach_date",
"from":"",
"gt":null,
"gte":null,
"id":"01704cdd",
"lt":null,
"lte":null,
"not":null,
"prior":null,
"to":"",
"value":null
}
]
I'm trying to extract key/value pairs where value is not null/blank and create another field for it.
Maybe to something like this or one long string:
{ "after": "2021-10-14T00:00:00", "column": "createddate", "id": "928d57b0"}, {"column": "last_coach_date","id": "01704cdd"} AS filter_value
Using FLATTEN and OBJECT_AGG:
CREATE OR REPLACE TABLE t(col VARIANT)
AS
SELECT PARSE_JSON('[ { "after": "2021-10-14T00:00:00", "column": "createddate", "from": null, "gt": null, "gte": null, "id": "928d57b0", "lt": null, "lte": null, "not": null, "prior": null, "to": null, "value": null }, { "after": null, "column": "last_coach_date", "from": "", "gt": null, "gte": null, "id": "01704cdd", "lt": null, "lte": null, "not": null, "prior": null, "to": "", "value": null }]'
);
Query:
SELECT s.index, OBJECT_AGG(s2.key, s2.value) AS output
FROM t
,LATERAL FLATTEN(input => col) s
,LATERAL FLATTEN(input => s.value) s2
WHERE NOT IS_NULL_VALUE(s2.value) AND s2.value::TEXT != ''
GROUP BY s.INDEX;
Output:
For Postgres:
select (select jsonb_object_agg(key, value)
from jsonb_array_elements(t.filter) as x(item)
cross join jsonb_each_text(x.item) as e(key,value)
where e.value <> '')
from the_table t;
So very similar to Lukasz solution, but OBJECT_AGG will filter out any NULL values, so if you cast to ::text the nulls become real nulls, and are filtered out, so the WHERE clause is not required:
WITH data_table AS(
SELECT parse_json('[ { "after": "2021-10-14T00:00:00", "column": "createddate", "from": null, "gt": null, "gte": null, "id": "928d57b0", "lt": null, "lte": null, "not": null, "prior": null, "to": null, "value": null }, { "after": null, "column": "last_coach_date", "from": "", "gt": null, "gte": null, "id": "01704cdd", "lt": null, "lte": null, "not": null, "prior": null, "to": "", "value": null } ]') as json
)
SELECT f.index as batch_id,
OBJECT_AGG(p.key, NULLIF(p.value::text,'')::variant) as obj
FROM data_table t,
TABLE(FLATTEN(input=>t.json)) as f,
TABLE(FLATTEN(input=>f.value)) as p
GROUP BY 1
ORDER BY 1
;
gives:
BATCH_ID
OBJ
0
{ "after": "2021-10-14T00:00:00", "column": "createddate", "id": "928d57b0" }
1
{ "column": "last_coach_date", "id": "01704cdd" }
It's not clear from the question if you want 2 rows, or a single value, the latter can be had by adding another layer of aggregation via ARRAY_AGG:
WITH data_table AS(
SELECT parse_json('[ { "after": "2021-10-14T00:00:00", "column": "createddate", "from": null, "gt": null, "gte": null, "id": "928d57b0", "lt": null, "lte": null, "not": null, "prior": null, "to": null, "value": null }, { "after": null, "column": "last_coach_date", "from": "", "gt": null, "gte": null, "id": "01704cdd", "lt": null, "lte": null, "not": null, "prior": null, "to": "", "value": null } ]') as json
)
SELECT array_agg(obj) as single_answer
FROM (
SELECT f.index as batch_id,
OBJECT_AGG(p.key, NULLIF(p.value::text,'')::variant) as obj
FROM data_table t,
TABLE(FLATTEN(input=>t.json)) as f,
TABLE(FLATTEN(input=>f.value)) as p
GROUP BY 1
)
;
gives:
SINGLE_ANSWER
[ { "after": "2021-10-14T00:00:00", "column": "createddate", "id": "928d57b0" }, { "column": "last_coach_date", "id": "01704cdd" } ]

How to configure a web application running in a docker container to succesfully connect to a MongoDB database running in a different container

Summary of the problem
I have two containers running in Docker on a Synology Diskstation 918+. One container hosts a web application, the other the database. The web application is failing to connect to the database.
Container1: This is the web application container
Name: glidinglogbook
Build: C#/.Net Core 2.1/MongoDb.Driver 2.10.2 + Angular 6/Typescript/Bootstrap for the front end
External port: 8003
Docker network: glb-network
This container's alias for the mongodb container is glbdb
Container2: This is the MongoDB database server
Name: mongodb
Database to connect to: glidinglogbook
External port: 8005
Docker network: glb-network
The details: The web application in the glidinglogbook container is failing to connect to the MongoDB database. 30 seconds after it attempts to connect, it times out with the following stack trace:
al.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerS
elector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ Cl
usterId : 1, EndPoint : "Unspecified/glbdb:8005" }", EndPoint: "Unspecified/glbdb:8005", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception
occurred while opening a connection to the server. ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection refused 172.17.0.2:8005
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__271_0(IAsyncResult iar)
--- End of stack trace from previous location where exception was thrown ---
at MongoDB.Driver.Core.Connections.TcpStreamFactory.ConnectAsync(Socket socket, EndPoint endPoint, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateStreamAsync(EndPoint endPoint, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2020-03-03T10:35:02.6718512Z" }] }.
at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellation
Token)
at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken)
at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken)
at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken)
at MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](FilterDefinition`1 filter, FindOptions`2 options, CancellationToken cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken cancellationToken)
at MongoDB.Driver.IAsyncCursorSourceExtensions.ToList[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
at GlidingLogbook.Repositories.FlightRepository.GetAll() in C:\Users\Dave\source\repos\GlidingLogbook\Repositories\FlightRepository.cs:line 22
at GlidingLogbook.Controllers.FlightsController.GetAll() in C:\Users\Dave\source\repos\GlidingLogbook\Controllers\FlightsController.cs:line 25
My Observations:
The stack trace above includes this: EndPoint : "Unspecified/glbdb:8005" which suggests that I am in some way wrongly identifying the database host. Can anyone tell me what is "unspecified" here?
I have no problems connecting to the MongDB database with Robo3T, using the credentials from my appsettings.json below, other than the hostname needs to be MyServer:8005.
When I run the web application in the Visual Studio 2019 debugger, it connects successfully to the database and performs CRUD operations in the normal way, as long as I change the database server host name to MyServer:8005.
I can browse to http://MyServer:8003 to display the UI, but in the docker context the web application is failing to connect to the database so no data is displayed.
Here is my appsettings.json:
{
"dbUsername": "[redacted]",
"dbPassword": "[redacted]",
"dbAuthMechanism": "SCRAM-SHA-1",
"dbHost": "glbdb",
"dbHostPort": 8005,
"dbName": "glidinglogbook",
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
And here is the C# code I am using to get a reference to the database:
public class Database : IDatabase
{
private readonly Settings settings;
public Database(IOptionsMonitor<Settings> settings)
{
this.settings = settings.CurrentValue;
}
public IMongoDatabase Get()
{
var internalIdentity = new MongoInternalIdentity("admin", settings.DbUsername);
var passwordEvidence = new PasswordEvidence(settings.DbPassword);
var mongoCredential = new MongoCredential(settings.DbAuthMechanism, internalIdentity, passwordEvidence);
var mongoClientSettings = new MongoClientSettings
{
Credential = mongoCredential,
Server = new MongoServerAddress(settings.DbHost, settings.DbHostPort)
};
var client = new MongoClient(mongoClientSettings);
return client.GetDatabase(settings.DbName);
}
}
In the course of my investigation, I also came up with the following:
docker network inspect glb-network
[
{
"Name": "glb-network",
"Id": "beb299fbdbe1a230891427828a41e804040bd1e5403ecbb9bdff4abb86c47af5",
"Created": "2020-03-02T16:38:49.893845611Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.21.0.0/16",
"Gateway": "172.21.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"9621d3b4971a585a632fb066bcd5b213a8e20f474729e6df20ef1e7ad3304b38": {
"Name": "alpine1",
"EndpointID": "c779c757b4847cd21fcb612e15a23a6d15a03ae4729a12d26a59cece14004e88",
"MacAddress": "02:42:ac:15:00:04",
"IPv4Address": "172.21.0.4/16",
"IPv6Address": ""
},
"b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a": {
"Name": "glidinglogbook",
"EndpointID": "e6a18ad3e811fddfab904f05a6f95bdd1f4323e727e71e5838d14a7a0e8eecc5",
"MacAddress": "02:42:ac:15:00:03",
"IPv4Address": "172.21.0.3/16",
"IPv6Address": ""
},
"d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643": {
"Name": "mongodb",
"EndpointID": "309b739d4a53a95e28e1e1713be100778619d2b74f6f7c6c2abef66dbbc253f0",
"MacAddress": "02:42:ac:15:00:02",
"IPv4Address": "172.21.0.2/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
and...
docker container inspect glidinglogbook
[
{
"Id": "b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a",
"Created": "2020-03-03T10:26:34.120702556Z",
"Path": "/bin/sh",
"Args": [
"-c",
"\"dotnet\" \"GlidingLogbook.dll\""
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 18767,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-03-03T10:32:24.412840804Z",
"FinishedAt": "2020-03-03T10:32:05.106756231Z",
"StartedTs": 1583231544,
"FinishedTs": 1583231525
},
"Image": "sha256:e6f43665ec3bc215de8913af816f88372aee8e8ee88ea16bd0765861f4fe6311",
"ResolvConfPath": "/volume1/#docker/containers/b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a/resolv.conf",
"HostnamePath": "/volume1/#docker/containers/b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a/hostname",
"HostsPath": "/volume1/#docker/containers/b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a/hosts",
"LogPath": "/volume1/#docker/containers/b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a/log.db",
"Name": "/glidinglogbook",
"RestartCount": 0,
"Driver": "btrfs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "db",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {
"64839/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8003"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": [
"/mongodb:/glidinglogbook/glbdb"
],
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DOTNET_SDK_VERSION=2.1.804",
"ASPNETCORE_URLS=http://*:64839",
"DOTNET_RUNNING_IN_CONTAINER=true",
"DOTNET_USE_POLLING_FILE_WATCHER=true",
"NUGET_XMLDOC_MODE=skip"
],
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 50,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": null,
"Name": "btrfs"
},
"Mounts": [],
"Config": {
"Hostname": "glidinglogbook",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"64839/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DOTNET_SDK_VERSION=2.1.804",
"ASPNETCORE_URLS=http://*:64839",
"DOTNET_RUNNING_IN_CONTAINER=true",
"DOTNET_USE_POLLING_FILE_WATCHER=true",
"NUGET_XMLDOC_MODE=skip"
],
"Cmd": null,
"ArgsEscaped": true,
"Image": "glidinglogbook:latest",
"Volumes": null,
"WorkingDir": "/app",
"Entrypoint": [
"/bin/sh",
"-c",
"\"dotnet\" \"GlidingLogbook.dll\""
],
"OnBuild": null,
"Labels": {},
"DDSM": false
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "3bc8bdb7582c1994d052735054d64b170d90b9e9bf54de3ffbd9635cb828ff45",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"64839/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8003"
}
]
},
"SandboxKey": "/var/run/docker/netns/3bc8bdb7582c",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "9297dc46163c799987c4cb57d5ee3ea8c3855bca3476ca503ecbd760eb5eb8b1",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "dad2d9a926d79fd266bcf1494a9ca5249666fd0280d799eb3b9589f9e7e7d750",
"EndpointID": "9297dc46163c799987c4cb57d5ee3ea8c3855bca3476ca503ecbd760eb5eb8b1",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03",
"DriverOpts": null
},
"glb-network": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"b491359c438d"
],
"NetworkID": "beb299fbdbe1a230891427828a41e804040bd1e5403ecbb9bdff4abb86c47af5",
"EndpointID": "e6a18ad3e811fddfab904f05a6f95bdd1f4323e727e71e5838d14a7a0e8eecc5",
"Gateway": "172.21.0.1",
"IPAddress": "172.21.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:15:00:03",
"DriverOpts": null
}
}
}
}
]
...and finally...
docker container inspect mongodb
[
{
"Id": "d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643",
"Created": "2020-02-26T15:42:39.938818193Z",
"Path": "docker-entrypoint.sh",
"Args": [
"mongod"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 17093,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-03-03T10:30:42.368424228Z",
"FinishedAt": "2020-03-03T10:29:59.821302747Z",
"StartedTs": 1583231442,
"FinishedTs": 1583231399
},
"Image": "sha256:bcef5fd2979dbcbf76e46139680bf71c35925e344afa4703de43bdc44c6c526a",
"ResolvConfPath": "/volume1/#docker/containers/d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643/resolv.conf",
"HostnamePath": "/volume1/#docker/containers/d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643/hostname",
"HostsPath": "/volume1/#docker/containers/d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643/hosts",
"LogPath": "/volume1/#docker/containers/d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643/log.db",
"Name": "/mongodb",
"RestartCount": 0,
"Driver": "btrfs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/volume1/docker/mongodb:/data/db:rw"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "db",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {
"27017/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8005"
}
]
},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.11",
"JSYAML_VERSION=3.13.0",
"GPG_KEYS=E162F504A20CDF15827F718D4B7C549A058F8B6B",
"MONGO_PACKAGE=mongodb-org",
"MONGO_REPO=repo.mongodb.org",
"MONGO_MAJOR=4.2",
"MONGO_VERSION=4.2.3",
"MONGO_INITDB_ROOT_PASSWORD=p*FW~t",
"MONGO_INITDB_ROOT_USERNAME=mongodbuser"
],
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 50,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": null,
"Name": "btrfs"
},
"Mounts": [
{
"Type": "volume",
"Name": "e4a576d00714481bcb576441551dc24c569f9e6b6ed6b9b48d2742c4e2baddb5",
"Source": "/volume1/#docker/volumes/e4a576d00714481bcb576441551dc24c569f9e6b6ed6b9b48d2742c4e2baddb5/_data",
"Destination": "/data/configdb",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
{
"Type": "bind",
"Source": "/volume1/docker/mongodb",
"Destination": "/data/db",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "mongodb",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"27017/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.11",
"JSYAML_VERSION=3.13.0",
"GPG_KEYS=E162F504A20CDF15827F718D4B7C549A058F8B6B",
"MONGO_PACKAGE=mongodb-org",
"MONGO_REPO=repo.mongodb.org",
"MONGO_MAJOR=4.2",
"MONGO_VERSION=4.2.3",
"MONGO_INITDB_ROOT_PASSWORD=p*FW~t",
"MONGO_INITDB_ROOT_USERNAME=mongodbuser"
],
"Cmd": [
"mongod"
],
"ArgsEscaped": true,
"Image": "mongo:latest",
"Volumes": {
"/data/configdb": {},
"/data/db": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {},
"DDSM": false
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "ca8ed91e9dabe029ef61412f4e0d385ddbfe5ca010fb7d4a933b441b5dcba5df",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"27017/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8005"
}
]
},
"SandboxKey": "/var/run/docker/netns/ca8ed91e9dab",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "2d4ae043a660b10324570e621c3fdf13043d334c5a511c77252411a360b99539",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "dad2d9a926d79fd266bcf1494a9ca5249666fd0280d799eb3b9589f9e7e7d750",
"EndpointID": "2d4ae043a660b10324570e621c3fdf13043d334c5a511c77252411a360b99539",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
},
"glb-network": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"d9e756043c56"
],
"NetworkID": "beb299fbdbe1a230891427828a41e804040bd1e5403ecbb9bdff4abb86c47af5",
"EndpointID": "309b739d4a53a95e28e1e1713be100778619d2b74f6f7c6c2abef66dbbc253f0",
"Gateway": "172.21.0.1",
"IPAddress": "172.21.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:15:00:02",
"DriverOpts": null
}
}
}
}
]
As a Docker newbie, I have pretty much run out of ideas as to why my web application, running in a container, is failing to connect to the database, running in a different container. My observations above about the stack trace may be a clue, but as yet I have't found a configuration that works, although I've tried various different options, including referencing the database by its IP address - nothing worked.
Any help in solving this would be much appreciated!
You can use the mongodb container IP: 172.21.0.2.
If you wish to reach the container using names instead of IP you can use Docker Compose to configure your containers.
Did you inspect if your web application is connected to the same network your database server is in?
https://docs.docker.com/engine/reference/commandline/network_connect/ -> This might help!
Problem solved: the IP address of the MongoDB container was being blocked by the firewall. I added a new rule to allow that IP address through the firewall, and everything suddenly started working.

Change the default port of mongodb on ECS Instance

EDIT : I finally resolved my problem, I replace the command line by :
"command": [
"mongod",
"--port",
"3001"
]
I want to run mongodb on port 3001 instead of 27017 on my ECS instance. I have one application (annonces) and one database (mongodb).
This is my Task Definition configuration :
{
"executionRoleArn": null,
"containerDefinitions": [
{
"dnsSearchDomains": null,
"logConfiguration": null,
"entryPoint": null,
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 4001
}
],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [
{
"name": "DB_URI",
"value": "mongodb://mongo:3001/db-annonces"
}
],
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"dockerSecurityOptions": null,
"memory": 128,
"memoryReservation": null,
"volumesFrom": [],
"image": "XXXXXXXXXXX.dkr.ecr.eu-west-3.amazonaws.com/annonces-service:latest",
"disableNetworking": null,
"healthCheck": null,
"essential": true,
"links": [
"mongo"
],
"hostname": null,
"extraHosts": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"privileged": null,
"name": "annonces"
},
{
"dnsSearchDomains": null,
"logConfiguration": null,
"entryPoint": [],
"portMappings": [
{
"hostPort": 3001,
"protocol": "tcp",
"containerPort": 3001
}
],
"command": [
"mongod --port 3001"
],
"linuxParameters": null,
"cpu": 0,
"environment": [],
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"dockerSecurityOptions": null,
"memory": 128,
"memoryReservation": null,
"volumesFrom": [],
"image": "mongo:latest",
"disableNetworking": null,
"healthCheck": null,
"essential": false,
"links": null,
"hostname": "mongo",
"extraHosts": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"privileged": null,
"name": "mongo"
}
],
"placementConstraints": [],
"memory": null,
"taskRoleArn": null,
"compatibilities": [
"EC2"
],
"taskDefinitionArn": "arn:aws:ecs:eu-west-3:XXXXXXXX:task-definition/annonces-task:17",
"family": "annonces-task",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.ecr-auth"
}
],
"requiresCompatibilities": null,
"networkMode": "bridge",
"cpu": null,
"revision": 17,
"status": "ACTIVE",
"volumes": []
}
The problem seems to come from the line :
"command": [
"mongod --port 3001"
]
When I try to run the task, the task shut down immediately. If I remove this line, it works but the database is not on port 3001.
If i run the command docker logs on the specific container, I get the following error :
/usr/local/bin/docker-entrypoint.sh: line 340: exec: mongod --port 3001: not found

How to use SoftLayer REST API to create an Auto Scale Group

I'm using this URL to get an existing Auto Scale Group that I want to clone with modifications. It seems to have all the informmation about Service Port, Policies, Resource Triggers, Watches, Actions that I need to have.
https://api.softlayer.com/rest/v3/SoftLayer_Scale_Group/1120061/getObject.json?objectMask=mask[policies[resourceUseTriggers[watches],actions],loadBalancers]
The resulting response is contained in "RESPONSE 1" below.
I then modify the response to "remove the IDs" and then modify it to use as a template to create a new Auto Scale Group and the new request JSON is shown in "REQUEST 1" below.
When I submit "REQUEST 1" to SoftLayer using a POST to
https://api.softlayer.com/rest/v3/SoftLayer_Scale_Group/createObject.json
I get the standard error - "The remote server returned an error: (500) Internal Server Error."
So what am I doing incorrectly here?
== REQUEST 1 ==
{ "parameters": [
{
"virtualGuestMemberTemplate": {
"accountId": 940999,
"domain": "partpic.com",
"hostname": "CaffeServer-test-001",
"maxMemory": 1024,
"postInstallScriptUri": "https://webdev.partpic.com/ppsvc/CaffeStartup.aspx?model=Sample.tar.gz",
"startCpus": 1,
"blockDeviceTemplateGroup": {
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"name": "dal06"
},
"hourlyBillingFlag": true
},
"loadBalancers": [{
"healthCheckId": 609283,
"id": 101503,
"port": 32400,
"virtualServerId": 275643
}],
"policies": [{
"name": "ScaleDown",
"resourceUseTriggers": [{
"typeId": 3,
"watches": [{
"algorithm": "EWMA",
"metric": "host.cpu.percent",
"operator": "<",
"period": 1500,
"value": "20"
}]
}],
"actions": [{
"typeId": 1,
"amount": 80,
"scaleType": "PERCENT"
}]
},
{
"name": "ScaleUp",
"resourceUseTriggers": [{
"typeId": 3,
"watches": [{
"algorithm": "EWMA",
"metric": "host.cpu.percent",
"operator": ">",
"period": 600,
"value": "80"
}]
}],
"actions": [{
"typeId": 1,
"amount": 150,
"scaleType": "PERCENT"
}]
}],
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": [],
"accountId": 940999,
"cooldown": 60,
"name": "scale_test-001",
"regionalGroupId": 22,
"terminationPolicyId": 1
}
]}
== RESPONSE 1 ==
{
"accountId": 940999,
"balancedTerminationFlag": false,
"cooldown": 60,
"createDate": "2016-08-08T13:19:51-05:00",
"desiredMemberCount": null,
"id": 1120061,
"lastActionDate": "2016-08-12T14:22:51-05:00",
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"modifyDate": "2016-08-12T14:22:57-05:00",
"name": "scale_CaffeServerSample",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"accountId": 940999,
"createDate": null,
"dedicatedAccountHostOnlyFlag": null,
"domain": "partpic.com",
"hostname": "CaffeServerSample",
"id": null,
"lastPowerStateId": null,
"lastVerifiedDate": null,
"maxCpu": null,
"maxMemory": 1024,
"metricPollDate": null,
"modifyDate": null,
"postInstallScriptUri": "https:\/\/webdev.partpic.com\/ppsvc\/CaffeStartup.aspx?model=Sample.tar.gz",
"provisionDate": null,
"startCpus": 1,
"statusId": null,
"blockDeviceTemplateGroup": {
"accountId": null,
"createDate": null,
"id": null,
"parentId": null,
"publicFlag": null,
"statusId": null,
"transactionId": null,
"userRecordId": null,
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"id": null,
"name": "dal06",
"statusId": null
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": [{
"createDate": "2016-08-12T14:06:07-05:00",
"deleteFlag": null,
"healthCheckId": 609283,
"id": 101503,
"modifyDate": "2016-08-12T14:19:33-05:00",
"port": 32400,
"scaleGroupId": 1120061,
"virtualServerId": 274353,
"scaleGroup": {
"accountId": 940999,
"balancedTerminationFlag": false,
"cooldown": 60,
"createDate": "2016-08-08T13:19:51-05:00",
"desiredMemberCount": null,
"id": 1120061,
"lastActionDate": "2016-08-12T14:22:51-05:00",
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"modifyDate": "2016-08-12T14:22:57-05:00",
"name": "scale_CaffeServerSample",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"accountId": 940999,
"createDate": null,
"dedicatedAccountHostOnlyFlag": null,
"domain": "partpic.com",
"hostname": "CaffeServerSample",
"id": null,
"lastPowerStateId": null,
"lastVerifiedDate": null,
"maxCpu": null,
"maxMemory": 1024,
"metricPollDate": null,
"modifyDate": null,
"postInstallScriptUri": "https:\/\/webdev.partpic.com\/ppsvc\/CaffeStartup.aspx?model=Sample.tar.gz",
"provisionDate": null,
"startCpus": 1,
"statusId": null,
"blockDeviceTemplateGroup": {
"accountId": null,
"createDate": null,
"id": null,
"parentId": null,
"publicFlag": null,
"statusId": null,
"transactionId": null,
"userRecordId": null,
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"id": null,
"name": "dal06",
"statusId": null
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": null,
"policies": [{
"cooldown": null,
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 174557,
"modifyDate": null,
"name": "ScaleDown",
"scaleGroupId": 1120061,
"actions": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 166457,
"modifyDate": null,
"scalePolicyId": 174557,
"typeId": 1,
"scalePolicy": null,
"amount": 80,
"scaleType": "PERCENT"
}],
"resourceUseTriggers": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 173005,
"modifyDate": null,
"scalePolicyId": 174557,
"typeId": 3,
"scalePolicy": null,
"watches": [{
"algorithm": "EWMA",
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 143505,
"metric": "host.cpu.percent",
"modifyDate": null,
"operator": "<",
"period": 1500,
"scalePolicyTriggerId": 173005,
"value": "20",
"scalePolicyTrigger": null
}]
}],
"scaleGroup": null
},
{
"cooldown": null,
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 174555,
"modifyDate": null,
"name": "ScaleUp",
"scaleGroupId": 1120061,
"actions": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 166455,
"modifyDate": null,
"scalePolicyId": 174555,
"typeId": 1,
"scalePolicy": null,
"amount": 150,
"scaleType": "PERCENT"
}],
"resourceUseTriggers": [{
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 173003,
"modifyDate": null,
"scalePolicyId": 174555,
"typeId": 3,
"scalePolicy": null,
"watches": [{
"algorithm": "EWMA",
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 143503,
"metric": "host.cpu.percent",
"modifyDate": null,
"operator": ">",
"period": 600,
"scalePolicyTriggerId": 173003,
"value": "80",
"scalePolicyTrigger": null
}]
}],
"scaleGroup": null
}],
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": []
}
}],
"policies": [{
"cooldown": null,
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 174557,
"modifyDate": null,
"name": "ScaleDown",
"scaleGroupId": 1120061,
"actions": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 166457,
"modifyDate": null,
"scalePolicyId": 174557,
"typeId": 1,
"scalePolicy": null,
"amount": 80,
"scaleType": "PERCENT"
}],
"resourceUseTriggers": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 173005,
"modifyDate": null,
"scalePolicyId": 174557,
"typeId": 3,
"scalePolicy": null,
"watches": [{
"algorithm": "EWMA",
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 143505,
"metric": "host.cpu.percent",
"modifyDate": null,
"operator": "<",
"period": 1500,
"scalePolicyTriggerId": 173005,
"value": "20",
"scalePolicyTrigger": null
}]
}],
"scaleGroup": {
"accountId": 940999,
"balancedTerminationFlag": false,
"cooldown": 60,
"createDate": "2016-08-08T13:19:51-05:00",
"desiredMemberCount": null,
"id": 1120061,
"lastActionDate": "2016-08-12T14:22:51-05:00",
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"modifyDate": "2016-08-12T14:22:57-05:00",
"name": "scale_CaffeServerSample",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"accountId": 940999,
"createDate": null,
"dedicatedAccountHostOnlyFlag": null,
"domain": "partpic.com",
"hostname": "CaffeServerSample",
"id": null,
"lastPowerStateId": null,
"lastVerifiedDate": null,
"maxCpu": null,
"maxMemory": 1024,
"metricPollDate": null,
"modifyDate": null,
"postInstallScriptUri": "https:\/\/webdev.partpic.com\/ppsvc\/CaffeStartup.aspx?model=Sample.tar.gz",
"provisionDate": null,
"startCpus": 1,
"statusId": null,
"blockDeviceTemplateGroup": {
"accountId": null,
"createDate": null,
"id": null,
"parentId": null,
"publicFlag": null,
"statusId": null,
"transactionId": null,
"userRecordId": null,
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"id": null,
"name": "dal06",
"statusId": null
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": [{
"createDate": "2016-08-12T14:06:07-05:00",
"deleteFlag": null,
"healthCheckId": 609283,
"id": 101503,
"modifyDate": "2016-08-12T14:19:33-05:00",
"port": 32400,
"scaleGroupId": 1120061,
"virtualServerId": 274353,
"scaleGroup": null
}],
"policies": null,
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": []
}
},
{
"cooldown": null,
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 174555,
"modifyDate": null,
"name": "ScaleUp",
"scaleGroupId": 1120061,
"actions": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 166455,
"modifyDate": null,
"scalePolicyId": 174555,
"typeId": 1,
"scalePolicy": null,
"amount": 150,
"scaleType": "PERCENT"
}],
"resourceUseTriggers": [{
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 173003,
"modifyDate": null,
"scalePolicyId": 174555,
"typeId": 3,
"scalePolicy": null,
"watches": [{
"algorithm": "EWMA",
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 143503,
"metric": "host.cpu.percent",
"modifyDate": null,
"operator": ">",
"period": 600,
"scalePolicyTriggerId": 173003,
"value": "80",
"scalePolicyTrigger": null
}]
}],
"scaleGroup": {
"accountId": 940999,
"balancedTerminationFlag": false,
"cooldown": 60,
"createDate": "2016-08-08T13:19:51-05:00",
"desiredMemberCount": null,
"id": 1120061,
"lastActionDate": "2016-08-12T14:22:51-05:00",
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"modifyDate": "2016-08-12T14:22:57-05:00",
"name": "scale_CaffeServerSample",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"accountId": 940999,
"createDate": null,
"dedicatedAccountHostOnlyFlag": null,
"domain": "partpic.com",
"hostname": "CaffeServerSample",
"id": null,
"lastPowerStateId": null,
"lastVerifiedDate": null,
"maxCpu": null,
"maxMemory": 1024,
"metricPollDate": null,
"modifyDate": null,
"postInstallScriptUri": "https:\/\/webdev.partpic.com\/ppsvc\/CaffeStartup.aspx?model=Sample.tar.gz",
"provisionDate": null,
"startCpus": 1,
"statusId": null,
"blockDeviceTemplateGroup": {
"accountId": null,
"createDate": null,
"id": null,
"parentId": null,
"publicFlag": null,
"statusId": null,
"transactionId": null,
"userRecordId": null,
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"id": null,
"name": "dal06",
"statusId": null
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": [{
"createDate": "2016-08-12T14:06:07-05:00",
"deleteFlag": null,
"healthCheckId": 609283,
"id": 101503,
"modifyDate": "2016-08-12T14:19:33-05:00",
"port": 32400,
"scaleGroupId": 1120061,
"virtualServerId": 274353,
"scaleGroup": null
}],
"policies": null,
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": []
}
}],
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": []
}
I do not think that create a new autoscale group is so easy like copy paste and delete some ids.
try this request:
{
"parameters": [
{
"balancedTerminationFlag": false,
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"cooldown": 60,
"name": "scale_test-0012a",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"domain": "partpic.com",
"hostname": "CaffeServer-test-001",
"maxMemory": 1024,
"postInstallScriptUri": "https://webdev.partpic.com/ppsvc/CaffeStartup.aspx?model=Sample.tar.gz",
"startCpus": 1,
"blockDeviceTemplateGroup": {
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"name": "dal06"
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": [{
"deleteFlag" : false,
"port": 32400,
"virtualServerId": 275643,
"healthCheck": {
"type": {
"keyname": "DEFAULT"
}
}
}],
"policies": [{
"name": "ScaleDown",
"resourceUseTriggers": [{
"watches": [{
"algorithm": "EWMA",
"metric": "host.cpu.percent",
"operator": "<",
"period": 1500,
"value": "20"
}]
}],
"scaleActions": [{
"amount": 80,
"scaleType": "PERCENT"
}]
}, {
"name": "ScaleUp",
"resourceUseTriggers": [{
"typeId": 3,
"watches": [{
"algorithm": "EWMA",
"metric": "host.cpu.percent",
"operator": ">",
"period": 600,
"value": "80"
}]
}],
"scaleActions": [{
"amount": 150,
"scaleType": "PERCENT"
}]
}]
}
]
}