From ed69f8ac81217e0e36823e9fdb217b424576fba3 Mon Sep 17 00:00:00 2001
From: "@inaki.etxaniz" <inaki.etxaniz@tecnalia.com>
Date: Thu, 18 Jan 2024 15:12:54 +0100
Subject: [PATCH] y3 final updates

---
 .env                                          |   9 +-
 .env.gen                                      | 113 ++++++-----
 .envs/global/development                      |  14 ++
 .envs/global/prod                             |  10 +
 .envs/global/release                          |  18 ++
 .envs/modules/iec/development                 |  14 ++
 .envs/modules/iec/prod                        |  10 +
 .envs/modules/iec/release                     |  18 ++
 .gitlab-ci.yml                                |   4 +-
 build/docker-compose.yaml                     |  13 ++
 build/image/docker-compose.yaml               |   3 +
 build/inline-cache/docker-compose.yaml        |   5 +
 docker-compose-artifactory.yaml               |   4 +
 docker-compose.yaml                           |  27 ++-
 git/iec-Influxdbclient/Dockerfile             |  24 +++
 git/iec-Influxdbclient/config/config.ini      |   6 +
 git/iec-Influxdbclient/init.sh                |   3 +
 .../piacere_influxdb_client.py                | 182 ++++++++++++++++++
 git/iec-Influxdbclient/requirements.txt       |   4 +
 .../templates/influxdb_query_templates.py     |  39 ++++
 .../templates/mysql_query_templates.py        |  85 ++++++++
 .../piacere/iec/backend/domain/Instance.java  |  31 ++-
 .../backend/service/InstanceQueryService.java |   4 +-
 .../service/criteria/InstanceCriteria.java    |  35 ++--
 .../iec/backend/service/dto/InstanceDTO.java  |  24 +--
 .../service/dto/InstanceSaveInfoDTO.java      |  22 ++-
 .../backend/web/rest/InstanceResource.java    |   2 +
 .../backend/web/rest/InstanceResourceIT.java  |  97 +---------
 .../detail/instance-detail.component.html     |   6 +-
 .../iecBackend/instance/instance.model.ts     |   2 +
 .../instance/list/instance.component.html     |  31 +--
 .../instance/pipes/filter.instance.pipe.ts    |   2 +-
 .../update/instance-update.component.html     |  18 --
 .../update/instance-update.component.ts       |   5 +-
 .../webapp/i18n/en/iecBackendInstance.json    |   1 +
 .../webapp/i18n/es/iecBackendInstance.json    |   1 +
 .../startupscripts/02_createTables.sql        |   2 +-
 .../startupscripts/03_initialData.sql         |   7 +-
 release/docker-compose.yaml                   |   3 +
 39 files changed, 638 insertions(+), 260 deletions(-)
 create mode 100644 .envs/global/development
 create mode 100644 .envs/global/prod
 create mode 100644 .envs/global/release
 create mode 100644 .envs/modules/iec/development
 create mode 100644 .envs/modules/iec/prod
 create mode 100644 .envs/modules/iec/release
 create mode 100644 git/iec-Influxdbclient/Dockerfile
 create mode 100644 git/iec-Influxdbclient/config/config.ini
 create mode 100644 git/iec-Influxdbclient/init.sh
 create mode 100644 git/iec-Influxdbclient/piacere_influxdb_client.py
 create mode 100644 git/iec-Influxdbclient/requirements.txt
 create mode 100644 git/iec-Influxdbclient/templates/influxdb_query_templates.py
 create mode 100644 git/iec-Influxdbclient/templates/mysql_query_templates.py

diff --git a/.env b/.env
index a1ab798..e0d8e54 100644
--- a/.env
+++ b/.env
@@ -1,9 +1,10 @@
-ADMIN_USER=piacere
-ADMIN_PASSWORD=piacerePassword
+ADMIN_USER=admin
+ADMIN_PASSWORD=projectPassword
 HTTPS_PORT=443
 SERVER_HOST=ci.piacere.digital.tecnalia.dev
-COMPOSE_PROJECT_NAME=piacere-iec-production
+COMPOSE_PROJECT_NAME=iec
 IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
 IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
 IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
-COMPOSE_FILE=docker-compose.yaml:docker-compose-jhipster-network-external.yaml:docker-compose-traefik-network-external.yaml:release/docker-compose.yaml
+IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
+COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:release/docker-compose.yaml
diff --git a/.env.gen b/.env.gen
index 8fd0ecd..d1ea828 100644
--- a/.env.gen
+++ b/.env.gen
@@ -2,23 +2,41 @@
 # Focus default variables as production, to allow direct download and run in production
 # Required external variables that must be defined externally are those that have no value
 
-#### Environments managed
+#### Environments managed ####
 # this is the default environment if needed uncomment and adjust
 # some conventions on environment prefixes
-# - _ENV_LOCAL_ .env.local purpouse is to cache build and start the setup locally using cache images exposing dev ports (i.e 3306, 5432, 8086, ...) for debug and development purposes. It is the default behaviour (_ENV_LOCAL_:build-cache:.env.local)
-# - _ENV_CACHE_ .env.cache purpouse is to generate images tagged for build cache from that use BUILDKIT_INLINE_CACHE 1 (_ENV_CACHE_:build-cache:.env.cache)
-# - _ENV_RELEASE_ .env.release purpouse is to generate images (that do not use BUILDKIT_INLINE_CACHE 1) tagged for the clients/pilots usage (_ENV_RELEASE_:build-release:.env.release)
-# - _ENV_DEPLOY_ .env purpose is to generate non building docker-compose that uses the release to deploy on generic client (_ENV_DEPLOY_:release:.env)
-# - _ENV_TEST_ .env.test the purpouse is to test from the cache images the correct behaviour without exposing ports ()
+# - development: purpouse is to cache build and start the setup locally using cache images exposing dev ports (i.e 3306, 5432, 8086, ...) for debug and development purposes. It is the default behaviour (local:run-build-cache)
+# - release: purpouse is to generate images (that do not use BUILDKIT_INLINE_CACHE 1) tagged for the clients/pilots usage (release:run-build-release)
+# - prod: purpose is to generate non building docker-compose that uses the release to deploy on generic client (prod:run-release)
+# - test: the purpouse is to test from the cache images the correct behaviour without exposing ports (test:run-cache)
 # types of building
+# - run-build-cache: it focuses in the generation of images with BUILDKIT_INLINE_CACHE 1 for its usage in the cache-from for subsequent build, for each compose-file in compose-file build it finds build/cache the same name to add it to the build, it will use cache from.
+# - run-build-release: it focuses in the generation of images for distribution it avoid using BUILDKIT_INLINE_CACHE 1 to reduce the size, it will use cache from.
 # - build-cache: it focuses in the generation of images with BUILDKIT_INLINE_CACHE 1 for its usage in the cache-from for subsequent build, for each compose-file in compose-file build it finds build/cache the same name to add it to the build, it will use cache from.
-# - build-release: it focuses in the generation of images for distribution it avoid using BUILDKIT_INLINE_CACHE 1 to reduce the size, it will use cache from.
-# - cache: it runs using cache images
-# - release: it runs using release images
+# - build-release: it focuses in the generation of images for distribution it avoid using BUILDKIT_INLINE_CACHE 1 to reduce the size, it will not use cache from.
+# - run-cache: it runs using cache images
+# - run-release: it runs using release images
 # default enviroment 
-# _ENVIRONMENTS=_ENV_LOCAL_:build-cache:.env.local
+# __ENVIRONMENTS=development:run-build-cache
 # to add more enviroments use split with ";"
-_ENVIRONMENTS=_ENV_LOCAL_:build-cache:.env.local;_ENV_RELEASE_:build-release:.env.release;_ENV_DEPLOY_:release:.env;_ENV_PIACERE_:release:.env.piacere
+__ENVIRONMENTS=development:run-build-cache;prod:run-release;release:build-release
+
+#### Modules managed ####
+# this will create individual docker composes that enables the individual usage of the modules through the docker-compose command and specific env files i.e.
+# __MODULES=traefik;step-ca
+# will enable the following docker-compose commands
+# docker-compose --env-file .env/modules/traefik/prod ----project-directory . up -d
+# __MODULES=traefik;step-ca
+__MODULES=iec
+
+#### default environment ####
+# __DEFAULT_ENVIRONMENT=.envs/global/prod
+
+#### default environment ####
+# __DEFAULT_DEVELOPMENT_ENVIRONMENT=.envs/global/development
+
+#### default release environment ####
+# __DEFAULT_RELEASE_ENVIRONMENT=.envs/global/release
 
 #### Common image related ####
 DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
@@ -32,56 +50,65 @@ DOCKER_REGISTRY_CACHE_VERSION=latest
 ### Common Traefik related ###
 TRAEFIK_NETWORK_NAME=traefik_network
 TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure
-TRAEFIK_HTTP_ENTRYPOINT_NAME=web
+# TRAEFIK_HTTP_ENTRYPOINT_NAME=web
 
 #### Common Production related ####
-ADMIN_USER=piacere
-ADMIN_PASSWORD=piacerePassword
+ADMIN_USER=admin
+ADMIN_PASSWORD=projectPassword
+# to calculate password hash `openssl passwd -apr1 $ADMIN_PASSWORD`
+# ADMIN_PASSWORD_HASH='$apr1$chTuJ7f9$.Ul8E16QYHtydKw.ehzZC.'
+# to calculate password bcrypt hash `sudo apt-get update; sudo apt-get install -y apache2-utils; htpasswd -bnBC 12 "" $ADMIN_PASSWORD | tr -d ':\n'`
+# ADMIN_PASSWORD_BCRYPT_HASH='$2y$12$NxJ.FkLgDZWWjc15y9bhX./GOTp67krCxWPanJLyCjofKyIN.zS96'
+# HTTPS_PORT must be 443 if you use step-ca
 HTTPS_PORT=443
+# server host is configured during the sync based on _ENV_LOCAL_ and _ENV_DEPLOY, _ENV_LOCAL_ will be used for test and release unless _ENV_RELEASE_ or _ENV_TEST_ specified
+# SERVER_HOST=project.org
 SERVER_HOST=ci.piacere.digital.tecnalia.dev
 
 #### Platform Specific ####
-TZ=Madrid
-
-#### Platform Specific path ####
+# TZ=Madrid
 EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
 
 #### Common docker-compose related ####
 # https://docs.docker.com/compose/reference/envvars/#compose_file#compose_project_name
 # these are docker-compose related environment variables
