Kibana Integration - not working

Hi,

Looking at the below documentation have tried to configure Kibana in CUBA Platform somehow my Kibana is not showing index pattern defined in logback.xml.

https://www.jmix.io/cuba-platform/guides/logging-in-cuba-applications

Can you please share sample working project with ELK Integration?

Here is build.gradle and logback.xml

buildscript {
ext.cubaVersion = ‘7.2.18’
repositories {
maven {
url ‘Index of /groups/work
credentials {
username(rootProject.hasProperty(‘repoUser’) ? rootProject[‘repoUser’] : ‘cuba’)
password(rootProject.hasProperty(‘repoPass’) ? rootProject[‘repoPass’] : ‘cuba123’)
}
}

}
dependencies {
    classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion"
}

}

def modulePrefix = ‘bpd’

def globalModule = project(“:${modulePrefix}-global”)
def coreModule = project(“:${modulePrefix}-core”)
def webModule = project(“:${modulePrefix}-web”)

def servletApi = ‘javax.servlet:javax.servlet-api:3.1.0’

apply(plugin: ‘cuba’)

cuba {
artifact {
group = ‘com.touchngo.raptor’
version = ‘0.1’
isSnapshot = true
}
tomcat {
port = ‘8092’
ajpPort = ‘8093’
shutdownPort = ‘8094’
debugPort = ‘8095’
}
}

dependencies {
appComponent(“com.haulmont.cuba:cuba-global:$cubaVersion”)
appComponent(“com.haulmont.reports:reports-global:$cubaVersion”)
appComponent(‘com.haulmont.addon.restapi:restapi-global:7.2.4’)
appComponent(‘de.diedavids.cuba.dataimport:dataimport-global:0.14.1’)
}

def mysql = ‘mysql:mysql-connector-java:8.0.15’

configure([globalModule, coreModule, webModule]) {
apply(plugin: ‘java’)
apply(plugin: ‘maven’)
apply(plugin: ‘cuba’)
apply(plugin: ‘jacoco’)

jacoco {
    toolVersion = "0.8.7"
}

dependencies {
        testCompile('org.junit.jupiter:junit-jupiter-api:5.5.2')
        testCompile('org.junit.jupiter:junit-jupiter-engine:5.5.2')
        testCompile('org.junit.vintage:junit-vintage-engine:5.5.2')  
    }

task sourceJar(type: Jar) {
    from file('src')
    classifier = 'sources'
}

artifacts {
    archives sourceJar
} 
test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport
}
jacocoTestReport {
    dependsOn test
    description = 'Generates an aggregate report from all subprojects'

    def jacocoProjects = subprojects.findAll { prj ->
        return prj.project.extensions.findByName('jacoco') != null
    }

    dependsOn(jacocoProjects.jacocoTestReport)

    reports {
        html {
            enabled true
            destination new File(rootProject.buildDir, 'reports/jacoco/project')
        }
        xml {
            enabled true
            destination new File(rootProject.buildDir, 'reports/jacoco/project/jacoco-project.xml')
        }
    }

    doFirst {
        executionData.from = jacocoProjects.jacocoTestReport.executionData
    }

    doLast {
        println "##[jacocoReport dataPath='modules/${project.projectDir.name}/build/jacoco/test.exec' " +
                "includes='com.haulmont.cuba.*' " +
                "classpath='+:modules/${project.projectDir.name}/build/classes/java/main/**']"
    }
}

}

configure(globalModule) {
dependencies {
if (!JavaVersion.current().isJava8()) {
runtime(‘javax.xml.bind:jaxb-api:2.3.1’)
runtime(‘org.glassfish.jaxb:jaxb-runtime:2.3.1’)
runtime(‘com.internetitem:logback-elasticsearch-appender:1.6’)
}
}

entitiesEnhancing {
    main {
        enabled = true
    }
}

}

