This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from logzio/dev
Zipkin-logz.io integration
- Loading branch information
Showing
24 changed files
with
2,190 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea | ||
*/logzio-storage | ||
*.iml | ||
*target | ||
build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,70 @@ | ||
# zipkin-logzio | ||
# Ship Zipkin traces | ||
|
||
Zipkin-Logz.io Trace Storage is a storage option for Zipkin distributed traces on your Logz.io account. | ||
It functions as both a collector and a span store. | ||
|
||
**Note**: | ||
This integration requires Logz.io API access. | ||
The Logz.io API is available for all Enterprise accounts. | ||
If you're on a Pro account, reach out to your account manager or the <a class="intercom-launch" href="mailto:[email protected]">Sales team</a> to request API access. | ||
|
||
### Limitations | ||
|
||
When you use the Zipkin UI to find traces stored in Logz.io, there are a couple limitations. | ||
For most users, these won't be an issue, but they're still good to know: | ||
|
||
* **Lookback** must be 2 days or less | ||
* **Limit** must be 1000 traces or less | ||
|
||
## To integrate Zipkin server and Logz.io | ||
|
||
### 1. Download Zipkin server and Zipkin-Logz.io Trace Storage | ||
|
||
Download [Zipkin server](https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec). | ||
|
||
```shell | ||
wget -O zipkin.jar 'https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec' | ||
``` | ||
|
||
Download the [Zipkin-Logz.io Trace Storage](https://github.com/logzio/zipkin-logzio/releases) jar to the same directory. | ||
|
||
### 2. Run Zipkin server with the Logz.io extension | ||
|
||
You can configure the Logz.io extension with shell variables or environment variables. | ||
|
||
For a complete list of options, see the parameters below the code block.👇 | ||
|
||
```bash | ||
STORAGE_TYPE=logzio \ | ||
LOGZIO_ACCOUNT_TOKEN=<ACCOUNT-TOKEN> \ | ||
LOGZIO_LISTENER_HOST=<LISTENER-URL> \ | ||
LOGZIO_API_TOKEN=<API-TOKEN> \ | ||
LOGZIO_API_HOST=<API-URL> \ | ||
java -Dloader.path='zipkin-logzio.jar,zipkin-logzio.jar!lib' -Dspring.profiles.active=logzio -cp zipkin.jar org.springframework.boot.loader.PropertiesLauncher | ||
``` | ||
|
||
**Pro tip**: | ||
You can optionally run two discrete Zipkin-Logzio Trace Storage instances if you want to separate shipping and reading of your traces. | ||
If you do, then the required fields change a bit from what's shown in the Parameters list: | ||
|
||
* The **shipping instance** uses `STORAGE_TYPE=logzio`, `LOGZIO_ACCOUNT_TOKEN`, and `LOGZIO_LISTENER_HOST`. | ||
* The **reading instance** uses `STORAGE_TYPE=logzio`, `LOGZIO_API_TOKEN`, and `LOGZIO_API_HOST`. | ||
|
||
**Parameters** | ||
|
||
| Parameter | Description | | ||
|---|---| | ||
| **STORAGE_TYPE=logzio** | **Required**. <br> We wish there was a way to include this as a default. Alas, Zipkin needs it, so you'll need to include this bit. | | ||
| **LOGZIO_ACCOUNT_TOKEN** | **Required**. <br> Required when using as a collector to ship logs to Logz.io. <br> Replace `<ACCOUNT-TOKEN>` with the [token](https://app.logz.io/#/dashboard/settings/general) of the account you want to ship to. | | ||
| **LOGZIO_API_TOKEN** | **Required**. <br> Required to read back traces from Logz.io. <br> Replace `<API-TOKEN>` with an [API token](https://app.logz.io/#/dashboard/settings/api-tokens) from the account you want to use. | | ||
| **LOGZIO_LISTENER_HOST** | **Default**: `listener.logz.io` <br> Replace `<LISTENER-URL>` with your region's listener URL. For more information on finding your account's region, see [Account region](https://docs.logz.io/user-guide/accounts/account-region.html). | | ||
| **LOGZIO_API_HOST** | **Default**: `api.logz.io` <br> Required to read back spans from Logz.io. <br> Replace `<API-URL>` with your region's base API URL. For more information on finding your account's region, see [Account region](https://docs.logz.io/user-guide/accounts/account-region.html). | | ||
| **STRICT_TRACE_ID** | **Default**: `true` <br> Use `false` if your version of Zipkin server generates 64-bit trace IDs (version 1.14 or lower). If `false`, spans are grouped by the rightmost 16 characters of the trace ID. For version 1.15 or later, we recommend leaving the default. | | ||
| **SENDER_DRAIN_INTERVAL** | **Default**: `5` <br> Time interval, in seconds, to send the traces accumulated on the disk. | | ||
| **CLEAN_SENT_TRACES_INTERVAL** | **Default**: `30` <br> Time interval, in seconds, to clean sent traces from the disk. | | ||
|
||
### 3. Check Logz.io for your traces | ||
|
||
Give your traces some time to get from your system to ours, and then open [Kibana](https://app.logz.io/#/dashboard/kibana). | ||
|
||
If you still don't see your logs, see [log shipping troubleshooting](https://docs.logz.io/user-guide/log-shipping/log-shipping-troubleshooting.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.logz.zipkin</groupId> | ||
<artifactId>zipkin-logzio-parent</artifactId> | ||
<!--suppress MavenPropertyInParent --> | ||
<version>${zipkin-logzio-version}</version> | ||
</parent> | ||
|
||
<artifactId>zipkin-autoconfigure</artifactId> | ||
<version>${zipkin-logzio-version}</version> | ||
<packaging>pom</packaging> | ||
|
||
<properties> | ||
<main.basedir>${project.basedir}/..</main.basedir> | ||
<!-- Server is Java 8+ --> | ||
<main.java.version>1.8</main.java.version> | ||
<main.signature.artifact>java18</main.signature.artifact> | ||
</properties> | ||
|
||
<modules> | ||
<module>storage-logzio-autoconfigure</module> | ||
</modules> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.logz.zipkin</groupId> | ||
<artifactId>zipkin-autoconfigure</artifactId> | ||
<!--suppress MavenPropertyInParent --> | ||
<version>${zipkin-logzio-version}</version> | ||
</parent> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>io.logz.zipkin</groupId> | ||
<artifactId>zipkin-storage-logzio</artifactId> | ||
<version>${zipkin-logzio-version}</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>fully.qualified.MainClass</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<appendAssemblyId>false</appendAssemblyId> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> <!-- this is used for inheritance merges --> | ||
<phase>package</phase> <!-- bind to the packaging phase --> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<artifactId>zipkin-autoconfigure-storage-logzio</artifactId> | ||
<properties> | ||
<main.basedir>${project.basedir}/../..</main.basedir> | ||
</properties> | ||
</project> |
23 changes: 23 additions & 0 deletions
23
...c/main/java/zipkin/autoconfigure/storage/logzio/ZipkinLogzioStorageAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package zipkin.autoconfigure.storage.logzio; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import zipkin2.storage.StorageComponent; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(ZipkinLogzioStorageProperties.class) | ||
@ConditionalOnProperty(name = "zipkin.storage.type", havingValue = "logzio") | ||
@ConditionalOnMissingBean(StorageComponent.class) | ||
class ZipkinLogzioStorageAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
StorageComponent storage(ZipkinLogzioStorageProperties properties, | ||
@Value("${zipkin.storage.strict-trace-id:true}") boolean strictTraceId) { | ||
return properties.toBuilder().strictTraceId(strictTraceId).build(); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
...gure/src/main/java/zipkin/autoconfigure/storage/logzio/ZipkinLogzioStorageProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package zipkin.autoconfigure.storage.logzio; | ||
|
||
import ch.qos.logback.classic.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import zipkin2.storage.logzio.ConsumerParams; | ||
import zipkin2.storage.logzio.LogzioStorage; | ||
import zipkin2.storage.logzio.LogzioStorageParams; | ||
|
||
import java.io.Serializable; | ||
|
||
@ConfigurationProperties("zipkin.storage.logzio") | ||
class ZipkinLogzioStorageProperties implements Serializable { // for Spark jobs | ||
private static final long serialVersionUID = 0L; | ||
private static final Logger logger = (Logger) LoggerFactory.getLogger(ZipkinLogzioStorageProperties.class.getName()); | ||
private static final String HTTPS_PREFIX = "https://"; | ||
private static final String SEARCH_API_SUFFIX = "/v1/search"; | ||
private static final String LISTENER_HTTPS_PORT = ":8071"; | ||
|
||
private String logzioAccountToken; | ||
private String logzioApiToken; | ||
private String logzioListenerHost; | ||
private String logzioApiHost; | ||
private int senderDrainInterval; | ||
private int cleanSentTracesInterval; | ||
|
||
public void setLogzioAccountToken(String logzioAccountToken) { | ||
this.logzioAccountToken = logzioAccountToken; | ||
} | ||
|
||
public String getLogzioAccountToken() { | ||
return this.logzioAccountToken; | ||
} | ||
|
||
public void setLogzioApiToken(String logzioApiToken) { | ||
this.logzioApiToken = logzioApiToken; | ||
} | ||
|
||
public String getLogzioApiToken() { | ||
return this.logzioApiToken; | ||
} | ||
|
||
public String getLogzioListenerHost() { | ||
return logzioListenerHost; | ||
} | ||
|
||
public void setLogzioListenerHost(String logzioListenerHost) { | ||
this.logzioListenerHost = logzioListenerHost; | ||
} | ||
|
||
public String getLogzioApiHost() { | ||
return logzioApiHost; | ||
} | ||
|
||
public int getSenderDrainInterval() { | ||
return senderDrainInterval; | ||
} | ||
|
||
public void setSenderDrainInterval(int senderDrainInterval) { | ||
this.senderDrainInterval = senderDrainInterval; | ||
} | ||
|
||
public int getCleanSentTracesInterval() { | ||
return cleanSentTracesInterval; | ||
} | ||
|
||
public void setCleanSentTracesInterval(int cleanSentTracesInterval) { | ||
this.cleanSentTracesInterval = cleanSentTracesInterval; | ||
} | ||
|
||
public void setLogzioApiHost(String logzioApiHost) { | ||
this.logzioApiHost = logzioApiHost; | ||
} | ||
|
||
public LogzioStorage.Builder toBuilder() { | ||
LogzioStorageParams config = new LogzioStorageParams(); | ||
ConsumerParams consumerParams = new ConsumerParams(); | ||
consumerParams.setListenerUrl(HTTPS_PREFIX + logzioListenerHost + LISTENER_HTTPS_PORT); | ||
consumerParams.setAccountToken(logzioAccountToken); | ||
consumerParams.setSenderDrainInterval(senderDrainInterval); | ||
consumerParams.setCleanSentTracesInterval(cleanSentTracesInterval); | ||
config.setConsumerParams(consumerParams); | ||
config.setApiToken(logzioApiToken); | ||
config.setSearchApiUrl(HTTPS_PREFIX + logzioApiHost + SEARCH_API_SUFFIX); | ||
logger.info(LogzioStorage.ZIPKIN_LOGZIO_STORAGE_MSG + "config " + config.toString()); | ||
return LogzioStorage.newBuilder().config(config); | ||
} | ||
|
||
|
||
} | ||
|
2 changes: 2 additions & 0 deletions
2
autoconfigure/storage-logzio-autoconfigure/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
zipkin.autoconfigure.storage.logzio.ZipkinLogzioStorageAutoConfiguration |
14 changes: 14 additions & 0 deletions
14
autoconfigure/storage-logzio-autoconfigure/src/main/resources/zipkin-server-logzio.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# When enabled, this allows shorter env properties (ex -Dspring.profiles.active=logzio) | ||
zipkin: | ||
storage: | ||
strict-trace-id: ${STRICT_TRACE_ID:true} | ||
logzio: | ||
logzio-listener-host: ${LOGZIO_LISTENER_HOST:listener.logz.io} | ||
logzio-api-token: ${LOGZIO_API_TOKEN:} | ||
logzio-api-host: ${LOGZIO_API_HOST:api.logz.io} | ||
logzio-account-token: ${LOGZIO_ACCOUNT_TOKEN:} | ||
sender-drain-interval: ${SENDER_DRAIN_INTERVAL:5} | ||
clean-sent-traces-interval: ${CLEAN_SENT_TRACES_INTERVAL:30} | ||
|
||
|
||
|
Oops, something went wrong.