-COMPOSE_PROJECT_NAME=piacere-iec-production
+COMPOSE_PROJECT_NAME=iec
 # _ENV_LOCAL_COMPOSE_FILE_BASE= # These are oriented for local vagrant usually it contains local traefik configuration, dev services, etc
 # _ENV_RELEASE_COMPOSE_FILE_BASE= # These are oriented for tagging relevant images for upload to official release repositories
 # _ENV_DEPLOY_COMPOSE_FILE_BASE= # These are oriented for final deployment it contains production traefik configuration, etc
 # _ENV_TEST_COMPOSE_FILE_BASE= # These are oriented for testing
 # COMPOSE_FILE_BASE= # (MANDATORY) These are those main services of the project, that will apply to all the scenarios
 
-COMPOSE_FILE_BASE=docker-compose.yaml
-COMPOSE_FILE_BASE_JHIPSTER_NETWORK=docker-compose-jhipster-network-external.yaml
+COMPOSE_FILE_BASE=
 
 COMPOSE_FILE=
 # COMPOSE_FILE Is generated automatically
 
-COMPOSE_FILE_BASE_NETWORK=docker-compose-traefik-network-external.yaml
-
-IEC_CONFIG_PATH=
-IEC_BASE_PATH=
-
-IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
-IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
-IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
-IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
-IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
-IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
-
-_ENV_LOCAL_SERVER_HOST=192.168.56.1.nip.io
-_ENV_LOCAL_COMPOSE_FILE_BASE_EXPOSE_DEV=docker-compose-dev-expose.yaml
-_ENV_LOCAL_COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_VOLUMES=docker-compose-jhipster-registry-volumes.yaml
-_ENV_LOCAL_COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY=git/jhipster-registry/docker-compose.yaml
-_ENV_LOCAL_COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_DEV=git/jhipster-registry/docker-compose-dev.yaml
-_ENV_LOCAL_JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/
-
-_ENV_PIACERE_COMPOSE_FILE_BASE_PIACERE_BUILD=piacere-build/docker-compose.yaml
-_ENV_PIACERE_COMPOSE_FILE_BASE_PIACERE_RELEASE=release/docker-compose.yaml
-_ENV_PIACERE_COMPOSE_FILE_BASE_ARTIFACTORY=docker-compose-artifactory.yaml
-_ENV_PIACERE_COMPOSE_FILE_BASE_TRAEFIK_NETWORK=docker-compose-traefik-network-internal.yaml
+__iec__COMPOSE_FILE_BASE=docker-compose.yaml
+__iec__COMPOSE_FILE_BASE_NETWORK=docker-compose-traefik-network-external.yaml
+
+__iec__IEC_CONFIG_PATH=
+__iec__IEC_BASE_PATH=
+
+__iec_development__SERVER_HOST=192.168.56.1.nip.io
+__iec_development__COMPOSE_FILE_BASE_EXPOSE_DEV=docker-compose-dev-expose.yaml
+__iec_development__COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_VOLUMES=docker-compose-jhipster-registry-volumes.yaml
+__iec_development__COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY=git/jhipster-registry/docker-compose.yaml
+__iec_development__COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_DEV=git/jhipster-registry/docker-compose-dev.yaml
+__iec_development__JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/
+
+__iec__IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
+__iec__IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
+__iec__IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
+__iec__IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
+__iec__IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
+__iec__IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
+__iec__IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
+__iec__IMAGE_IEC_INFLUXDBCLIENT_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
+
+__iec__COMPOSE_FILE_BASE_JHIPSTER_NETWORK=docker-compose-jhipster-network-external.yaml
+
+__iec_release__COMPOSE_FILE_BASE_PIACERE_BUILD=piacere-build/docker-compose.yaml
+__iec_release__COMPOSE_FILE_BASE_PIACERE_RELEASE=release/docker-compose.yaml
+__iec_release__COMPOSE_FILE_BASE_ARTIFACTORY=docker-compose-artifactory.yaml
+__iec_release__COMPOSE_FILE_BASE_TRAEFIK_NETWORK=docker-compose-traefik-network-internal.yaml
diff --git a/.envs/global/development b/.envs/global/development
new file mode 100644
index 0000000..b0891b9
--- /dev/null
+++ b/.envs/global/development
@@ -0,0 +1,14 @@
+DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
+DOCKER_REGISTRY_CACHE_VERSION=latest
+TRAEFIK_NETWORK_NAME=traefik_network
+TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure
+ADMIN_USER=admin
+ADMIN_PASSWORD=projectPassword
+HTTPS_PORT=443
+SERVER_HOST=192.168.56.1.nip.io
+EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
+COMPOSE_PROJECT_NAME=iec
+IEC_CONFIG_PATH=
+IEC_BASE_PATH=
+JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/
+COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-dev-expose.yaml:docker-compose-jhipster-registry-volumes.yaml:git/jhipster-registry/docker-compose.yaml:git/jhipster-registry/docker-compose-dev.yaml:docker-compose-jhipster-network-external.yaml:build/docker-compose.yaml:build/inline-cache/docker-compose.yaml:build/image/docker-compose.yaml
diff --git a/.envs/global/prod b/.envs/global/prod
new file mode 100644
index 0000000..e0d8e54
--- /dev/null
+++ b/.envs/global/prod
@@ -0,0 +1,10 @@
+ADMIN_USER=admin
+ADMIN_PASSWORD=projectPassword
+HTTPS_PORT=443
+SERVER_HOST=ci.piacere.digital.tecnalia.dev
+COMPOSE_PROJECT_NAME=iec
+IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
+IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
+IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
+IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
+COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:release/docker-compose.yaml
diff --git a/.envs/global/release b/.envs/global/release
new file mode 100644
index 0000000..94a8171
--- /dev/null
+++ b/.envs/global/release
@@ -0,0 +1,18 @@
+DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
+DOCKER_REGISTRY_CACHE_VERSION=latest
+TRAEFIK_NETWORK_NAME=traefik_network
+ADMIN_USER=admin
+ADMIN_PASSWORD=projectPassword
+HTTPS_PORT=443
+SERVER_HOST=ci.piacere.digital.tecnalia.dev
+EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
+COMPOSE_PROJECT_NAME=iec
+IEC_BASE_PATH=
+IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
+IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
+IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
+IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
+IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
+IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
+IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
+COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:piacere-build/docker-compose.yaml:release/docker-compose.yaml:docker-compose-artifactory.yaml:docker-compose-traefik-network-internal.yaml:build/docker-compose.yaml
diff --git a/.envs/modules/iec/development b/.envs/modules/iec/development
new file mode 100644
index 0000000..b0891b9
--- /dev/null
+++ b/.envs/modules/iec/development
@@ -0,0 +1,14 @@
+DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
+DOCKER_REGISTRY_CACHE_VERSION=latest
+TRAEFIK_NETWORK_NAME=traefik_network
+TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure
+ADMIN_USER=admin
+ADMIN_PASSWORD=projectPassword
+HTTPS_PORT=443
+SERVER_HOST=192.168.56.1.nip.io
+EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
+COMPOSE_PROJECT_NAME=iec
+IEC_CONFIG_PATH=
+IEC_BASE_PATH=
+JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/
+COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-dev-expose.yaml:docker-compose-jhipster-registry-volumes.yaml:git/jhipster-registry/docker-compose.yaml:git/jhipster-registry/docker-compose-dev.yaml:docker-compose-jhipster-network-external.yaml:build/docker-compose.yaml:build/inline-cache/docker-compose.yaml:build/image/docker-compose.yaml
diff --git a/.envs/modules/iec/prod b/.envs/modules/iec/prod
new file mode 100644
index 0000000..e0d8e54
--- /dev/null
+++ b/.envs/modules/iec/prod
@@ -0,0 +1,10 @@
+ADMIN_USER=admin
+ADMIN_PASSWORD=projectPassword
+HTTPS_PORT=443
+SERVER_HOST=ci.piacere.digital.tecnalia.dev
+COMPOSE_PROJECT_NAME=iec
+IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
+IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
+IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
+IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
+COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:release/docker-compose.yaml
diff --git a/.envs/modules/iec/release b/.envs/modules/iec/release
new file mode 100644
index 0000000..94a8171
--- /dev/null
+++ b/.envs/modules/iec/release
@@ -0,0 +1,18 @@
+DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
+DOCKER_REGISTRY_CACHE_VERSION=latest
+TRAEFIK_NETWORK_NAME=traefik_network
+ADMIN_USER=admin
+ADMIN_PASSWORD=projectPassword
+HTTPS_PORT=443
+SERVER_HOST=ci.piacere.digital.tecnalia.dev
+EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
+COMPOSE_PROJECT_NAME=iec
+IEC_BASE_PATH=
+IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
+IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
+IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
+IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
+IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
+IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
+IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
+COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:piacere-build/docker-compose.yaml:release/docker-compose.yaml:docker-compose-artifactory.yaml:docker-compose-traefik-network-internal.yaml:build/docker-compose.yaml
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9937bc2..d62f06b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -57,8 +57,8 @@ stages:
     DOCKER_BUILDKIT: 1
     COMPOSE_DOCKER_CLI_BUILD: 1
     DOCKER_COMPOSE_PATH: "."
-    DOCKER_COMPOSE_ENV_FILE_CACHE: ".env.piacere"
-    DOCKER_COMPOSE_ENV_FILE: ".env.piacere"
+    DOCKER_COMPOSE_ENV_FILE_CACHE: ".envs/global/release"
+    DOCKER_COMPOSE_ENV_FILE: ".envs/global/release"
   before_script:
     - !reference [.artifactory-login]
   script:
diff --git a/build/docker-compose.yaml b/build/docker-compose.yaml
index 39c9b16..5d1828d 100644
--- a/build/docker-compose.yaml
+++ b/build/docker-compose.yaml
@@ -23,3 +23,16 @@ services:
         EXTRA_CA_URL: ${EXTRA_CA_URL:?err}
       cache_from:
         - ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err} 
