Here were going to take 3 laps of your time and demonstrate how I wired up my Racing SIM to IRIS for "As Real Time as It Gets" Metrics reporting. I missed the window for the contest, which happens quite often, but I still ended up 3rd I think in the demo race in the video below.
Technical Salad
Below are the technical ingredients for this demonstration for a salad you can post on Instragram.
Gluing it all together, we have a rolling SIM emitting, scraping and serving up iRacing metrics suitable for real time display.
As Real Time as It Gets
The excuse I made for myself to derive some real value of sorts out of this was I have always wanted to be as agressive as possible with data reporting from the source to the exporter, clear through the Prometheus Scrape and the eventual dashboard. The python sdk is wicked fast, as it reads from a memory mapped file while in session, and the other components can be configured to be agressive, but just are not by default and took some edits and daemon reloads.
In order to make this work, I found the following tweaks for necessary:
grafani.ini
min_refresh_interval = 1s
prometheus.yml 1s scrape
- job_name: 'iracing' # Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 1s
scrape_timeout: 1s # metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['192.168.1.193:52773']
metrics_path: '/api/monitor/metrics'
Dashboard
Newly added refresh rate can be added, and "Refresh Live Dashboards" should be enabled.
At rest it doesnt look like much, as its designed to be real time, but a screenshot is in order to see the 5 panels.
I am trying to replicate a REST call that I am able to make via a Postman call within a EnsLib.REST.GenericOperation.
It's been a while since I have messed around with trying to make external REST calls. When I execute my REST call, tSC is coming back with an error and I am trying to pinpoint why. I tried turning on ISCLOG = 5 but when calling the REST Operation from the Testing tool it is not logging anything to the ISC log.
How do we see the RAW request being sent out to verify that my request is formatted properly? tSC is coming back with an error as the message displayed in the error is "Error in sending request to server"
Method PostSearchPerson(pRequest As COM.REST.Msg.Request.PostSearchPerson.PostSearchPersonRequest, Output pResponse As COM.REST.Msg.Response.PostSearchPerson.PostSearchPersonResponse) As%Status
{
#dim tSC As%Status = $$$OKset tHTTPRequest = ##class(%Net.HttpRequest).%New()
set tHTTPRequest.SSLConfiguration = ..Adapter.SSLConfig
set tHTTPRequest.Https = 1set tHTTPRequest.WriteRawMode = 1set tHTTPRequest.Port = ..Adapter.HTTPPort
do tHTTPRequest.SetHeader("Host", ..Adapter.HTTPServer)
Do tHTTPRequest.SetHeader("Accept-Encoding","application/json")
Do tHTTPRequest.SetHeader("Content-Type","application/json")
Do tHTTPRequest.SetHeader("api-key",..ApiKey)
do tHTTPRequest.EntityBody.Write()
do tHTTPRequest.OutputHeaders()
set tRequest = ##class(%DynamicObject).%New()
set tRequest.searchString = pRequest.searchString
set tPayload = tRequest.%ToJSON()
set tURL=..Adapter.URL_"/persons/search"set tSC = tHTTPRequest.EntityBody.Write(tPayload)
set tHTTPResponse = ##class(%Net.HttpResponse).%New()
set tSC = ..Adapter.SendFormDataArray(.tHTTPResponse, "POST", tHTTPRequest, tURL, tPayload)
if$$$ISERR(tSC) {
set tSC = $$$ERROR($$$GeneralError, "Error in sending request to the server")
quit tSC
}
set responseData = {}.%FromJSON(tHTTPResponse.Data)
set pResponse = ##class(COM.REST.Msg.Response.PostSearchPerson.PostSearchPersonResponse).%New()
set tSC = pResponse.%JSONImport(responseData)
quit tSC
}
I’m new to this community and could really use some help with creating a production in InterSystems IRIS for Health Community 2024.3. I have deployed my instance using Docker. Here’s what I’m trying to do:
Input: I have an HL7 file that is processed by the standard EnsLib.HL7.Service.FileService.
DTL Transformation: I’ve created a DTL to transform the HL7 content into a custom class like this:
This setup allows me to create my DTL with Demo.MyApp.Messages.JSONEvent5 as the target class.
However, I’m stuck after this step. I need to take the result of the DTL transformation and export it into a .txt file using a Business Operation, which will export the file in a specified folder.
I've read a lot about the JSON Adaptor, but I’m having trouble applying it in my case. I tried to create a custom Business Process that applies the DTL and then converts the result to a string using %JSONExportToString, but it’s not working as expected.
Could anyone share an example or guide me on how to properly set up this production ? I’d really appreciate any insights or recommendations.
It helps to remove special characters, such as non-utf-8 characters either control characters or unicode characters from text that is not printable or can't be parsed by downstream systems.
There is also $C(32) in this condition; sometimes NBSP appears in the text and it will not be recognized by TIE, but downstream it displays as "?".
In order to avoid the NBSP issue, the if condition is replaced with a space in order to prevent the error.
Unicode characters only Remove:
Class Test.Utility.FunctionSet Extends %RegisteredObject { ClassMethod ConvertTextToAscii(text As %String) As %String { Set (str,char) = ""
FOR i=1:1:$LENGTH(text) { Set char = $E(text, i) Set ascii = $ASCII(char)
IF ascii'<33,ascii>126 { ///ascii 32 included to avoid NBSP W "Removing"_" ASCII code of "_ascii_" character is: "_char,! Set char = " " } Set str = str_char } Set str = $Replace(str," ","")
QUIT str }
}
Output:
W ##class(Test.Utility.FunctionSet).ConvertTextToAscii( "This”text is€example for × special € unicode — characters.•!!£;: with in the text? @downstream systems <removing (-)them> from {+adding some $%^'#utf-8'-_¦¬test@hotmail.com!"),! Removing ASCII code of 8221 character is: ” Removing ASCII code of 8364 character is: € Removing ASCII code of 160 character is: Removing ASCII code of 215 character is: × Removing ASCII code of 8364 character is: € Removing ASCII code of 8212 character is: — Removing ASCII code of 8226 character is: • Removing ASCII code of 163 character is: £ Removing ASCII code of 166 character is: ¦ Removing ASCII code of 172 character is: ¬ This text is example for special unicode characters. !! ;: with in the text? @downstream systems <removing (-)them> from {+adding some $%^'#utf-8'-_test@hotmail.com!
Including Control characters as well as Unicode characters to strip from Text:
ClassMethod ConvertTextToAscii(text As %String = "Testing unicode”charactersand€control characters×removing unicode—andcharacters.•and!£;:?$%^'#utf-8'-_¦¬test@hotmail.com!") As %String { Set (str,char) = "" FOR i=1:1:$LENGTH(text) { Set char = $E(text, i) Set ascii = $ASCII(char) //W "Ascii of char "_char_" is"_ascii,! IF ascii<33!(ascii>126) { ///ascii 32 included to avoid NBSP W "Removing"_" ASCII code of "_ascii_" character is: "_char,! Set char = " " } Set str = str_char } Set str = $Replace(str," ","")