configure(coreModule) {

configurations {
    jdbc
    dbscripts
}

dependencies {
    compile(globalModule)
    compileOnly(servletApi)
    jdbc(mysql)
    testRuntime(mysql)
    runtime('com.internetitem:logback-elasticsearch-appender:1.6')
}

task cleanConf(description: 'Cleans up conf directory', type: Delete) {
    delete "$cuba.appHome/${modulePrefix}-core/conf"
}

task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
    appName = "${modulePrefix}-core"
    appJars(modulePrefix + '-global', modulePrefix + '-core')
}

task createDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
}

task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) {
}

}

configure(webModule) {
configurations {
webcontent
}

dependencies {
    compileOnly(servletApi)
    compile(globalModule)
    runtime('com.internetitem:logback-elasticsearch-appender:1.6')
}

task webArchive(type: Zip) {
    from file("$buildDir/web")
    from file('web')
    classifier = 'web'
}

artifacts {
    archives webArchive
}

task deployConf(type: Copy) {
    from file('src')
    include "com/touchngo/raptor/**"
    into "$cuba.appHome/${modulePrefix}/conf"
}

task clearMessagesCache(type: CubaClearMessagesCache) {
    appName = "${modulePrefix}"
}
deployConf.dependsOn clearMessagesCache

task cleanConf(description: 'Cleans up conf directory', type: Delete) {
    delete "$cuba.appHome/${modulePrefix}/conf"
}

task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
    appName = "${modulePrefix}"
    appJars(modulePrefix + '-global', modulePrefix + '-web')
}

}

task undeploy(type: Delete, dependsOn: “:${modulePrefix}-web:cleanConf”) {
delete(“$cuba.tomcat.dir/shared”)
delete(“$cuba.tomcat.dir/webapps/${modulePrefix}-core”)
delete(“$cuba.tomcat.dir/webapps/${modulePrefix}”)
}

task restart(dependsOn: [‘stop’, “:${modulePrefix}-core:deploy”, “:${modulePrefix}-web:deploy”], description: ‘Redeploys applications and restarts local Tomcat’) {
doLast {
ant.waitfor(maxwait: 6, maxwaitunit: ‘second’, checkevery: 2, checkeveryunit: ‘second’) {
not {
socket(server: ‘localhost’, port: ‘8787’)
}
}
}
}
restart.finalizedBy start

task buildUberJar(type: CubaUberJarBuilding, dependsOn: [“:${modulePrefix}-core:jacocoTestReport”, “:${modulePrefix}-web:jacocoTestReport”]) {
appName = ‘app’
webPort = 8092
logbackConfigurationFile = ‘etc/uber-jar-logback.xml’
singleJar = true
appProperties = [‘cuba.automaticDatabaseUpdate’ : true]
}

logback.xml:

<appender name="elasticsearch" class="com.internetitem.logback.elasticsearch.ElasticsearchAppender">
    <url>http://localhost:9200/</url>
    <index>raptor-crm-billing-debt-managment-logs-%date{yyyy-MM-dd}</index>
    <type>raptor-crm-billing-debt-managment</type>
    <errorLoggerName>es-error-logger</errorLoggerName>
    <includeMdc>true</includeMdc>
    <properties>
        <property>
            <name>host</name>
            <value>localhost</value>
            <allowEmpty>false</allowEmpty>
        </property>
        <property>
            <name>severity</name>
            <value>%level</value>
        </property>
        <property>
            <name>thread</name>
            <value>%thread</value>
        </property>
        <property>
            <name>logger</name>
            <value>%logger</value>
        </property>
        <property>
            <name>stacktrace</name>
            <value>%ex</value>
        </property>
    </properties>
</appender>

Regards
Zafar

Hi,
What exactly does not work?
Error messages, if they are issued by logback or by the appender, should be visible in the system out or system err logs.

The only thing I can suggest is that for the logback-elasticsearch-appender dependency - you shouldn’t attach it as runtime dependency (because this library is loaded not by CUBA app, it is loaded by another shared library - logback).
Instead, in CUBA 7.2 you should use server dependency type. See info here: Copy dependencies with server type to tomcatDir/shared/lib for local deployment · Issue #141 · cuba-platform/cuba-gradle-plugin · GitHub