+
+  iec-influxdbclient:
+      build:
+        args:
+          - ENABLED=1
+          - LISTEN_INTERVAL=60
+          - RANGE_START=-30m
+          - TELEGRAF_INTERVAL=10s
+          - AGGREGATE_SAMPLING=60s
+        context: ${IEC_BASE_PATH}git/iec-influxdbclient
+        dockerfile: Dockerfile
+        cache_from:
+          - ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err} 
diff --git a/build/image/docker-compose.yaml b/build/image/docker-compose.yaml
index 206ed79..da3e12d 100644
--- a/build/image/docker-compose.yaml
+++ b/build/image/docker-compose.yaml
@@ -7,3 +7,6 @@ services:
 
   iec-frontend:
     image: ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err}  
+
+  iec-influxdbclient:
+    image: ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-influxdbclient:${DOCKER_REGISTRY_CACHE_VERSION:?err}  
diff --git a/build/inline-cache/docker-compose.yaml b/build/inline-cache/docker-compose.yaml
index 956fffd..607e912 100644
--- a/build/inline-cache/docker-compose.yaml
+++ b/build/inline-cache/docker-compose.yaml
@@ -13,3 +13,8 @@ services:
     build:
       args:
         BUILDKIT_INLINE_CACHE: 1 # For multistage docker
+  
+  iec-influxdbclient:
+    build:
+      args:
+        BUILDKIT_INLINE_CACHE: 1 # For multistage docker
diff --git a/docker-compose-artifactory.yaml b/docker-compose-artifactory.yaml
index 6786dc9..1142f08 100644
--- a/docker-compose-artifactory.yaml
+++ b/docker-compose-artifactory.yaml
@@ -11,4 +11,8 @@ services:
     build:
       labels:
         com.jfrog.artifactory.retention.maxCount: 6
+  iec-influxdbclient:
+    build:
+      labels:
+        com.jfrog.artifactory.retention.maxCount: 6
 
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 41dbaa8..558d2d3 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -5,7 +5,7 @@ services:
     volumes:
       - iec-mysql_data:/var/lib/mysql
     networks:
-      default:
+      traefik_network:
 
   iec-backend:
     restart: always
@@ -17,8 +17,7 @@ services:
       # SPRING_R2DBC_URL: r2dbc:mysql://iec-mysql:3306/iecBackend?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
       # SPRING_LIQUIBASE_URL: jdbc:mysql://iec-mysql:3306/iecBackend?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
     networks:
-      default:
-      jhipster_network:
+      traefik_network:
 
   iec-frontend:
     restart: always
@@ -26,8 +25,6 @@ services:
       GLOBAL_PASSWORD: ${ADMIN_PASSWORD}
       JHIPSTER_CORS_ALLOWEDORIGINS: "https://iec.${SERVER_HOST:?err}:${HTTPS_PORT}"
     networks:
-      default:
-      jhipster_network:
       traefik_network:
     labels:
       - "traefik.enable=true"
@@ -35,8 +32,22 @@ services:
       - "traefik.http.routers.iec-frontend.entrypoints=websecure"
       - "traefik.http.routers.iec-frontend.rule=Host(`iec.${SERVER_HOST:?err}`)"
 
+  # PIACERE InfluxDB Client
+  iec-influxdbclient:
+      restart: always
+      environment:
+        - INFLUXDB_URL=https://influxdb.pm.ci.piacere.digital.tecnalia.dev
+        - INFLUXDB_TOKEN=Fu7iwOeqhYOd6A_1Fg9GKSUNKBwl-FEAWn8cUTXuMUwAXXge4WETVAxg4iRh_l9vdYZN9klkf3aY250h6wyNKg==
+        - INFLUXDB_ORGANIZATION=piacere
+        - INFLUXDB_BUCKET=bucket
+        - INFLUXDB_MEASUREMENT=psl
+        - INFLUXDB_FIELD=input_system_availability_percent
+        - MYSQL_HOST=iec-mysql
+        - MYSQL_USER=root
+        - MYSQL_PASSWORD=
+        - MYSQL_DB=iecbackend
+      networks:
+        traefik_network:
+
 volumes:
   iec-mysql_data:
