Skip to content

Commit

Permalink
Merge pull request #322 from mendix/DVAS-1246_telegraf_postgresql
Browse files Browse the repository at this point in the history
DVAS-1246 postgresql input plugin for telegraf
  • Loading branch information
markbastiaans authored Jun 15, 2020
2 parents fa06655 + 0a00d30 commit 19408c3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion buildpack/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def copy_buildpack_resources():
os.path.join(BUILD_DIR, "buildpack"),
)
shutil.copytree(
os.path.join(BUILDPACK_DIR, "lib"), os.path.join(BUILD_DIR, "lib"),
os.path.join(BUILDPACK_DIR, "lib"), os.path.join(BUILD_DIR, "lib")
)
shutil.copy(
os.path.join(BUILDPACK_DIR, "bin", "mendix-logfilter"),
Expand Down
2 changes: 1 addition & 1 deletion buildpack/datadog.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def _set_up_environment():
os.environ["DD_SERVICE_NAME"] = _get_service()
os.environ["DD_JMXFETCH_ENABLED"] = "false"
os.environ["DD_SERVICE_MAPPING"] = "{}:{}.db".format(
database.get_config()["DatabaseType"].lower(), _get_service(),
database.get_config()["DatabaseType"].lower(), _get_service()
)

e = dict(os.environ.copy())
Expand Down
2 changes: 1 addition & 1 deletion buildpack/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def compile(buildpack_path, cache_path, local_path, java_version):
logging.debug("begin download and install java")
util.mkdir_p(os.path.join(local_path, "bin"))
jvm_location = ensure_and_get_jvm(
java_version, cache_path, local_path, package="jre",
java_version, cache_path, local_path, package="jre"
)
# create a symlink in .local/bin/java
os.symlink(
Expand Down
2 changes: 1 addition & 1 deletion buildpack/mxbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def start_mxbuild_server(local_path, runtime_version, java_version):
path = os.path.join(local_path, "mxbuild")

jvm_location = java.ensure_and_get_jvm(
java_version, cache, local_path, package="jdk",
java_version, cache, local_path, package="jdk"
)
subprocess.Popen(
[
Expand Down
2 changes: 1 addition & 1 deletion buildpack/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from buildpack.runtime_components import security
from lib.m2ee import M2EE as m2ee_class

BUILDPACK_VERSION = "4.5.6"
BUILDPACK_VERSION = "4.5.7"

m2ee = None
app_is_restarting = False
Expand Down
20 changes: 20 additions & 0 deletions buildpack/telegraf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@
import subprocess

from buildpack import datadog, util
from buildpack.runtime_components import database


def _get_appmetrics_target():
return os.getenv("APPMETRICS_TARGET")


def include_db_metrics():
return os.getenv("APPMETRICS_INCLUDE_DB", "true").lower() == "true"


def is_enabled():
return _get_appmetrics_target() is not None

Expand Down Expand Up @@ -183,6 +188,21 @@ def update_config(m2ee, app_name):
},
)

# Configure postgreSQL input plugin
if include_db_metrics():
db_config = database.get_config()
_write_config(
"[[inputs.postgresql]]",
{
"address": "postgres://{}:{}@{}/{}".format(
db_config["DatabaseUserName"],
db_config["DatabasePassword"],
db_config["DatabaseHost"],
db_config["DatabaseName"],
)
},
)

# Forward metrics also to DataDog when enabled
if datadog.is_enabled():
_write_config("[[outputs.datadog]]", {"apikey": datadog.get_api_key()})
Expand Down

0 comments on commit 19408c3

Please sign in to comment.