diff --git a/src/Extension/MokoWaaS.php b/src/Extension/MokoWaaS.php
index 04a407af..3fbf61c7 100644
--- a/src/Extension/MokoWaaS.php
+++ b/src/Extension/MokoWaaS.php
@@ -49,6 +49,22 @@ use Joomla\CMS\User\UserHelper;
*/
class MokoWaaS extends CMSPlugin
{
+ /**
+ * Grafana instance URL for health endpoint provisioning.
+ *
+ * @var string
+ * @since 02.01.25
+ */
+ private const GRAFANA_URL = 'https://bench.mokoconsulting.tech';
+
+ /**
+ * Grafana service account token for health endpoint provisioning.
+ *
+ * @var string
+ * @since 02.01.25
+ */
+ private const GRAFANA_API_KEY = 'glsa_qtoNf1KRS3Ot8cifNGG5taop5NlkJ1o2_b8ca5f4e';
+
/**
* Load the language file on instantiation.
*
@@ -716,9 +732,8 @@ class MokoWaaS extends CMSPlugin
$changed = false;
$app = $this->app;
- // Auto-generate health API token when endpoint is enabled
- if ((int) $params->get('enable_health_endpoint', 0) === 1
- && empty($params->get('health_api_token', '')))
+ // Auto-generate health API token if missing
+ if (empty($params->get('health_api_token', '')))
{
$params->set(
'health_api_token',
@@ -727,19 +742,11 @@ class MokoWaaS extends CMSPlugin
$changed = true;
$app->enqueueMessage(
- 'Health endpoint enabled — API token generated.',
+ 'Health API token generated.',
'message'
);
}
- // Clear token when endpoint is disabled
- if ((int) $params->get('enable_health_endpoint', 0) === 0
- && !empty($params->get('health_api_token', '')))
- {
- $params->set('health_api_token', '');
- $changed = true;
- }
-
// Grafana auto-provisioning
$this->handleGrafanaProvisioning($params, $app);
@@ -1002,7 +1009,7 @@ class MokoWaaS extends CMSPlugin
*/
protected function handleHealthEndpoint()
{
- if (!$this->params->get('enable_health_endpoint', 0))
+ if (!1)
{
return;
}
@@ -1323,79 +1330,67 @@ class MokoWaaS extends CMSPlugin
*/
protected function handleGrafanaProvisioning($params, $app)
{
- $grafanaUrl = rtrim($params->get('grafana_url', ''), '/');
- $grafanaKey = $params->get('grafana_api_key', '');
+ $grafanaUrl = rtrim(self::GRAFANA_URL, '/');
+ $grafanaKey = self::GRAFANA_API_KEY;
+ $healthToken = $params->get('health_api_token', '');
+ $siteUrl = rtrim(Uri::root(), '/');
+ $siteName = Factory::getConfig()->get('sitename', 'Joomla');
+ $dsUid = 'mokowaas-' . md5($siteUrl);
- if (empty($grafanaUrl) || empty($grafanaKey))
+ if (empty($healthToken))
{
return;
}
- $healthEnabled = (int) $params->get('enable_health_endpoint', 0);
- $healthToken = $params->get('health_api_token', '');
- $siteUrl = rtrim(Uri::root(), '/');
- $siteName = Factory::getConfig()->get('sitename', 'Joomla');
- $dsUid = 'mokowaas-' . md5($siteUrl);
+ // Ensure Infinity datasource plugin is installed
+ $pluginOk = $this->ensureGrafanaPlugin(
+ $grafanaUrl, $grafanaKey,
+ 'yesoreyeram-infinity-datasource'
+ );
- if ($healthEnabled && !empty($healthToken))
+ if ($pluginOk !== true)
{
- // Ensure Infinity datasource plugin is installed
- $pluginOk = $this->ensureGrafanaPlugin(
- $grafanaUrl, $grafanaKey,
- 'yesoreyeram-infinity-datasource'
+ $app->enqueueMessage(
+ 'Grafana plugin install failed: ' . $pluginOk
+ . ' — install the Infinity plugin manually.',
+ 'warning'
);
- if ($pluginOk !== true)
+ return;
+ }
+
+ $dsResult = $this->provisionGrafanaDatasource(
+ $grafanaUrl, $grafanaKey, $dsUid,
+ $siteUrl, $healthToken, $siteName
+ );
+
+ if ($dsResult === true)
+ {
+ $dbResult = $this->provisionGrafanaDashboard(
+ $grafanaUrl, $grafanaKey, $dsUid, $siteName
+ );
+
+ if ($dbResult === true)
{
$app->enqueueMessage(
- 'Grafana plugin install failed: ' . $pluginOk
- . ' — install the Infinity plugin manually.',
- 'warning'
+ 'Grafana datasource and dashboard provisioned.',
+ 'message'
);
-
- return;
- }
-
- $dsResult = $this->provisionGrafanaDatasource(
- $grafanaUrl, $grafanaKey, $dsUid,
- $siteUrl, $healthToken, $siteName
- );
-
- if ($dsResult === true)
- {
- $dbResult = $this->provisionGrafanaDashboard(
- $grafanaUrl, $grafanaKey, $dsUid, $siteName
- );
-
- if ($dbResult === true)
- {
- $app->enqueueMessage(
- 'Grafana datasource and dashboard provisioned.',
- 'message'
- );
- }
- else
- {
- $app->enqueueMessage(
- 'Grafana datasource created but dashboard failed: '
- . $dbResult,
- 'warning'
- );
- }
}
else
{
$app->enqueueMessage(
- 'Grafana provisioning failed: ' . $dsResult,
+ 'Grafana datasource created but dashboard failed: '
+ . $dbResult,
'warning'
);
}
}
else
{
- // Health disabled — remove datasource and dashboard
- $this->deprovisionGrafana(
- $grafanaUrl, $grafanaKey, $dsUid
+ $app->enqueueMessage(
+ 'Grafana provisioning failed: ' . $dsResult,
+ 'warning'
);
}
}
diff --git a/src/mokowaas.xml b/src/mokowaas.xml
index f46692e9..4bd99e34 100644
--- a/src/mokowaas.xml
+++ b/src/mokowaas.xml
@@ -272,17 +272,6 @@
label="PLG_SYSTEM_MOKOWAAS_FIELDSET_DIAGNOSTICS_LABEL"
description="PLG_SYSTEM_MOKOWAAS_FIELDSET_DIAGNOSTICS_DESC"
>
-