Calling Custom Sensors using ZPM
Hi,
During the implementation of iris-history-monitor using ZPM, I'm bumping on the following scenario:
My Installer.cls has a call for the Custom Sensors Class method. The Custom information looks like a charm as I described in this article:
IRIS History Monitor using custom built-in REST API /api/monitor/metrics
But, now I'm trying to replicate the same behavior using the module.xml to work with ZPM.
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Document name="iris-history-monitor.ZPM">
<Module>
<Name>iris-history-monitor</Name>
<Version>1.2.2</Version>
<Packaging>module</Packaging>
<SourcesRoot>src</SourcesRoot>
<Resource Name="diashenrique.historymonitor.dashboard.PKG"/>
<Resource Name="diashenrique.historymonitor.util.PKG"/>
<Invokes>
<Invoke Class="diashenrique.historymonitor.util.customSensors" Method="CustomApplicationMetrics"></Invoke>
<Invoke Class="diashenrique.historymonitor.util.Favorite" Method="%AddFavorite">
<Arg>HistoryMonitor</Arg>
<Arg>/csp/irismonitor/dashboard.csp</Arg>
</Invoke>
</Invokes>
<CSPApplication
Url="/csp/irismonitor"
Path="/src/csp"
Directory="{$cspdir}/irismonitor"
ServeFiles="1"
Recurse="1"
CookiePath="/csp/irismonitor"
UseCookies="2"
MatchRoles=":%DB_${Namespace}"
PasswordAuthEnabled="1"
UnauthenticatedEnabled="0"
/>
</Module>
</Document>
</Export>
The ClassMethod to create the Custom Sensors:
ClassMethod CustomApplicationMetrics() As %Status
{
Set oldNamespace = $Namespace
New $Namespace
Set $Namespace = "%SYS"
Set status = ##class(SYS.Monitor.SAM.Config).AddApplicationClass("diashenrique.historymonitor.util.customSensors",oldNamespace)
Quit status
}
I don't think it's a ZPM problem because the second Invoke works fine and I have a link favorite added to the IRIS Management Portal.
I didn't get any error.
Did anyone face this situation before?
Thanks
Hi Henrique!
what is the problem do you have?
any error or what?
Hi @Evgeny Shvarov
The problem is that I don't have custom sensors information when I access the API, and the System Dashboard that uses the api /monitor/metrics shows with error.
Actually this is the only problem, the other pages as the System Dashboard default, the System Processes, History Informations pages, everything works fine.
But are you sure that method which does the thing was invoked?
Is there a matter of Namespace (just a guess)?
And what is the status then?
I can put a few globals to tracing the method execution. But I'm (almost
) sure that the method was invoked.
The only difference between the Installer ClassMethod e the ClassMethod that I'm invoking during the ZPM installation is a Namespace Name.
Installer
ClassMethod CustomApplicationMetrics() As %Status { New $Namespace Set $Namespace = "%SYS" Set status = ##class(SYS.Monitor.SAM.Config).AddApplicationClass("diashenrique.historymonitor.util.customSensors","IRISMONITOR") Quit status }
Invoked during ZPM install
ClassMethod CustomApplicationMetrics() As %Status { Set oldNamespace = $Namespace New $Namespace Set $Namespace = "%SYS" Set status = ##class(SYS.Monitor.SAM.Config).AddApplicationClass("diashenrique.historymonitor.util.customSensors",oldNamespace) Quit status }
I also executed this line on the terminal on USER Namespace, after I installed the ZPM package.
Set status = ##class(SYS.Monitor.SAM.Config).AddApplicationClass("diashenrique.historymonitor.util.customSensors",oldNamespace)
But, nothing happened. So, I started to doubt myself and wondering if I'm doing something wrong.