-
-networks:
-  default:
diff --git a/git/iec-Influxdbclient/Dockerfile b/git/iec-Influxdbclient/Dockerfile
new file mode 100644
index 0000000..16e3e1e
--- /dev/null
+++ b/git/iec-Influxdbclient/Dockerfile
@@ -0,0 +1,24 @@
+FROM python:3.9-slim-bullseye
+
+ARG ENABLED
+ARG LISTEN_INTERVAL
+ARG RANGE_START
+ARG TELEGRAF_INTERVAL
+ARG AGGREGATE_SAMPLING
+
+RUN mkdir -p /piacere_influxdb_client
+WORKDIR /piacere_influxdb_client
+
+COPY . /piacere_influxdb_client
+
+RUN apt-get update && \
+	pip3 install --no-cache-dir -r requirements.txt && \
+	sed -i "s|\"ENABLED\"|$ENABLED|g" /piacere_influxdb_client/config/config.ini && \
+	sed -i "s|\"LISTEN_INTERVAL\"|$LISTEN_INTERVAL|g" /piacere_influxdb_client/config/config.ini && \
+	sed -i "s|\"RANGE_START\"|$RANGE_START|g" /piacere_influxdb_client/config/config.ini && \
+	sed -i "s|\"TELEGRAF_INTERVAL\"|$TELEGRAF_INTERVAL|g" /piacere_influxdb_client/config/config.ini && \
+	sed -i "s|\"AGGREGATE_SAMPLING\"|$AGGREGATE_SAMPLING|g" /piacere_influxdb_client/config/config.ini
+
+ENV PATH /piacere_influxdb_client:$PATH
+
+ENTRYPOINT ["sh", "./init.sh"]
\ No newline at end of file
diff --git a/git/iec-Influxdbclient/config/config.ini b/git/iec-Influxdbclient/config/config.ini
new file mode 100644
index 0000000..ce5923f
--- /dev/null
+++ b/git/iec-Influxdbclient/config/config.ini
@@ -0,0 +1,6 @@
+[PIACERE-INFLUXDB-CLIENT]
+piacere.influxdb.enabled = "ENABLED"
+piacere.influxdb.sleep = "LISTEN_INTERVAL"
+piacere.influxdb.range.start = "RANGE_START"
+piacere.influxdb.telegraf.interval = "TELEGRAF_INTERVAL"
+piacere.influxdb.aggregate.sampling = "AGGREGATE_SAMPLING"
\ No newline at end of file
diff --git a/git/iec-Influxdbclient/init.sh b/git/iec-Influxdbclient/init.sh
new file mode 100644
index 0000000..cd16826
--- /dev/null
+++ b/git/iec-Influxdbclient/init.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+python piacere_influxdb_client.py
\ No newline at end of file
diff --git a/git/iec-Influxdbclient/piacere_influxdb_client.py b/git/iec-Influxdbclient/piacere_influxdb_client.py
new file mode 100644
index 0000000..7dd6aa5
--- /dev/null
+++ b/git/iec-Influxdbclient/piacere_influxdb_client.py
@@ -0,0 +1,182 @@
+import configparser
+import influxdb_client
+import json
+import logging
+import os
+import pymysql
+import time
+
+from datetime import datetime
+
+from influxdb_client import InfluxDBClient, Point, WritePrecision
+from influxdb_client.client.write_api import SYNCHRONOUS
+
+import templates.influxdb_query_templates as influxdb_query_templates
+import templates.mysql_query_templates as mysql_query_templates
+
+
+# Configure the logging level
+logging.basicConfig(level = logging.INFO)
+
+# Create the config object and read config.ini file
+config = configparser.ConfigParser()
+config.read('config/config.ini')
+
+
+# Function: commitToDatabase
+def commitToDatabase(query_result):
+    # logging.info(json.dumps(query_result, indent = 4))
+    conn = None
+    try:
+        # Connect to the database
+        conn = pymysql.connect(
+            host = os.environ.get("MYSQL_HOST"),
+            user = os.environ.get("MYSQL_USER"),
+            password = os.environ.get("MYSQL_PASSWORD"),
+            db = os.environ.get("MYSQL_DB"))
+
+        # Declare the custom cursor and update the database
+        cursor = conn.cursor()
+        if query_result:
+            # Transform the influxdb query result, replacing the service name by the service id
+            # and discarding the entries whose service id is null
+            data_to_process = {}
+            cursor.execute(mysql_query_templates.mysql_select_services_query)
+            services = cursor.fetchall()
+            if services and len(services) > 0:
+                for key in query_result:
+                    service_id = None
+                    for service in services:
+                        if query_result[key]['service'] == service[1]:
+                            service_id = service[0]
+                            break
+                    if service_id:
+                        query_result[key]['service'] = service_id
+                        data_to_process[key] = query_result[key]
+
+            # Fetch the instances, and separate them into active and inactive
+            logging.info("")
+            logging.info(" > Data to be processed:")
+            logging.info(json.dumps(data_to_process, indent = 4))
+            cursor.execute(mysql_query_templates.mysql_select_instances_query)
+            instances = cursor.fetchall()
+            active_instances = []
+            inactive_instances = []
+            if instances and len(instances) > 0:
+                for instance in instances:
+                    if instance[4]:
+                        inactive_instances.append(instance)
+                    else:
+                        active_instances.append(instance)
+            logging.info("")
+            logging.info(" > Checking instances...")
+            logging.info(" > Active instances:  " + str(len(active_instances)))
+            logging.info(" > Inactive instances:  " + str(len(inactive_instances)))
+
+            # Set all the active instances to inactive
+            if active_instances and len(active_instances) > 0:
+                logging.info(" > Setting the active instances to inactive...")
+                cursor.execute(mysql_query_templates.mysql_update_instances_to_inactive_query % (datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
+                conn.commit()
+
+            # Search the result of the influxdb query in active and inactive instance lists
+            foundInActiveInstances = False
+            foundInInactiveInstances = False
+            for key in data_to_process:
+                for instance in active_instances:
+                    if key == instance[1] and data_to_process[key]['instance'] == instance[2] and data_to_process[key]['service'] == instance[5] and data_to_process[key]['host'] == instance[3]:
+                        foundInActiveInstances = True
+                        break
+                for instance in inactive_instances:
+                    if key == instance[1] and data_to_process[key]['instance'] == instance[2] and data_to_process[key]['service'] == instance[5] and data_to_process[key]['host'] == instance[3]:
+                        foundInInactiveInstances = True
+                        break
+
+                # If the instance is not found, insert into database. If the instances is found as active, update database
+                if foundInActiveInstances is False and foundInInactiveInstances is False:
+                    logging.info(" > Inserting '" + data_to_process[key]['instance'] + "' instance...")
+                    cursor.execute(mysql_query_templates.mysql_insert_instance_query % (key, data_to_process[key]['instance'], data_to_process[key]['host'], data_to_process[key]['availability'], datetime.now().strftime('%Y-%m-%d %H:%M:%S'), datetime.now().strftime('%Y-%m-%d %H:%M:%S'), data_to_process[key]['service']))
+                    conn.commit()
+                    logging.info(" > The instance was inserted successfully!")
+                    logging.info("")
+                elif foundInActiveInstances is True:
+                    logging.info(" > Updating '" + data_to_process[key]['instance'] + "' instance...")
+                    cursor.execute(mysql_query_templates.mysql_update_instance_query % (data_to_process[key]['availability'], datetime.now().strftime('%Y-%m-%d %H:%M:%S'), key, data_to_process[key]['instance'], data_to_process[key]['host'], data_to_process[key]['service']))
+                    conn.commit()
+                    logging.info(" > The instance was updated successfully!")
+                    logging.info("")
+    except Exception as error:
+        logging.error(str(error))
+    finally:
+        # Close the connection
+        if conn:
+            conn.close()
+
+
+# Welcome message
+logging.info('')
+logging.info('******************************************************************************************')
+logging.info('***************************  PIACERE InfluxDB Client started!  ***************************')
+logging.info('******************************************************************************************')
+
+
+# Start the process
+if int(config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.enabled']) != 1:
+    logging.info('')
+    logging.info('******************************************************************************************')
+    logging.info('*************************  PIACERE InfluxDB Client not enabled!  *************************')
+    logging.info('*************************  PIACERE InfluxDB Client exited!       *************************')
+    logging.info('******************************************************************************************')
+else:
+    try:
+        # Create the query result object
+        query_result = {}
+
+        # Create the InfluxDB client and the query API
+        client = influxdb_client.InfluxDBClient(
+            url = os.environ.get("INFLUXDB_URL"),
+            token = os.environ.get("INFLUXDB_TOKEN"),
+            org = os.environ.get("INFLUXDB_ORGANIZATION"))
+        query_api = client.query_api()
+
+        # Start listening
+        while True:
+            logging.info(' > Listening...')
+
+            # Execute the query and extract the data as a JSON object
+            tables = query_api.query(influxdb_query_templates.influxdb_query, org = os.environ.get("INFLUXDB_ORGANIZATION"))
+            tables_to_json = json.loads(tables.to_json(indent = 4))
+
+            # Loop through the query result (if needed)
+            if tables_to_json and len(tables_to_json) > 0:
+                # logging.info(json.dumps(tables_to_json, indent = 4))
+                deployments = []
+                for table in tables_to_json:
+                   if table['deployment_id'] not in deployments:
+                       deployments.append(table['deployment_id'])
+                       if table['deployment_id'] not in query_result:
+                           query_result[table['deployment_id']] = { 'service': None, 'instance': None, 'host': None, 'availability': None, 'time': 0 }
+                if deployments and len(deployments) > 0:
+                    for deployment in deployments:
+                        for table in tables_to_json:
+                            if table['deployment_id'] == deployment:
+                                result_time = datetime.strptime(table['_time'][:19], '%Y-%m-%dT%H:%M:%S').timestamp() * 1000
+                                if result_time > query_result[deployment]['time']:
+                                    if 'doml_element_type' in table:
+                                        query_result[deployment]['service'] = table['doml_element_type']
+                                    query_result[deployment]['instance'] = table['doml_element_name']
+                                    if 'host' in table:
+                                        query_result[deployment]['host'] = table['host']
+                                    query_result[deployment]['availability'] = table['_value']
+                                    query_result[deployment]['time'] = result_time
+
+            # Commit to database
+            commitToDatabase(query_result)
+
+            # Wait the configured interval
+            time.sleep(int(config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.sleep']))
+    except Exception as error:
+        logging.info('')
+        logging.info('******************************************************************************************')
+        logging.error(str(error))
+        logging.info('******************************************************************************************')
\ No newline at end of file
diff --git a/git/iec-Influxdbclient/requirements.txt b/git/iec-Influxdbclient/requirements.txt
new file mode 100644
index 0000000..a3af078
--- /dev/null
+++ b/git/iec-Influxdbclient/requirements.txt
@@ -0,0 +1,4 @@
+cryptography == 41.0.5
+influxdb-client == 1.38.0
+pymysql == 1.1.0
+Werkzeug == 2.2.2
\ No newline at end of file
diff --git a/git/iec-Influxdbclient/templates/influxdb_query_templates.py b/git/iec-Influxdbclient/templates/influxdb_query_templates.py
new file mode 100644
index 0000000..ce1c8aa
--- /dev/null
+++ b/git/iec-Influxdbclient/templates/influxdb_query_templates.py
@@ -0,0 +1,39 @@
+import configparser
+import os
+
+# Create the config object and read config.ini file
+config = configparser.ConfigParser()
+config.read('config/config.ini')
+
+# Replacing variables
+influxdb_query_data = {
+    "bucket": os.environ.get("INFLUXDB_BUCKET"),
+    "start": config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.range.start'],
+    "telegraf_interval": config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.telegraf.interval'],
+    "aggregate_sampling": config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.aggregate.sampling'],
+    "measurement": os.environ.get("INFLUXDB_MEASUREMENT"),
+    "field": os.environ.get("INFLUXDB_FIELD")
+}
+
+# The query template
+INFLUXDB_QUERY_TEMPLATE = """
+    bucket = "{bucket}"
+    start = {start}
+    telegraf_interval = {telegraf_interval}
+    discard_level = int(v: duration(v: uint(v: telegraf_interval) + uint(v: 5s)))/1000000000
+    aggregate_sampling = {aggregate_sampling}
+    measurement = "{measurement}"
+    field = "{field}"
+
+    from(bucket: bucket)
+    |> range(start: start)
+    |> filter(fn: (r) => r._measurement == measurement)
+    |> filter(fn: (r) => r._field == field)
+    |> keep(columns: ["deployment_id", "host", "doml_element_name", "doml_element_type", "_time", "_field", "_value"])
+    |> aggregateWindow(every: 1m, fn: mean, createEmpty: true)
+    |> fill(column: "_value", value: 0.0)
+    |> yield(name: "mean")
+"""
+
+# The final query
+influxdb_query = INFLUXDB_QUERY_TEMPLATE.format(**influxdb_query_data)
\ No newline at end of file
diff --git a/git/iec-Influxdbclient/templates/mysql_query_templates.py b/git/iec-Influxdbclient/templates/mysql_query_templates.py
new file mode 100644
index 0000000..a5fead8
--- /dev/null
+++ b/git/iec-Influxdbclient/templates/mysql_query_templates.py
@@ -0,0 +1,85 @@
+import configparser
+import os
+
+# Create the config object and read config.ini file
+config = configparser.ConfigParser()
+config.read('config/config.ini')
+
+# Replacing variables
+mysql_connection_data = {
+	"mysql_host": os.environ.get("MYSQL_HOST"),
+	"mysql_db": os.environ.get("MYSQL_DB"),
+	"mysql_user": os.environ.get("MYSQL_USER"),
+	"mysql_password": os.environ.get("MYSQL_PASSWORD")
+}
+
+# The select instances query
+MYSQL_SELECT_INSTANCES_QUERY_TEMPLATE = """
+    SELECT
+        id,
+        deployment_id,
+        instance_name,
+        instance_ip_url,
+        deleted_date,
+        service_id
+    FROM
+        instance
+"""
+
+# The select services query
+MYSQL_SELECT_SERVICES_QUERY_TEMPLATE = """
+    SELECT
+        id,
+        service_name
+    FROM
+        root_service
+"""
+
+# The update instances to inactive query
+MYSQL_UPDATE_INSTANCES_TO_INACTIVE_QUERY_TEMPLATE = """
+    UPDATE instance
+    SET
+        deleted_date = '%s'
+    WHERE
+        deleted_date is null
+"""
+
+# The delete instances query
+MYSQL_DELETE_INSTANCES_QUERY_TEMPLATE = """
+    DELETE FROM instance
+"""
+
+# The insert instance query template
+MYSQL_INSERT_INSTANCE_QUERY_TEMPLATE = """
+    INSERT INTO instance (
+        deployment_id,
+        instance_name,
+        instance_ip_url,
+        average_availability,
+        created_date,
+        last_modified_date,
+        service_id
+    ) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', %s)
+"""
+
+# The update instance query template
+MYSQL_UPDATE_INSTANCE_QUERY_TEMPLATE = """
+    UPDATE instance
+    SET
+        average_availability = '%s',
+        last_modified_date = '%s',
+        deleted_date = NULL
+    WHERE
+        deployment_id = '%s' AND
+        instance_name = '%s' AND
+        instance_ip_url = '%s' AND
+        service_id = %s
+"""
+
+# The final queries
+mysql_select_instances_query = MYSQL_SELECT_INSTANCES_QUERY_TEMPLATE
+mysql_select_services_query = MYSQL_SELECT_SERVICES_QUERY_TEMPLATE
+mysql_update_instances_to_inactive_query = MYSQL_UPDATE_INSTANCES_TO_INACTIVE_QUERY_TEMPLATE
+mysql_delete_instances_query = MYSQL_DELETE_INSTANCES_QUERY_TEMPLATE
+mysql_insert_instance_query = MYSQL_INSERT_INSTANCE_QUERY_TEMPLATE
+mysql_update_instance_query = MYSQL_UPDATE_INSTANCE_QUERY_TEMPLATE
\ No newline at end of file
diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/domain/Instance.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/domain/Instance.java
index 0d9df80..d8fb43f 100644
--- a/git/iec-backend/src/main/java/com/piacere/iec/backend/domain/Instance.java
+++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/domain/Instance.java
@@ -38,11 +38,10 @@ public class Instance implements Serializable {
     @Size(max = 70)
     @Column(name = "instance_ip_url", length = 70, nullable = false)
     private String instanceIpUrl;
-
-    @NotNull
-    @Size(max = 70)
-    @Column(name = "email", length = 70, nullable = false)
-    private String email;
+    
+    @Size(max = 8)
+    @Column(name = "average_availability", length = 8, nullable = true)
+    private String averageAvailability;
 
     @NotNull
     @Column(name = "created_date", nullable = false)
@@ -115,19 +114,19 @@ public class Instance implements Serializable {
     public void setInstanceIpUrl(String instanceIpUrl) {
         this.instanceIpUrl = instanceIpUrl;
     }
+    
+    public String getAverageAvailability() {
+		return averageAvailability;
+	}
 
-    public String getEmail() {
-        return this.email;
-    }
-
-    public Instance email(String email) {
-        this.email = email;
+    public Instance averageAvailability(String averageAvailability) {
+        this.averageAvailability = averageAvailability;
         return this;
     }
-
-    public void setEmail(String email) {
-        this.email = email;
-    }
+    
+	public void setAverageAvailability(String averageAvailability) {
+		this.averageAvailability = averageAvailability;
+	}
 
     public Instant getCreatedDate() {
         return this.createdDate;
@@ -239,7 +238,7 @@ public class Instance implements Serializable {
             ", deploymentId='" + getDeploymentId() + "'" +
             ", instanceName='" + getInstanceName() + "'" +
             ", instanceIpUrl='" + getInstanceIpUrl() + "'" +
-            ", email='" + getEmail() + "'" +
+            ", averageAvailability='" + getAverageAvailability() + "'" +
             ", createdDate='" + getCreatedDate() + "'" +
             ", lastModifiedDate='" + getLastModifiedDate() + "'" +
             ", deletedDate='" + getDeletedDate() + "'" +
diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/InstanceQueryService.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/InstanceQueryService.java
index 30aeba2..5d44e9f 100644
--- a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/InstanceQueryService.java
+++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/InstanceQueryService.java
@@ -92,8 +92,8 @@ public class InstanceQueryService extends QueryService<Instance> {
             if (criteria.getInstanceIpUrl() != null) {
                 specification = specification.and(buildStringSpecification(criteria.getInstanceIpUrl(), Instance_.instanceIpUrl));
             }
-            if (criteria.getEmail() != null) {
-                specification = specification.and(buildStringSpecification(criteria.getEmail(), Instance_.email));
+            if (criteria.getAverageAvailability() != null) {
+                specification = specification.and(buildStringSpecification(criteria.getAverageAvailability(), Instance_.averageAvailability));
             }
             if (criteria.getCreatedDate() != null) {
                 specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), Instance_.createdDate));
diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/criteria/InstanceCriteria.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/criteria/InstanceCriteria.java
index 0c751b1..2e7a207 100644
--- a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/criteria/InstanceCriteria.java
+++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/criteria/InstanceCriteria.java
@@ -2,13 +2,10 @@ package com.piacere.iec.backend.service.criteria;
 
 import java.io.Serializable;
 import java.util.Objects;
+
 import tech.jhipster.service.Criteria;
-import tech.jhipster.service.filter.BooleanFilter;
-import tech.jhipster.service.filter.DoubleFilter;
 import tech.jhipster.service.filter.Filter;
-import tech.jhipster.service.filter.FloatFilter;
 import tech.jhipster.service.filter.InstantFilter;
-import tech.jhipster.service.filter.IntegerFilter;
 import tech.jhipster.service.filter.LongFilter;
 import tech.jhipster.service.filter.StringFilter;
 
@@ -30,8 +27,8 @@ public class InstanceCriteria implements Serializable, Criteria {
     private StringFilter instanceName;
 
     private StringFilter instanceIpUrl;
-
-    private StringFilter email;
+    
+    private StringFilter averageAvailability;
 
     private InstantFilter createdDate;
 
@@ -49,7 +46,7 @@ public class InstanceCriteria implements Serializable, Criteria {
         this.id = other.id == null ? null : other.id.copy();
         this.instanceName = other.instanceName == null ? null : other.instanceName.copy();
         this.instanceIpUrl = other.instanceIpUrl == null ? null : other.instanceIpUrl.copy();
-        this.email = other.email == null ? null : other.email.copy();
+        this.averageAvailability = other.averageAvailability == null ? null : other.averageAvailability.copy();
         this.createdDate = other.createdDate == null ? null : other.createdDate.copy();
         this.lastModifiedDate = other.lastModifiedDate == null ? null : other.lastModifiedDate.copy();
         this.deletedDate = other.deletedDate == null ? null : other.deletedDate.copy();
@@ -106,20 +103,20 @@ public class InstanceCriteria implements Serializable, Criteria {
     public void setInstanceIpUrl(StringFilter instanceIpUrl) {
         this.instanceIpUrl = instanceIpUrl;
     }
-
-    public StringFilter getEmail() {
-        return email;
+    
+    public StringFilter getAverageAvailability() {
+        return averageAvailability;
     }
 
-    public StringFilter email() {
-        if (email == null) {
-            email = new StringFilter();
+    public StringFilter averageAvailability() {
+        if (averageAvailability == null) {
+        	averageAvailability = new StringFilter();
         }
-        return email;
+        return averageAvailability;
     }
 
-    public void setEmail(StringFilter email) {
-        this.email = email;
+    public void setAverageAvailability(StringFilter averageAvailability) {
+        this.averageAvailability = averageAvailability;
     }
 
     public InstantFilter getCreatedDate() {
@@ -210,7 +207,7 @@ public class InstanceCriteria implements Serializable, Criteria {
             Objects.equals(id, that.id) &&
             Objects.equals(instanceName, that.instanceName) &&
             Objects.equals(instanceIpUrl, that.instanceIpUrl) &&
-            Objects.equals(email, that.email) &&
+            Objects.equals(averageAvailability, that.averageAvailability) &&
             Objects.equals(createdDate, that.createdDate) &&
             Objects.equals(lastModifiedDate, that.lastModifiedDate) &&
             Objects.equals(deletedDate, that.deletedDate) &&
@@ -221,7 +218,7 @@ public class InstanceCriteria implements Serializable, Criteria {
 
     @Override
     public int hashCode() {
-        return Objects.hash(id, instanceName, instanceIpUrl, email, createdDate, lastModifiedDate, deletedDate, incidenceId, serviceId);
+        return Objects.hash(id, instanceName, instanceIpUrl, averageAvailability, createdDate, lastModifiedDate, deletedDate, incidenceId, serviceId);
     }
 
     // prettier-ignore
@@ -231,7 +228,7 @@ public class InstanceCriteria implements Serializable, Criteria {
             (id != null ? "id=" + id + ", " : "") +
             (instanceName != null ? "instanceName=" + instanceName + ", " : "") +
             (instanceIpUrl != null ? "instanceIpUrl=" + instanceIpUrl + ", " : "") +
-            (email != null ? "email=" + email + ", " : "") +
+            (averageAvailability != null ? "averageAvailability=" + averageAvailability + ", " : "") +
             (createdDate != null ? "createdDate=" + createdDate + ", " : "") +
             (lastModifiedDate != null ? "lastModifiedDate=" + lastModifiedDate + ", " : "") +
             (deletedDate != null ? "deletedDate=" + deletedDate + ", " : "") +
diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceDTO.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceDTO.java
index dd4e815..1b92152 100644
--- a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceDTO.java
+++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceDTO.java
@@ -6,7 +6,8 @@ import java.util.HashSet;
 import java.util.Objects;
 import java.util.Set;
 
-import javax.validation.constraints.*;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
 
 import com.piacere.iec.backend.domain.InstanceIncidence;
 
@@ -27,10 +28,9 @@ public class InstanceDTO implements Serializable {
     @NotNull
     @Size(max = 70)
     private String instanceIpUrl;
-
-    @NotNull
-    @Size(max = 70)
-    private String email;
+    
+    @Size(max = 8)
+    private String averageAvailability;
 
     @NotNull
     private Instant createdDate;
@@ -52,7 +52,7 @@ public class InstanceDTO implements Serializable {
 		this.deploymentId=instanceSaveInfoDTO.getDeploymentId();
 		this.instanceName = instanceSaveInfoDTO.getInstanceName();
 		this.instanceIpUrl = instanceSaveInfoDTO.getInstanceIpUrl();
-		this.email = instanceSaveInfoDTO.getEmail();
+		this.averageAvailability = instanceSaveInfoDTO.getAverageAvailability();
 		this.service= new RootServiceDTO();
 		this.service.setServiceName(instanceSaveInfoDTO.getServiceName());
 	}
@@ -88,13 +88,13 @@ public class InstanceDTO implements Serializable {
     public void setInstanceIpUrl(String instanceIpUrl) {
         this.instanceIpUrl = instanceIpUrl;
     }
-
-    public String getEmail() {
-        return email;
+    
+    public String getAverageAvailability() {
+        return averageAvailability;
     }
 
-    public void setEmail(String email) {
-        this.email = email;
+    public void setAverageAvailability(String averageAvailability) {
+        this.averageAvailability = averageAvailability;
     }
 
     public Instant getCreatedDate() {
@@ -166,7 +166,7 @@ public class InstanceDTO implements Serializable {
             ", deploymentId='" + getDeploymentId() + "'" +            
             ", instanceName='" + getInstanceName() + "'" +
             ", instanceIpUrl='" + getInstanceIpUrl() + "'" +
-            ", email='" + getEmail() + "'" +
+            ", averageAvailability='" + getAverageAvailability() + "'" +
             ", createdDate='" + getCreatedDate() + "'" +
             ", lastModifiedDate='" + getLastModifiedDate() + "'" +
             ", deletedDate='" + getDeletedDate() + "'" +
diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceSaveInfoDTO.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceSaveInfoDTO.java
index e63560d..6922b76 100644
--- a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceSaveInfoDTO.java
+++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceSaveInfoDTO.java
@@ -1,14 +1,10 @@
 package com.piacere.iec.backend.service.dto;
 
 import java.io.Serializable;
-import java.time.Instant;
-import java.util.HashSet;
 import java.util.Objects;
-import java.util.Set;
 
-import javax.validation.constraints.*;
-
-import com.piacere.iec.backend.domain.InstanceIncidence;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
 
 /**
  * A DTO for the {@link com.piacere.iec.backend.domain.Instance} entity.
@@ -29,6 +25,9 @@ public class InstanceSaveInfoDTO implements Serializable {
     @NotNull
     @Size(max = 70)
     private String email;
+    
+    @Size(max = 8)
+    private String averageAvailability;
 
     private String serviceName;
 
@@ -56,7 +55,7 @@ public class InstanceSaveInfoDTO implements Serializable {
     public void setInstanceIpUrl(String instanceIpUrl) {
         this.instanceIpUrl = instanceIpUrl;
     }
-
+    
     public String getEmail() {
         return email;
     }
@@ -64,6 +63,14 @@ public class InstanceSaveInfoDTO implements Serializable {
     public void setEmail(String email) {
         this.email = email;
     }
+    
+    public String getAverageAvailability() {
+        return averageAvailability;
+    }
+
+    public void setAverageAvailability(String averageAvailability) {
+        this.averageAvailability = averageAvailability;
+    }
 
 	public String getServiceName() {
 		return serviceName;
@@ -102,6 +109,7 @@ public class InstanceSaveInfoDTO implements Serializable {
             ", instanceName='" + getInstanceName() + "'" +
             ", instanceIpUrl='" + getInstanceIpUrl() + "'" +
             ", email='" + getEmail() + "'" +
+            ", averageAvailability='" + getAverageAvailability() + "'" +
             ", serviceName='" + getServiceName() +
             "}";
     }
diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/web/rest/InstanceResource.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/web/rest/InstanceResource.java
index bb5d4d8..f7763c7 100644
--- a/git/iec-backend/src/main/java/com/piacere/iec/backend/web/rest/InstanceResource.java
+++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/web/rest/InstanceResource.java
@@ -2,6 +2,7 @@ package com.piacere.iec.backend.web.rest;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.time.Instant;
 import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
@@ -84,6 +85,7 @@ public class InstanceResource {
         if (instanceDTO.getId() != null) {
             throw new BadRequestAlertException("A new instance cannot already have an ID", ENTITY_NAME, "idexists");
         }
+        instanceDTO.setDeletedDate(Instant.now());
         InstanceDTO result = instanceService.save(instanceDTO);
         return ResponseEntity
             .created(new URI("/api/instances/" + result.getId()))
diff --git a/git/iec-backend/src/test/java/com/piacere/iec/backend/web/rest/InstanceResourceIT.java b/git/iec-backend/src/test/java/com/piacere/iec/backend/web/rest/InstanceResourceIT.java
index 612fc60..8dedb9d 100644
--- a/git/iec-backend/src/test/java/com/piacere/iec/backend/web/rest/InstanceResourceIT.java
+++ b/git/iec-backend/src/test/java/com/piacere/iec/backend/web/rest/InstanceResourceIT.java
@@ -42,9 +42,6 @@ class InstanceResourceIT {
     private static final String DEFAULT_INSTANCE_IP_URL = "AAAAAAAAAA";
     private static final String UPDATED_INSTANCE_IP_URL = "BBBBBBBBBB";
 
-    private static final String DEFAULT_EMAIL = "AAAAAAAAAA";
-    private static final String UPDATED_EMAIL = "BBBBBBBBBB";
-
     private static final Instant DEFAULT_CREATED_DATE = Instant.ofEpochMilli(0L);
     private static final Instant UPDATED_CREATED_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS);
 
@@ -84,7 +81,6 @@ class InstanceResourceIT {
         Instance instance = new Instance()
             .instanceName(DEFAULT_INSTANCE_NAME)
             .instanceIpUrl(DEFAULT_INSTANCE_IP_URL)
-            .email(DEFAULT_EMAIL)
             .createdDate(DEFAULT_CREATED_DATE)
             .lastModifiedDate(DEFAULT_LAST_MODIFIED_DATE)
             .deletedDate(DEFAULT_DELETED_DATE);
@@ -101,7 +97,6 @@ class InstanceResourceIT {
         Instance instance = new Instance()
             .instanceName(UPDATED_INSTANCE_NAME)
             .instanceIpUrl(UPDATED_INSTANCE_IP_URL)
-            .email(UPDATED_EMAIL)
             .createdDate(UPDATED_CREATED_DATE)
             .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE)
             .deletedDate(UPDATED_DELETED_DATE);
@@ -129,7 +124,6 @@ class InstanceResourceIT {
         Instance testInstance = instanceList.get(instanceList.size() - 1);
         assertThat(testInstance.getInstanceName()).isEqualTo(DEFAULT_INSTANCE_NAME);
         assertThat(testInstance.getInstanceIpUrl()).isEqualTo(DEFAULT_INSTANCE_IP_URL);
-        assertThat(testInstance.getEmail()).isEqualTo(DEFAULT_EMAIL);
         assertThat(testInstance.getCreatedDate()).isEqualTo(DEFAULT_CREATED_DATE);
         assertThat(testInstance.getLastModifiedDate()).isEqualTo(DEFAULT_LAST_MODIFIED_DATE);
         assertThat(testInstance.getDeletedDate()).isEqualTo(DEFAULT_DELETED_DATE);
@@ -194,9 +188,6 @@ class InstanceResourceIT {
     @Transactional
     void checkEmailIsRequired() throws Exception {
         int databaseSizeBeforeTest = instanceRepository.findAll().size();
-        // set the field null
-        instance.setEmail(null);
-
         // Create the Instance, which fails.
         InstanceDTO instanceDTO = instanceMapper.toDto(instance);
 
@@ -240,7 +231,6 @@ class InstanceResourceIT {
             .andExpect(jsonPath("$.[*].id").value(hasItem(instance.getId().intValue())))
             .andExpect(jsonPath("$.[*].instanceName").value(hasItem(DEFAULT_INSTANCE_NAME)))
             .andExpect(jsonPath("$.[*].instanceIpUrl").value(hasItem(DEFAULT_INSTANCE_IP_URL)))
-            .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL)))
             .andExpect(jsonPath("$.[*].createdDate").value(hasItem(DEFAULT_CREATED_DATE.toString())))
             .andExpect(jsonPath("$.[*].lastModifiedDate").value(hasItem(DEFAULT_LAST_MODIFIED_DATE.toString())))
             .andExpect(jsonPath("$.[*].deletedDate").value(hasItem(DEFAULT_DELETED_DATE.toString())));
@@ -260,7 +250,6 @@ class InstanceResourceIT {
             .andExpect(jsonPath("$.id").value(instance.getId().intValue()))
             .andExpect(jsonPath("$.instanceName").value(DEFAULT_INSTANCE_NAME))
             .andExpect(jsonPath("$.instanceIpUrl").value(DEFAULT_INSTANCE_IP_URL))
-            .andExpect(jsonPath("$.email").value(DEFAULT_EMAIL))
             .andExpect(jsonPath("$.createdDate").value(DEFAULT_CREATED_DATE.toString()))
             .andExpect(jsonPath("$.lastModifiedDate").value(DEFAULT_LAST_MODIFIED_DATE.toString()))
             .andExpect(jsonPath("$.deletedDate").value(DEFAULT_DELETED_DATE.toString()));
@@ -440,84 +429,6 @@ class InstanceResourceIT {
         defaultInstanceShouldBeFound("instanceIpUrl.doesNotContain=" + UPDATED_INSTANCE_IP_URL);
     }
 
-    @Test
-    @Transactional
-    void getAllInstancesByEmailIsEqualToSomething() throws Exception {
-        // Initialize the database
-        instanceRepository.saveAndFlush(instance);
-
-        // Get all the instanceList where email equals to DEFAULT_EMAIL
-        defaultInstanceShouldBeFound("email.equals=" + DEFAULT_EMAIL);
-
-        // Get all the instanceList where email equals to UPDATED_EMAIL
-        defaultInstanceShouldNotBeFound("email.equals=" + UPDATED_EMAIL);
-    }
-
-    @Test
-    @Transactional
-    void getAllInstancesByEmailIsNotEqualToSomething() throws Exception {
-        // Initialize the database
-        instanceRepository.saveAndFlush(instance);
-
-        // Get all the instanceList where email not equals to DEFAULT_EMAIL
-        defaultInstanceShouldNotBeFound("email.notEquals=" + DEFAULT_EMAIL);
-
-        // Get all the instanceList where email not equals to UPDATED_EMAIL
-        defaultInstanceShouldBeFound("email.notEquals=" + UPDATED_EMAIL);
-    }
-
-    @Test
-    @Transactional
-    void getAllInstancesByEmailIsInShouldWork() throws Exception {
-        // Initialize the database
-        instanceRepository.saveAndFlush(instance);
-
-        // Get all the instanceList where email in DEFAULT_EMAIL or UPDATED_EMAIL
-        defaultInstanceShouldBeFound("email.in=" + DEFAULT_EMAIL + "," + UPDATED_EMAIL);
-
-        // Get all the instanceList where email equals to UPDATED_EMAIL
-        defaultInstanceShouldNotBeFound("email.in=" + UPDATED_EMAIL);
-    }
-
-    @Test
-    @Transactional
-    void getAllInstancesByEmailIsNullOrNotNull() throws Exception {
-        // Initialize the database
-        instanceRepository.saveAndFlush(instance);
-
-        // Get all the instanceList where email is not null
-        defaultInstanceShouldBeFound("email.specified=true");
-
-        // Get all the instanceList where email is null
-        defaultInstanceShouldNotBeFound("email.specified=false");
-    }
-
-    @Test
-    @Transactional
-    void getAllInstancesByEmailContainsSomething() throws Exception {
-        // Initialize the database
-        instanceRepository.saveAndFlush(instance);
-
-        // Get all the instanceList where email contains DEFAULT_EMAIL
-        defaultInstanceShouldBeFound("email.contains=" + DEFAULT_EMAIL);
-
-        // Get all the instanceList where email contains UPDATED_EMAIL
-        defaultInstanceShouldNotBeFound("email.contains=" + UPDATED_EMAIL);
-    }
-
-    @Test
-    @Transactional
-    void getAllInstancesByEmailNotContainsSomething() throws Exception {
-        // Initialize the database
-        instanceRepository.saveAndFlush(instance);
-
-        // Get all the instanceList where email does not contain DEFAULT_EMAIL
-        defaultInstanceShouldNotBeFound("email.doesNotContain=" + DEFAULT_EMAIL);
-
-        // Get all the instanceList where email does not contain UPDATED_EMAIL
-        defaultInstanceShouldBeFound("email.doesNotContain=" + UPDATED_EMAIL);
-    }
-
     @Test
     @Transactional
     void getAllInstancesByCreatedDateIsEqualToSomething() throws Exception {
@@ -723,7 +634,6 @@ class InstanceResourceIT {
             .andExpect(jsonPath("$.[*].id").value(hasItem(instance.getId().intValue())))
             .andExpect(jsonPath("$.[*].instanceName").value(hasItem(DEFAULT_INSTANCE_NAME)))
             .andExpect(jsonPath("$.[*].instanceIpUrl").value(hasItem(DEFAULT_INSTANCE_IP_URL)))
-            .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL)))
             .andExpect(jsonPath("$.[*].createdDate").value(hasItem(DEFAULT_CREATED_DATE.toString())))
             .andExpect(jsonPath("$.[*].lastModifiedDate").value(hasItem(DEFAULT_LAST_MODIFIED_DATE.toString())))
             .andExpect(jsonPath("$.[*].deletedDate").value(hasItem(DEFAULT_DELETED_DATE.toString())));
@@ -777,7 +687,6 @@ class InstanceResourceIT {
         updatedInstance
             .instanceName(UPDATED_INSTANCE_NAME)
             .instanceIpUrl(UPDATED_INSTANCE_IP_URL)
-            .email(UPDATED_EMAIL)
             .createdDate(UPDATED_CREATED_DATE)
             .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE)
             .deletedDate(UPDATED_DELETED_DATE);
@@ -797,7 +706,6 @@ class InstanceResourceIT {
         Instance testInstance = instanceList.get(instanceList.size() - 1);
         assertThat(testInstance.getInstanceName()).isEqualTo(UPDATED_INSTANCE_NAME);
         assertThat(testInstance.getInstanceIpUrl()).isEqualTo(UPDATED_INSTANCE_IP_URL);
-        assertThat(testInstance.getEmail()).isEqualTo(UPDATED_EMAIL);
         assertThat(testInstance.getCreatedDate()).isEqualTo(UPDATED_CREATED_DATE);
         assertThat(testInstance.getLastModifiedDate()).isEqualTo(UPDATED_LAST_MODIFIED_DATE);
         assertThat(testInstance.getDeletedDate()).isEqualTo(UPDATED_DELETED_DATE);
@@ -880,7 +788,7 @@ class InstanceResourceIT {
         Instance partialUpdatedInstance = new Instance();
         partialUpdatedInstance.setId(instance.getId());
 
-        partialUpdatedInstance.instanceName(UPDATED_INSTANCE_NAME).email(UPDATED_EMAIL).lastModifiedDate(UPDATED_LAST_MODIFIED_DATE);
+        partialUpdatedInstance.instanceName(UPDATED_INSTANCE_NAME).lastModifiedDate(UPDATED_LAST_MODIFIED_DATE);
 
         restInstanceMockMvc
             .perform(
@@ -896,7 +804,6 @@ class InstanceResourceIT {
         Instance testInstance = instanceList.get(instanceList.size() - 1);
         assertThat(testInstance.getInstanceName()).isEqualTo(UPDATED_INSTANCE_NAME);
         assertThat(testInstance.getInstanceIpUrl()).isEqualTo(DEFAULT_INSTANCE_IP_URL);
-        assertThat(testInstance.getEmail()).isEqualTo(UPDATED_EMAIL);
         assertThat(testInstance.getCreatedDate()).isEqualTo(DEFAULT_CREATED_DATE);
         assertThat(testInstance.getLastModifiedDate()).isEqualTo(UPDATED_LAST_MODIFIED_DATE);
         assertThat(testInstance.getDeletedDate()).isEqualTo(DEFAULT_DELETED_DATE);
@@ -917,7 +824,6 @@ class InstanceResourceIT {
         partialUpdatedInstance
             .instanceName(UPDATED_INSTANCE_NAME)
             .instanceIpUrl(UPDATED_INSTANCE_IP_URL)
-            .email(UPDATED_EMAIL)
             .createdDate(UPDATED_CREATED_DATE)
             .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE)
             .deletedDate(UPDATED_DELETED_DATE);
@@ -936,7 +842,6 @@ class InstanceResourceIT {
         Instance testInstance = instanceList.get(instanceList.size() - 1);
         assertThat(testInstance.getInstanceName()).isEqualTo(UPDATED_INSTANCE_NAME);
         assertThat(testInstance.getInstanceIpUrl()).isEqualTo(UPDATED_INSTANCE_IP_URL);
-        assertThat(testInstance.getEmail()).isEqualTo(UPDATED_EMAIL);
         assertThat(testInstance.getCreatedDate()).isEqualTo(UPDATED_CREATED_DATE);
         assertThat(testInstance.getLastModifiedDate()).isEqualTo(UPDATED_LAST_MODIFIED_DATE);
         assertThat(testInstance.getDeletedDate()).isEqualTo(UPDATED_DELETED_DATE);
diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/detail/instance-detail.component.html b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/detail/instance-detail.component.html
index 3f24893..69c5291 100644
--- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/detail/instance-detail.component.html
+++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/detail/instance-detail.component.html
@@ -18,13 +18,13 @@
         <span class="text-primary font-weight-bold" jhiTranslate="iecFrontendApp.iecBackendInstance.instanceIpUrl">Instance Ip Url</span>
         <span>&nbsp;&nbsp;</span>
         <span>{{ instance?.instanceIpUrl }}</span><br>
-        <span class="text-primary font-weight-bold" jhiTranslate="iecFrontendApp.iecBackendInstance.email">Email</span>
+        <span class="text-primary font-weight-bold" jhiTranslate="iecFrontendApp.iecBackendInstance.averageAvailability">Average availability</span>
         <span>&nbsp;&nbsp;</span>
-        <span>{{ instance?.email }}</span><br>
+        <span>{{ instance?.averageAvailability }} %</span><br>
         <span class="text-primary font-weight-bold" jhiTranslate="iecFrontendApp.iecBackendInstance.service">Service</span>
         <span>&nbsp;&nbsp;</span>
         <span>{{ instance?.service?.serviceName }}</span><br><br>
-        <span class="text-warning" jhiTranslate="iecFrontendApp.iecBackendInstance.alertsdetail">Alerts</span>:<br>
+        <span *ngIf="getAlertsCount()>0" class="text-warning" jhiTranslate="iecFrontendApp.iecBackendInstance.alertsdetail">Alerts</span><br *ngIf="getAlertsCount()>0">
         <ng-container *ngIf="getAlertsCount()>0">
           <span *ngFor="let incidence of instance?.incidences; let i = index;">
             &nbsp;&nbsp;&nbsp;<strong>{{incidence?.detail}}</strong> ({{ incidence.createdDate }})<br>
diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/instance.model.ts b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/instance.model.ts
index 3b931d1..61fb892 100644
--- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/instance.model.ts
+++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/instance.model.ts
@@ -8,6 +8,7 @@ export interface IInstance {
   instanceName?: string;
   instanceIpUrl?: string;
   email?: string;
+  averageAvailability?: string;
   createdDate?: dayjs.Dayjs;
   lastModifiedDate?: dayjs.Dayjs | null;
   deletedDate?: dayjs.Dayjs | null;
@@ -22,6 +23,7 @@ export class Instance implements IInstance {
     public instanceName?: string,
     public instanceIpUrl?: string,
     public email?: string,
+    public averageAvailability?: string,
     public createdDate?: dayjs.Dayjs,
     public lastModifiedDate?: dayjs.Dayjs | null,
     public deletedDate?: dayjs.Dayjs | null,
diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/list/instance.component.html b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/list/instance.component.html
index 85350c5..a9a4059 100644
--- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/list/instance.component.html
+++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/list/instance.component.html
@@ -2,7 +2,7 @@
   <nav class="navbar navbar-dark bg-primary">
     <span class="navbar-brand mb-0 h1" jhiTranslate="iecFrontendApp.iecBackendInstance.home.title">Instances</span>
     <div class="form-inline">
-      <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" [(ngModel)]="searchText">
+      <input class="form-control mr-sm-2" type="search" placeholder="Search by Service" aria-label="Search" [(ngModel)]="searchText">
     </div>
     <!-- <form class="form-inline">
       <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
@@ -49,14 +49,11 @@
           <th scope="col" jhiSortBy="instanceName">
             <span jhiTranslate="iecFrontendApp.iecBackendInstance.instanceName">Instance Name</span> <fa-icon icon="sort"></fa-icon>
           </th>
-          <th scope="col">
-            <span jhiTranslate="iecFrontendApp.iecBackendInstance.status">Status</span> 
-          </th>
           <th scope="col" jhiSortBy="instanceIpUrl">
             <span jhiTranslate="iecFrontendApp.iecBackendInstance.instanceIpUrl">Instance Ip Url</span> <fa-icon icon="sort"></fa-icon>
           </th>
-          <th scope="col" jhiSortBy="email">
-            <span jhiTranslate="iecFrontendApp.iecBackendInstance.email">Email</span> <fa-icon icon="sort"></fa-icon>
+          <th scope="col" jhiSortBy="averageAvailability">
+            <span jhiTranslate="iecFrontendApp.iecBackendInstance.averageAvailability">Average availability</span> <fa-icon icon="sort"></fa-icon>
           </th>
           <!-- <th scope="col" jhiSortBy="createdDate">
             <span jhiTranslate="iecFrontendApp.iecBackendInstance.createdDate">Created Date</span> <fa-icon icon="sort"></fa-icon>
@@ -68,12 +65,12 @@
           <th scope="col" jhiSortBy="deletedDate">
             <span jhiTranslate="iecFrontendApp.iecBackendInstance.deletedDate">Deleted Date</span> <fa-icon icon="sort"></fa-icon>
           </th> -->
-          <th scope="col" jhiSortBy="instanceRootService.serviceName">
+          <th scope="col" jhiSortBy="service.serviceName">
             <span jhiTranslate="iecFrontendApp.iecBackendInstance.service">Service</span>
             <fa-icon icon="sort"></fa-icon>
           </th>
           <th scope="col">
-            <span jhiTranslate="iecFrontendApp.iecBackendInstance.alerts">N.Alerts</span>
+            <span jhiTranslate="iecFrontendApp.iecBackendInstance.status">Status</span> 
           </th>
           <th scope="col"></th>
         </tr>
@@ -85,12 +82,8 @@
           </td> -->
           <td>{{ instance.deploymentId }}</td>
           <td>{{ instance.instanceName }}</td>
-          <td>
-            <span class="badge badge-success" jhiTranslate="iecFrontendApp.iecBackendInstance.active" *ngIf="instance.deletedDate == null">Active</span>
-            <span class="badge badge-danger" jhiTranslate="iecFrontendApp.iecBackendInstance.inactive" *ngIf="instance.deletedDate != null">Inactive</span>
-          </td>
           <td>{{ instance.instanceIpUrl }}</td>
-          <td>{{ instance.email }}</td>
+          <td>{{ instance.averageAvailability }} %</td>
           <!-- <td>{{ instance.createdDate | formatMediumDatetime }}</td>
           <td>{{ instance.lastModifiedDate | formatMediumDatetime }}</td>
           <td>{{ instance.deletedDate | formatMediumDatetime }}</td> -->
@@ -100,12 +93,8 @@
             </div>
           </td>
           <td>
-            <div *ngIf="instance.incidences?.length">
-              <a *ngIf="instance.incidences?.length" [routerLink]="['/instance', instance?.id, 'view']">{{ instance.incidences?.length }}</a>
-            </div>
-            <div *ngIf="!instance.incidences?.length">
-              0
-            </div>
+            <span class="badge badge-success" jhiTranslate="iecFrontendApp.iecBackendInstance.active" *ngIf="instance.deletedDate == null">Active</span>
+            <span class="badge badge-danger" jhiTranslate="iecFrontendApp.iecBackendInstance.inactive" *ngIf="instance.deletedDate != null">Inactive</span>
           </td>
           <td class="text-right">
             <div class="btn-group">
@@ -118,7 +107,7 @@
                 <fa-icon icon="eye"></fa-icon>
                 <span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
               </button>
-
+			  <!--
               <button
                 type="submit"
                 [routerLink]="['/instance', instance.id, 'edit']"
@@ -128,7 +117,7 @@
                 <fa-icon icon="pencil-alt"></fa-icon>
                 <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
               </button>
-
+			  -->
               <button type="submit" (click)="delete(instance)" class="btn btn-danger btn-sm" data-cy="entityDeleteButton">
                 <fa-icon icon="times"></fa-icon>
                 <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/pipes/filter.instance.pipe.ts b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/pipes/filter.instance.pipe.ts
index 54e367f..dc850fc 100644
--- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/pipes/filter.instance.pipe.ts
+++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/pipes/filter.instance.pipe.ts
@@ -12,7 +12,7 @@ export class FilterInstancePipe implements PipeTransform {
     }
     searchText = searchText.toLocaleLowerCase();
 
-    return items.filter( it => it.instanceName?.toLocaleLowerCase().includes(searchText));
+    return items.filter( it => it.service?.serviceName?.toLocaleLowerCase().includes(searchText));
   }
 
 }
diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.html b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.html
index d20db88..c774ec6 100644
--- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.html
+++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.html
@@ -117,24 +117,6 @@
             </small>
           </div>
         </div>
-
-        <div class="form-group">
-          <label class="form-control-label" jhiTranslate="iecFrontendApp.iecBackendInstance.email" for="field_email">Email</label>
-          <input type="text" class="form-control" name="email" id="field_email" data-cy="email" formControlName="email" />
-          <div *ngIf="editForm.get('email')!.invalid && (editForm.get('email')!.dirty || editForm.get('email')!.touched)">
-            <small class="form-text text-danger" *ngIf="editForm.get('email')?.errors?.required" jhiTranslate="entity.validation.required">
-              This field is required.
-            </small>
-            <small
-              class="form-text text-danger"
-              *ngIf="editForm.get('email')?.errors?.maxlength"
-              jhiTranslate="entity.validation.maxlength"
-              [translateValues]="{ max: 70 }"
-            >
-              This field cannot be longer than 70 characters.
-            </small>
-          </div>
-        </div>
         <input type="hidden" id="field_createdDate" data-cy="createdDate" name="createdDate" formControlName="createdDate"/>
         <input type="hidden" id="field_lastModifiedDate" data-cy="lastModifiedDate" name="lastModifiedDate" formControlName="lastModifiedDate"/>
         <input type="hidden" id="field_deletedDate" data-cy="deletedDate" name="deletedDate" formControlName="deletedDate"/>
diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.ts b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.ts
index e8c6f5f..cc1aa93 100644
--- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.ts
+++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.ts
@@ -27,7 +27,6 @@ export class InstanceUpdateComponent implements OnInit {
     deploymentId: [null, [Validators.required, Validators.maxLength(70)]],
     instanceName: [null, [Validators.required, Validators.maxLength(70)]],
     instanceIpUrl: [null, [Validators.required, Validators.maxLength(70)]],
-    email: [null, [Validators.required, Validators.maxLength(70)]],
     createdDate: [null, [Validators.required]],
     lastModifiedDate: [],
     deletedDate: [],
@@ -97,7 +96,7 @@ export class InstanceUpdateComponent implements OnInit {
       deploymentId: instance.deploymentId,
       instanceName: instance.instanceName,
       instanceIpUrl: instance.instanceIpUrl,
-      email: instance.email,
+      averageAvailability: '0.0',
       createdDate: instance.createdDate ? instance.createdDate.format(DATE_TIME_FORMAT) : null,
       lastModifiedDate: instance.lastModifiedDate ? instance.lastModifiedDate.format(DATE_TIME_FORMAT) : null,
       deletedDate: instance.deletedDate ? instance.deletedDate.format(DATE_TIME_FORMAT) : null,
@@ -129,7 +128,7 @@ export class InstanceUpdateComponent implements OnInit {
       instanceName: this.editForm.get(['instanceName'])!.value,
       deploymentId: this.editForm.get(['deploymentId'])!.value,
       instanceIpUrl: this.editForm.get(['instanceIpUrl'])!.value,
-      email: this.editForm.get(['email'])!.value,
+      averageAvailability: '0.0',
       createdDate: this.editForm.get(['createdDate'])!.value
         ? dayjs(this.editForm.get(['createdDate'])!.value, DATE_TIME_FORMAT)
         : undefined,
diff --git a/git/iec-frontend/src/main/webapp/i18n/en/iecBackendInstance.json b/git/iec-frontend/src/main/webapp/i18n/en/iecBackendInstance.json
index 4ed3759..c8162e8 100644
--- a/git/iec-frontend/src/main/webapp/i18n/en/iecBackendInstance.json
+++ b/git/iec-frontend/src/main/webapp/i18n/en/iecBackendInstance.json
@@ -19,6 +19,7 @@
       "instanceName": "Name",
       "instanceIpUrl": "Instance Ip Url",
       "email": "Email",
+      "averageAvailability": "Avg. availability",
       "createdDate": "Created Date",
       "lastModifiedDate": "Last Modified Date",
       "deletedDate": "Deleted Date",
diff --git a/git/iec-frontend/src/main/webapp/i18n/es/iecBackendInstance.json b/git/iec-frontend/src/main/webapp/i18n/es/iecBackendInstance.json
index f61b4d0..9ebe5f7 100644
--- a/git/iec-frontend/src/main/webapp/i18n/es/iecBackendInstance.json
+++ b/git/iec-frontend/src/main/webapp/i18n/es/iecBackendInstance.json
@@ -19,6 +19,7 @@
       "instanceName": "Nombre",
       "instanceIpUrl": "Ip Url",
       "email": "Email",
+      "averageAvailability": "Disponiblidad media",
       "createdDate": "Fecha de creación",
       "lastModifiedDate": "Fecha última modificación",
       "deletedDate": "Fecha eliminación",
diff --git a/git/iec-mysql/startupscripts/02_createTables.sql b/git/iec-mysql/startupscripts/02_createTables.sql
index defbd80..601d4a2 100644
--- a/git/iec-mysql/startupscripts/02_createTables.sql
+++ b/git/iec-mysql/startupscripts/02_createTables.sql
@@ -29,7 +29,7 @@ CREATE TABLE `instance` (
   `deployment_id` varchar(70) NOT NULL,
   `instance_name` varchar(70) NOT NULL,
   `instance_ip_url` varchar(70) NOT NULL,
-  `email` varchar(70) NOT NULL,
+  `average_availability` varchar(8) DEFAULT '0.0',
   `created_date` datetime(6) NOT NULL,
   `last_modified_date` datetime(6),
   `deleted_date` datetime(6),
diff --git a/git/iec-mysql/startupscripts/03_initialData.sql b/git/iec-mysql/startupscripts/03_initialData.sql
index f69df04..03b1ff7 100644
--- a/git/iec-mysql/startupscripts/03_initialData.sql
+++ b/git/iec-mysql/startupscripts/03_initialData.sql
@@ -1263,14 +1263,13 @@ INSERT INTO iecbackend.definition (code,value,ismainattribute,ischeckoption,serv
 
 -- 	25: Cost
 
-INSERT INTO instance (`id`,`created_date`,`deleted_date`,`email`,`instance_ip_url`,`deployment_id`,`instance_name`,`last_modified_date`,`service_id`) VALUES
-	 (1, '2021-07-05 00:00:00',NULL,'testmail@tecnalia.com','168.0.1.10','deployment01','instanceTest',NULL,1);
+INSERT INTO `instance` (`id`,`created_date`,`deleted_date`,`instance_ip_url`,`deployment_id`,`instance_name`,`average_availability`,`last_modified_date`,`service_id`) VALUES
+	 (1, '2021-07-05 00:00:00','2021-07-05 00:00:00','168.0.1.10','123e4567-e89b-12d3-a456-426614174000','instanceTest','100.0',NULL,1);	 
 
-INSERT INTO `instance_incidence` (`id`, `detail`, `real_metric_value`, `instance_id`, `created_date`, `last_modified_date`, `deleted_date`) VALUES
+/*INSERT INTO `instance_incidence` (`id`, `detail`, `real_metric_value`, `instance_id`, `created_date`, `last_modified_date`, `deleted_date`) VALUES
 	(1, 'NFR Violation', NULL, 1, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL),
 	(2, 'NFR Violation', NULL, 1, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL),
 	(3, 'Error in Region', NULL, 1, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL);
-	/*,
 	(8, 'NFR Violation', NULL, 6, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL),
 	(18, 'Error in Region', NULL, 3, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL);*/
 
diff --git a/release/docker-compose.yaml b/release/docker-compose.yaml
index 3af1f85..2810505 100644
--- a/release/docker-compose.yaml
+++ b/release/docker-compose.yaml
@@ -7,3 +7,6 @@ services:
 
   iec-frontend:
     image: ${IMAGE_IEC_FRONTEND:?err}
+
+  iec-influxdbclient:
+    image: ${IMAGE_IEC_INFLUXDBCLIENT:?err}
\ No newline at end of file
-- 
GitLab