検索

質問
· 2023年11月28日

Converting API Monitor Metrics to JSON: Addressing Carriage Return and Line Feed Challenges in InterSystems IRIS Integration

Hello,

First of all thanks for your help, time, and answers.

We would like to know what are we doing wrong and how could we improve it and fix it.

We need to convert the Api Monitor Metrics which are a String with this format:

iris_cache_efficiency 13449.122
iris_cpu_pct{id="CSPDMN"} 0
iris_cpu_pct{id="ECPWorker"} 0

[...]

iris_wdwij_time 11
iris_wd_write_time 8
iris_wij_writes_per_sec 0

 

To JSON.

We would expect them to look like a normal JSON as follows:

{
"iris_cache_efficiency": "13449.122",
"iris_cpu_pct{id='CSPDMN'}": "0",

[...]
"iris_wij_writes_per_sec": 0
}

 

We have currently developed a REST Operation which gets them and tries to convert them from the raw string to a JSON format:

Class Operaciones.REST.MetricasApiMonitorv01r00 Extends EnsLib.REST.Operation
{

Parameter INVOCATION = "Queue";
Method obtenerMetricas(pRequest As Mensajes.Request.Metricas.ObtenerRequest, pResponse As Mensajes.Response.Metricas.ObtenerResponse) As %Library.Status
{
	//Creamos Request y Response HTTP
	Set httpRequest=##class(%Net.HttpRequest).%New()
	set tResponse  = ##class(%Net.HttpResponse).%New()
	set pResponse = ##class(Mensajes.Response.Metricas.ObtenerResponse).%New()

	// Se obtiene la URL de la configurada en la Producción
	;set URL		= ..Adapter.URL
	set URL = "http://[Ip]]:[Port]]/api/monitor/metrics"
	$$$LOGINFO("URL: "_URL)

	//Enviamos al sistema externo
	set tSC=httpRequest.Get(URL,0) 
	$$$LOGALERT("tSC: "_$System.Status.GetErrorText(tSC))

	//Lanzamos excepcion si hubo error
	if $$$ISERR(tSC){
			$$$ThrowOnError(tSC)
	}
	
	set tResponse = httpRequest.HttpResponse
	
	set linea = ""
	//Leemos respuesta
	while (tResponse.Data.AtEnd = 0) {
		set linea = linea_tResponse.Data.Read()
	}
	$$$LOGINFO("linea: "_linea)
	
	set lineaSinComillasDobles = $REPLACE(linea,"""","'")
	$$$LOGINFO("lineaSinComillasDobles: "_lineaSinComillasDobles)
	
	set lineaConDobleComillaDosPuntosEnMedio = $REPLACE(lineaSinComillasDobles," ",""": ")
	$$$LOGINFO("lineaConDobleComillaDosPuntosEnMedio: "_lineaConDobleComillaDosPuntosEnMedio)
	
	$$$LOGALERT("$FIND(lineaConDobleComillaDosPuntosEnMedio,$CHAR(13,10)): "_$FIND(lineaConDobleComillaDosPuntosEnMedio,$CHAR(13,10)))
	
	set lineaConComasAlFinal = $REPLACE(lineaConDobleComillaDosPuntosEnMedio, $CHAR(13,10),",")
	$$$LOGINFO("lineaConComasAlFinal: "_lineaConComasAlFinal)
	
	set pResponse.resultado = "{"_lineaConComasAlFinal_"}"
	Quit pResponse
}

XData MessageMap
{
<MapItems>
  <MapItem MessageType="Mensajes.Request.Metricas.ObtenerRequest">
    <Method>obtenerMetricas</Method>
  </MapItem>  
  </MapItems>
}

}

 

However we do not know hot to replace Carrie Return and Line Feed with a comma and a double quote.

We have tried:

	$$$LOGALERT("$FIND(lineaConDobleComillaDosPuntosEnMedio,$CHAR(13,10)): "_$FIND(lineaConDobleComillaDosPuntosEnMedio,$CHAR(13,10)))
	
	set lineaConComasAlFinal = $REPLACE(lineaConDobleComillaDosPuntosEnMedio, $CHAR(13,10),",")
	$$$LOGINFO("lineaConComasAlFinal: "_lineaConComasAlFinal)

 

However the $FIND outputs "0", so we think it means that is does not find a Carrie Return and Line Feed at all.

Even more the $REPLACE outputs no effect.

The response currently shows:

{iris_cache_efficiency": 13492.868
iris_cpu_pct{id='CSPDMN'}": 0
iris_cpu_pct{id='CSPSRV'}": 1

[...]

iris_wdwij_time": 24
iris_wd_write_time": 23
iris_wij_writes_per_sec": 0}

 

Being outputted at the visual trace:

 

How could we convert the API Monitor Metrics to JSON in an effective way?

What have we done wrong?

How could we improve and fix our code to accomplish this need?

 

In addition we have also read:

https://community.intersystems.com/post/replace-carriage-return-linefeed...

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

 

Thanks for your help

4 Comments
ディスカッション (4)1
続けるにはログインするか新規登録を行ってください
質問
· 2023年11月27日

Using the Message viewer to find specific value in trace set in BPL

I have a BPL that I set up a trace to check if the ProcRsltStatus Order is 1. Because the trace is set up in the BPL, I am having issues in searching traces that have the 1 in the message viewer. Any idea how I can limit my search to only the ones with ProcRsltStatus Order::1? Thanks in advance.  

6 Comments
ディスカッション (6)2
続けるにはログインするか新規登録を行ってください
記事
· 2023年11月23日 3m read

IRISHealth在DBServer和ECPApp之间启用SSL/TLS安全双向认证加密通信

        IRISHealth以其完备且系统化的安全特性在医疗行业的数据库中独树一帜,这些特性包括安全认证、安全授权、安全审计、数据加密以及安全配置。其中数据传输无疑是其中最重要的一环。为此,IRISHealth采用了SSL/TLS技术来对传输的数据进行加密,有效保障了从IRIS数据平台的超级服务数据传输、Telnet服务数据传输、java/.net/Studio客户端的访问数据传输、MIRROR与DB的数据传输,到DBServer和ECPApp之间的数据传输的安全性。


        本文是在两个IRISHealth2021实例之间进行ECP服务通信的示例,一个作为DBServer,一个作为ECPApp,两个实例之间通过使用SSL/TLS的ECP协议进行TCP的加密传输通信。

1.IRIS的DB和ECP环境:

DBServer 

ECPApp

10.1.30.231  10.1.30.232

 

2. CA证书的环境:

CA根服务器 

DBServer

ECPApp

10.1.30.231 10.1.30.231 10.1.30.232
CARoot.cer DataSever.cer ECPApp.cer
CARoot.key DataSever.key ECPApp.key
私钥密码:123 data123 ecp123
  • 在 System > Security Management > Public Key Infrastructure - (security settings) 下进行根证书服务器搭建,审批DBServer和ECPApp申请的证书。

 

3. DBServer配置:

3.1 开启Superserver SSL/TLS support功能 

  • System > Security Management > System-wide Security Parameters - (security settings) Superserver SSL/TLS support勾选Enable

3.2 开启The ECP service is Enabled

  • System > Configuration > ECP Settings - (configuration settings)

  • This System as an ECP Data Server

  • ECP SSL/TLS support勾选Required-->只能通过SSL/TLS方式通信
  • ECP SSL/TLS support勾选Disabled-->不能通过SSL/TLS方式通信
  • ECP SSL/TLS support勾选Enabled-->既能通过SSL/TLS方式通信,也可以不通过

 

3.3 创建 ECP Data Server的SSL/TLS配置名称为%ECPServer

  • 通过System > Configuration > ECP Settings - (configuration settings) 下的Edit SSL/TLS ‘%ECPServer’的链接进行配置
  •    
  • 在 System > Security Management > SSL/TLS Configurations > Edit SSL/TLS Configuration - (security settings)路径下也可以查看,内容相同
  •          

4. ECPApp配置:

4.1 创建ECP Application Server的SSL/TSL配置名称为%ECPClient

  • 通过System > Configuration > ECP Settings - (configuration settings) 下的Edit SSL/TLS ‘%ECPClient’的链接进行配置

  •     

  • 在 System > Security Management > SSL/TLS Configurations > Edit SSL/TLS Configuration - (security settings)路径下也可以查看,内容相同。

4.2 创建ECP Data Connection

  • System > Configuration > ECP Settings > ECP Data Servers---点击Add Server

  •  

 5.在DataServer上对ECP connection进行授权

  • System > Configuration > ECP Settings > ECP Application Servers

  • 授权后,DBServer和ECPApp之间的SSL/TLS双向认证加密通信配置完成。  
5 Comments
ディスカッション (5)8
続けるにはログインするか新規登録を行ってください
質問
· 2023年11月22日

Handling CDATA in XML Responses: Removing <![CDATA[]]> in String Properties for Clean Integration

Hello,

First of all thanks for your help.

We have the following scenario: some responses include special characters as ">" and "<" which are being put inside a property defined as:

Property PACPROBLEMAS As %String(MAXLEN = "", XMLNAME = "PAC_PROBLEMAS");

 

So then, when we observe the LOG SOAP it shows that the Target System replies to the ESB as follows:

➡️ <PAC_PROBLEMAS>46807#278.01#OBESIDAD INFANTIL GRAVE     ( Z-SCORE IMC &gt;2,70 ) #19/09/2019##N#</PAC_PROBLEMAS>

 

However when we observe the Visual Trace, the message being replied from the Operation to the Process has a CDATA section as you could see:

➡️ <s01:PAC_PROBLEMAS><![CDATA[46807#278.01#OBESIDAD INFANTIL GRAVE     ( Z-SCORE IMC >2,70 )#19/09/2019##N#S]]>
</s01:PAC_PROBLEMAS>

 

We do need to find a way to remove the <![CDATA[]]> because the system which receives the response needs it to be raw without any CDATA.

We do have checked that it only shows this behaviour with special character which conflict with the ones that are used in XML as ">" and "<".

 

We do have investigated the following options:

📌 Declare CONTENT = "ESCAPE"

Property PACPROBLEMAS As %String(CONTENT = "ESCAPE", MAXLEN = "", XMLNAME = "PAC_PROBLEMAS");

It stills being the same

 

📌 Declare ESCAPE = "HTML"

Property PACPROBLEMAS As %String(ESCAPE = "HTML", MAXLEN = "", XMLNAME = "PAC_PROBLEMAS");
It behaves similarly

 

📌 Declare ESCAPE = "XML"

Property PACPROBLEMAS As %String(ESCAPE = "XML", MAXLEN = "", XMLNAME = "PAC_PROBLEMAS");

It just shows the same behaviour

 

We have also read:

https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.D...

https://community.intersystems.com/post/convert-string-property-cdata-an...

https://community.intersystems.com/post/there-way-automatically-remove-s...

 

However the previous post does not cover this topic.

Could you help us please?

🔎 How could we remove <![CDATA[]]> in a String property? 📍  

Could we declare there any properties, parameters, configurations or options to remove it?

What is the most recommended and clean way to achieve this?

 

Thanks for your help, time, answers, teaching and support.

5 Comments
ディスカッション (5)2
続けるにはログインするか新規登録を行ってください
質問
· 2023年11月21日

Configure SQL.OutboundAdapter to SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

Hi,

DBA has asked me to configure a working Business Operation using a SQL.OutboundAdapter (connecting to external MSSQL server) to run as TRANSACTION ISOLATION LEVEL READ UNCOMMITTED.

I would like help with an example of how this is done.

Thanks

4 Comments
ディスカッション (4)3
続けるにはログインするか新規登録を行ってください