New post

Find

Article
· Mar 22, 2021 2m read

Monitor Docker containers usando SAM and cAdvisor

cAdvisor (abreviação de contêiner Advisor) analisa e expõe o uso de recursos e dados de desempenho de contêineres em execução. O cAdvisor expõe as métricas do Prometheus fora da caixa.

https://prometheus.io/docs/guides/cadvisor/

O Prometheus está integrado no SAM. Isso torna possível aproveitar as métricas do cAdvisor e expô-las por meio do Prometheus e do Grafana.

Como o cAdvisor escuta na porta 8080, que está em conflito com a porta Nginx, você pode escolher alterar a porta Nginx para acomodar isso.

Etapas de configuração:

1. Altere a porta nginx.

modificar nghix.conf:

    servidor {

        escute 9991;

Isso permite que você acesse a IU do cAdvisor via http: // server: 8080 /, que vem com muitos painéis de exemplo.

2. Configure docker-compose para adicionar o contêiner cAdvisor:

em docker-compose.yml, adicione o seguinte:

  cadvisor:

    imagem: google / cadvisor: mais recente

    portas:

      - 8080: 8080

    volumes:

      - /: / rootfs: ro

      - / var / run: / var / run: rw

      - / sys: / sys: ro

      - / var / lib / docker /: / var / lib / docker: ro

 

3. Configure o prometheus para adicionar trabalho ao cAdvisor:

modifique isc_prometheus.yml e adicione:

- job_name: cadvisor

  scrape_interval: 5s

  static_configs:

  - rótulos:

      cluster: "1"

      grupo: nó

    alvos:

    - cadvisor: 8080

Você Terminou! Para ter certeza de que o prometheus está puxando as métricas do cAdvisor, vá para prometheus UI http: // server: 9090 /, em Status-> Targets, você deve ver o endpoint e o status do cAdvisor.

você pode baixar alguns excelentes painéis pré-construídos com métricas cAdvisor, basta adicionar o parâmetro cluster em cada consulta.

 

 

Discussion (0)0
Log in or sign up to continue
Discussion (5)1
Log in or sign up to continue
Article
· Mar 18, 2021 3m read

Aproveitando ao máximo $ Query

Encontrei um caso de uso interessante do ObjectScript hoje com uma solução geral que gostaria de compartilhar.

Caso de uso:  

Eu tenho uma matriz JSON (especificamente, no meu caso, uma matriz de problemas de Jira) que desejo agregar em alguns campos - digamos, categoria, prioridade e tipo de problema. Em seguida, desejo nivelar os agregados em uma lista simples com o total de cada um dos grupos. Claro, para a agregação, faz sentido usar uma matriz local na forma:

agg(category, priority, type) = total

De modo que, para cada registro na matriz de entrada, posso apenas:

Do $increment(agg(category, priority, type))

Mas depois de fazer a agregação, quero colocá-la em uma forma mais fácil de iterar, como uma matriz subscrita por inteiro:

summary = n
summary(1) = $listbuild(total1, category1, priority1, type1)
...
summary(n) = $listbuild(totalN, categoryN, priorityN, typeN)

Solução Básica:

A abordagem simples é ter três loops For aninhados com $ Order - por exemplo:

Set category = ""
For {
    Set category = $Order(agg(category))
    Quit:category=""
    
    Set priority = ""
    For {
        Set priority = $Order(agg(category,priority))
        Quit:priority=""
        
        Set type = ""
        For {
            Set type = $Order(agg(category,priority,type),1,total)
            Quit:type=""
            
            Set summary($i(summary)) = $listbuild(total,category,priority,type)
        }
    }

Foi com isso que comecei, mas é muito código, e se eu tivesse mais dimensões para agregar sobre ele ficaria complicado rapidamente. Isso me fez pensar - existe uma solução geral para realizar a mesma coisa? Acontece que existe!

Melhor solução com $ Query:

Decidi que usar $ query ajudaria. Observe que esta solução assume uma profundidade uniforme de subscritos / valores em todo o array local; coisas estranhas aconteceriam se essa suposição fosse violada.  

 

ClassMethod Flatten(ByRef deep, Output flat) [ PublicList = deep ]
{
    Set reference = "deep"
    For {
        Set reference = $query(@reference)
        Quit:reference=""
        Set value = $listbuild(@reference)
        For i=1:1:$qlength(reference) {
            Set value = value_$listbuild($qsubscript(reference,i))
        }
        Set flat($i(flat)) = value
    }
}

Portanto, o snippet acima é substituído por:

Do ..Flatten(.agg,.summary)

Algumas coisas a serem observadas sobre esta solução:

deep precisa estar na PublicList para que $ query possa operar nela em cada iteração, a referência é alterada para fazer referência ao próximo conjunto de subscritos em profundidade que tem um valor - por exemplo, o valor pode ser: deep ("foo", "bar") $ qlength retorna o número de subscritos em referência $ qsubscript retorna o valor do i'ésimo subscrito de referência Quando as listas $ listbuild são concatenadas, o resultado é uma lista $ listbuild válida com as listas combinadas (isso é muito melhor do que usar qualquer outro delimitador!) Resumo $ query, $ qlength e $ qsubscript são úteis para lidar com matrizes globais / locais de profundidade arbitrária.

Leitura Adicional

$Query: https://docs.intersystems.com/irisforhealthlatest/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_FQUERY

$QSubscript: https: //docs.intersystems.com/irisforhealthlatest/csp/docbook/Doc.View.c ... 

$QLength: https: //docs.intersystems.com/irisforhealthlatest/csp/docbook/Doc.View.c ...

Discussion (0)0
Log in or sign up to continue
Article
· Mar 18, 2021 2m read

VSCode Tips & Tricks - SOAP Wizard

Another VSCode "Tips & Tricks" entry -

Do you want to see this option in VSCode?

This time we'll focus on how to get the SOAP Wizard as was available in Studio (to define a WSDL-based SOAP Web Service client (and Business Operation), or service).

If you work with Web Services you most probably used the SOAP Wizard in Studio. You would open it via Tools -> Add-Ins

And this opened a "Server Template" -

In VSCode you might be wondering how you can access this.

Well the basic fact you need to understand is that truly this Add-In or Wizard is simply a web page, displayed within Studio per above, and as such can also be accessed in a simple browser. VSCode facilitates the opening of such a browser with the desired content (ultimately constructing the correct URL with the right server name, port, web application, etc.).

The result would be the same as you see an option to open the Management Portal or the Class Reference (with relevant URLs) when you click on the Server Connection on the bottom Status Bar of VSCode, for example:

You will also see an entry for the SOAP Wizard.

You can achieve this by adding a 'links' entry in to your 'conn' object in your Settings JSON of your ObjectScript Extension, and specifying the desired URL (using the relevant variables).

This is mentioned in the VSCode ObjectScript's GitHub Issues discussion under a "SOAP Wizard" issue, with comments by @John Murray and @Ondřej Hoferek, and also referred to in this comment on a Community post by @Timothy Leavitt 
 

The JSON value would be:

"SOAP Wizard": "${serverUrl}/isc/studio/templates/%25ZEN.Template.AddInWizard.SOAPWizard.cls?Namespace=${namespace}${serverAuth}"

 

And this part would look like this:

Once you have this you will see an extra option when you click on the Connection -

And choosing that option will take you to the desired Wizard (opened in a Browser):

Here's a short GIF demonstrating this process (starting from the regular menu when clicking the Connection, and ending with the menu including the SOAP Wizard).

 

Note there are other Wizards (or Templates) you can add this way (like the XSD Wizard for example).

4 Comments
Discussion (4)3
Log in or sign up to continue
Article
· Mar 10, 2021 3m read

RESTでセッション共有化する方法

これは InterSystems FAQ サイトの記事です。

REST アプリケーションはステートレスであることが想定されています。

しかし、複数の REST 呼び出し間でデータを保持したい場合などの理由で、Webセッションを使用したい場合は、UseSession パラメータを使用することができます。

以下のように、Web アプリケーションのディスパッチクラスとして定義された %CSP.REST のサブクラスでUseSession パラメータを指定することで、CSPと同じようにWebセッションを使用することが可能となります。

Class REST.MyServices Extends %CSP.REST
{
 Parameter UseSession As Integer = 1;


詳細は以下のドキュメントをご覧ください。

REST での Web セッションの使用


以下は、UseSession パラメータを使用した簡単なサンプルになります。最初に、2つのクラスを作成してください。


REST.SessionTest.cls

Class REST.SessionTest Extends %CSP.REST
{

Parameter UseSession As Integer = 1;

XData UrlMap
  {
    <Routes>
      <Route Url="/test/" Method="GET" Call="test"/>
    </Routes>
  }

ClassMethod test() As %Status
  {
    write "{""SessionId"":"""_%session.SessionId_"""}"
    quit $$$OK
  }
}


REST.test.cls

Class REST.test Extends %CSP.Page
{
ClassMethod OnPage() As %Status
  {
  &html<
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> 
<script type="text/javascript" src="http://code.jquery.com/jquery-2.2.4.js"></script>
<script type="text/javascript">
function go() {
   $.ajax({
     type:'GET',
     dataType:'json',
     url:'/csp/user/rest/test/',
     success:function(data) {
       ans = '';
       for(var i in data) {
           ans = ans + '\n' + JSON.stringify(data[i]);
       }
       alert(ans);
     }
   });
  return;
  }
  </script>

      </head>
      <body>
        <form name="xxx" method="post" action="">
          <input type="button" name="test" onclick="go();" value="push" /></p>
        </form>
        Session ID: #(%session.SessionId)#<br>
      </body>
    </html>


サンプルの使用方法は以下になります。

1. 上記2つのクラスをUSERネームスペースに作成し、コンパイルする

2. ウェブアプリケーション /csp/user/rest を作成、
     ディスパッチクラスに REST.SessionTest を設定、
     セッションCookieパスを /csp/user に変更して保存

 

3. ブラウザで /csp/user/REST.test.cls を開いて、push ボタンを押す

 

Discussion (0)0
Log in or sign up to continue